Skip to content

AKS data-gatherer missing some information #40

Open

Description

@wwwil

Currently the AKS data gatherer collects information about the configuration of an AKS cluster from the Azure API.

https://docs.microsoft.com/en-us/rest/api/aks/managedclusters/get

The information returned includes a list of node pools, referred to as agent pools. However it does not give details of each of these pools. This needs to be fetched separately. We should get the configuration of each node pool so we can make the checks performed in the AKS package more comprehensive.

https://docs.microsoft.com/en-us/rest/api/aks/agentpools/get

These will both return separate JSON documents, in fact there will be a JSON document for each node pool. We need to work out how this will be handled in Preflight. We could put them all in a list in master JSON document to evaluate with Rego. Alternatively we could make an AKS node pool data gatherer separately, but this would require support for multiple instances of the same data gatherer type to fetch multiple node pools and seems like more work for users.

I had misunderstood the problem here. Using the az aks show --resource-group preflight --name preflight-test-wil command I can see all the required information, as described in the API spec: https://docs.microsoft.com/en-us/rest/api/aks/managedclusters/get

However when using HTTP GET requests, as the data gatherer does, some information is missing. This also occurs when doing the same thing manually with the curl command.

Related to #30

Activity

  1. wwwil commented on Jan 10, 2020

    @wwwil
    ContributorAuthor

    Reading though the docs a bit closer it looks like the agentPoolProfiles part of what we get from the cluster JSON should have what we need, so we don't need to get the agent pool JSON separately. However, in examples it seems to be missing some values... Specifically I want properties.agentPoolProfiles[_].type.

  2. changed the title [-]Expand AKS data-gatherer to get node information[/-] [+]AKS data-gatherer missing some information[/+] on Jan 10, 2020
  3. wwwil commented on Jan 10, 2020

    @wwwil
    ContributorAuthor

    I'm going to look into how the az command gets it's information on Monday and try to work out what we need to change in Preflight. Going to start looking at this function that @j-fuentes found: https://github.com/Azure/azure-cli/blob/addbaf43b4618a500e5690a84096ddbef00df642/src/azure-cli/azure/cli/command_modules/acs/custom.py#L1902

  4. wwwil commented on Jan 10, 2020

    @wwwil
    ContributorAuthor

    /assign @wwwil

  5. wwwil commented on Jan 15, 2020

    @wwwil
    ContributorAuthor

    I'm now finding curl gets the info I want, but it is still not shown in the Preflight intermediate data.

    $ curl -i -H "Authorization: Bearer $(jq -r .accessToken /tmp/credentials.json)" https://management.azure.com/subscriptions/4b4cdf50-7109-4d7a-9866-bbbb3d34acf9/resourceGroups/preflight/providers/Microsoft.ContainerService/managedClusters/preflight-test-wil\?api-version\=2019-08-01
    

    Gives:

    ...
       "agentPoolProfiles": [
        {
         "name": "agentpool",
         "count": 3,
         "vmSize": "Standard_DS2_v2",
         "osDiskSizeGB": 100,
         "maxPods": 110,
         "type": "VirtualMachineScaleSets",
         "provisioningState": "Succeeded",
         "orchestratorVersion": "1.14.8",
         "osType": "Linux"
        }
      ]
    ...
    

    However looking at the aks_basic.intermediate.json file it looks like this:

    ...
            "agentPoolProfiles": [
              {
                "name": "agentpool",
                "count": 3,
                "vmSize": "Standard_DS2_v2",
                "osDiskSizeGB": 100,
                "storageProfile": "ManagedDisks",
                "maxPods": 110,
                "osType": "Linux"
              }
            ],
    ...
    
  6. wwwil commented on Jan 15, 2020

    @wwwil
    ContributorAuthor

    Confirmed the problem! I'm not sure why I was not getting full info previously with curl, but when that started to work I looked into our code again and noticed the JSON from the API is unmarshalled into a struct that is missing the type field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions