Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AKS data-gatherer #30

Merged
merged 3 commits into from Jan 8, 2020
Merged

Add AKS data-gatherer #30

merged 3 commits into from Jan 8, 2020

Conversation

j-fuentes
Copy link
Member

@j-fuentes j-fuentes commented Jan 3, 2020

This adds the first implementation of the AKS datagatherer and a sample package that uses it.

This also bumps Go version to 1.13 since that is the branch we are using in CI.

Signed-off-by: Jose Fuentes jsfuentescastillo@gmail.com

@jetstack-bot jetstack-bot added the dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. label Jan 3, 2020
@jetstack-bot jetstack-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 3, 2020
@j-fuentes j-fuentes requested a review from wwwil January 3, 2020 10:41
@jetstack-bot jetstack-bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jan 3, 2020
@j-fuentes
Copy link
Member Author

It can be run with:

go run . check -c ./examples/aks.preflight.yaml

This is an example of the data that is gatherered:

{
  "aks": {
    "Cluster": {
      "properties": {
        "networkProfile": {
          "dockerBridgeCidr": "172.17.0.1/16",
          "dnsServiceIP": "10.0.0.10",
          "serviceCidr": "10.0.0.0/16",
          "podCidr": "10.244.0.0/16",
          "networkPlugin": "kubenet"
        },
        "enableRBAC": true,
        "nodeResourceGroup": "MC_preflight_preflight-test_uksouth",
        "addonProfiles": {
          "httpApplicationRouting": {
            "config": null,
            "enabled": false
          }
        },
        "servicePrincipalProfile": {
          "clientId": "***********************"
        },
        "agentPoolProfiles": [
          {
            "osType": "Linux",
            "maxPods": 110,
            "storageProfile": "ManagedDisks",
            "osDiskSizeGB": 100,
            "vmSize": "Standard_B2s",
            "count": 1,
            "name": "agentpool"
          }
        ],
        "fqdn": "preflight-test-dns-f2de96e5.hcp.uksouth.azmk8s.io",
        "dnsPrefix": "preflight-test-dns",
        "kubernetesVersion": "1.14.8",
        "provisioningState": "Succeeded"
      },
      "type": "Microsoft.ContainerService/ManagedClusters",
      "name": "preflight-test",
      "location": "uksouth",
      "id": "/subscriptions/*****************/resourcegroups/preflight/providers/Microsoft.ContainerService/managedClusters/preflight-test"
    }
  }
}

@j-fuentes
Copy link
Member Author

The credentials file required for this has been obtained with the Azure CLI by running az account get-access-token > /tmp/credentials.json.

This access token is very short-living (max 1 hour), which is suboptimal for this use case. I am exploring other alternatives to authenticate against Azure.

@jetstack-bot jetstack-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. dco-signoff: no Indicates that at least one commit in this pull request is missing the DCO sign-off message. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. dco-signoff: no Indicates that at least one commit in this pull request is missing the DCO sign-off message. labels Jan 3, 2020

// Fetch retrieves cluster information from AKS.
func (g *AKSDataGatherer) Fetch() (interface{}, error) {
client := &http.Client{}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for using the HTTP client rather than the Azure client? https://github.com/Azure-Samples/azure-sdk-for-go-samples/blob/master/compute/container_cluster.go

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a strong opinion about how it should be done, just comparing it to other gatherers.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I didn't know about https://github.com/Azure-Samples/azure-sdk-for-go-samples.

I checked https://github.com/Azure/azure-sdk-for-go and https://github.com/Azure/aks-engine and none of them can serve as a client for what we wanted here.

I will give https://github.com/Azure-Samples/azure-sdk-for-go-samples a try.

@wwwil
Copy link
Member

wwwil commented Jan 7, 2020

@j-fuentes I can confirm I've been able to run this against an actual AKS cluster and it worked correctly, so I've approved it in its current form. If you change the AKS client I will give another test, or if you decide to leave it as is I can lgtm it once rebased.

j-fuentes and others added 3 commits January 8, 2020 14:35
Signed-off-by: Jose Fuentes <jsfuentescastillo@gmail.com>
Signed-off-by: Jose Fuentes <jsfuentescastillo@gmail.com>
Signed-off-by: Jose Fuentes <jsfuentescastillo@gmail.com>
@jetstack-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: j-fuentes, wwwil

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jetstack-bot jetstack-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 8, 2020
@j-fuentes
Copy link
Member Author

@j-fuentes I can confirm I've been able to run this against an actual AKS cluster and it worked correctly, so I've approved it in its current form. If you change the AKS client I will give another test, or if you decide to leave it as is I can lgtm it once rebased.

I have just rebased the current master.

After checking Azure-samples/azure-sdk-for-go-samples it does not seem like something we should rely on because of several reasons: it looks like "sample" code, I don't think it is designed to be a library.

@wwwil
Copy link
Member

wwwil commented Jan 8, 2020

/lgtm

@jetstack-bot jetstack-bot added the lgtm Indicates that a PR is ready to be merged. label Jan 8, 2020
@jetstack-bot jetstack-bot merged commit fc93276 into jetstack:master Jan 8, 2020
@j-fuentes j-fuentes deleted the aks-support branch January 8, 2020 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants