AKS icon indicating copy to clipboard operation
AKS copied to clipboard

Enabling monitoring addon breaks IMDS access

Open mibollma opened this issue 5 years ago • 7 comments

What happened: When enabling the monitoring addon/oms_agent either through terraform or Azure CLI, pods are unable to access IMDS to retrieve their system assigned identity credentials.

What you expected to happen: Enabling the monitoring addon has no impact on access to IMDS

How to reproduce it (as minimally and precisely as possible):

Terraform Cluster

resource "azurerm_kubernetes_cluster" "somecluster" {
  name                = "somecluster"
  location            = azurerm_resource_group.somegroup.location
  resource_group_name = azurerm_resource_group.somegroup.name
  dns_prefix          = "someprefix"

  default_node_pool {
    name            = "default"
    node_count      = 1
    vm_size         = "Standard_D2_v2"
    os_disk_size_gb = 30
    vnet_subnet_id  = azurerm_subnet.somesubnet.id
  }

  network_profile {
    network_plugin = "azure"
  }

  identity {
    type = "SystemAssigned"
  }

  role_based_access_control {
    enabled = true
  }

  addon_profile {
    oms_agent {
      enabled                    = true
      log_analytics_workspace_id = azurerm_log_analytics_workspace.someworkspace.id
    }
  }
}

Replacing oms_agent with az aks enable-addons -a monitoring ... has the same effect.

Anything else we need to know?:

Pods start producing errors such as

2021-10-21 09:04:12.004Z ERROR c.a.i.implementation.IdentityClient - ManagedIdentityCredential authentication unavailable. Connection to IMDS endpoint cannot be established.
2021-10-21 09:04:12.012Z ERROR c.a.i.ManagedIdentityCredential - Azure Identity => ERROR in getToken() call for scopes [https://monitor.azure.com//.default]: ManagedIdentityCredential authentication unavailable. Connection to IMDS endpoint cannot be established.
2021-10-21 09:04:12.014Z ERROR c.a.c.i.AccessTokenCache - Failed to acquire a new access token.
2021-10-21 09:04:12.020Z WARN  c.m.a.a.i.q.QuickPulsePingSender - Pinging live metrics endpoint: ManagedIdentityCredential authentication unavailable. Connection to IMDS endpoint cannot be established. (future warnings will be aggregated and logged once every 5 minutes)
com.azure.identity.CredentialUnavailableException: ManagedIdentityCredential authentication unavailable. Connection to IMDS endpoint cannot be established.
        at com.azure.identity.implementation.IdentityClient.lambda$authenticateToIMDSEndpoint$49(IdentityClient.java:1154)
        at reactor.core.publisher.MonoCallable.call(MonoCallable.java:92)
        at reactor.core.publisher.FluxFlatMap.trySubscribeScalarMap(FluxFlatMap.java:174)
        at reactor.core.publisher.MonoFlatMap.subscribeOrReturn(MonoFlatMap.java:53)
        at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:57)
        at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
        at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
        at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
        at reactor.core.publisher.MonoFromFluxOperator.subscribe(MonoFromFluxOperator.java:81)
        at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
        at reactor.core.publisher.Mono.subscribe(Mono.java:4338)
        at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.subscribeNext(MonoIgnoreThen.java:255)
        at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:51)
        at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
        at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
        at reactor.core.publisher.Mono.subscribe(Mono.java:4338)
        at reactor.core.publisher.Mono.block(Mono.java:1703)
        at com.microsoft.applicationinsights.agent.internal.quickpulse.QuickPulsePingSender.ping(QuickPulsePingSender.java:116)
        at com.microsoft.applicationinsights.agent.internal.quickpulse.QuickPulseCoordinator.ping(QuickPulseCoordinator.java:107)
        at com.microsoft.applicationinsights.agent.internal.quickpulse.QuickPulseCoordinator.run(QuickPulseCoordinator.java:63)
        at java.base/java.lang.Thread.run(Unknown Source)
        Suppressed: java.lang.Exception: #block terminated with an error
                at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:99)
                at reactor.core.publisher.Mono.block(Mono.java:1704)
                ... 4 common frames omitted

mibollma avatar Oct 21 '21 21:10 mibollma

Hi mibollma, AKS bot here :wave: Thank you for posting on the AKS Repo, I'll do my best to get a kind human from the AKS team to assist you.

I might be just a bot, but I'm told my suggestions are normally quite good, as such:

  1. If this case is urgent, please open a Support Request so that our 24/7 support team may help you faster.
  2. Please abide by the AKS repo Guidelines and Code of Conduct.
  3. If you're having an issue, could it be described on the AKS Troubleshooting guides or AKS Diagnostics?
  4. Make sure your subscribed to the AKS Release Notes to keep up to date with all that's new on AKS.
  5. Make sure there isn't a duplicate of this issue already reported. If there is, feel free to close this one and '+1' the existing issue.
  6. If you have a question, do take a look at our AKS FAQ. We place the most common ones there!

ghost avatar Oct 21 '21 21:10 ghost

If you are running AAD pod identity, then you should be able to resolve the issue by following step 3 of this link: https://docs.microsoft.com/en-us/azure/azure-monitor/containers/container-insights-troubleshoot#metrics-arent-being-collected

If you are still having issues, please reach out to [email protected].

austonli avatar Oct 22 '21 16:10 austonli

@austonli Thanks for your reply.

I do not use AAD pod identity, at least not knowingly. Also the issue is not about that metrics are not being collected.

As soon a I enable the monitoring addon all of my other unrelated pods are unable to reach the IMDS endpoint, which works fine before. Do you have any idea why one might impact the other?

mibollma avatar Oct 22 '21 21:10 mibollma

Hi @mibollma , sorry for the delay, we will investigate this issue and get back shortly, thanks!

@ganga1980 please review and answer this.

austonli avatar Oct 29 '21 16:10 austonli

Triage required from @Azure/aks-pm

ghost avatar Nov 03 '21 06:11 ghost

Hi, @mibollma , looks like this is the issue with client library which you are using in your java container when both system and user assigned managed identity exists. can you please run curl command - https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/how-to-use-vm-token#get-a-token-using-curl and see if it works? if this works, then most likely issue with client library which you are using? if yes, please provide more details about the version of the client library you are using and also sample code how you are trying to get the token from IMDS endpoint.

ganga1980 avatar Nov 03 '21 07:11 ganga1980

Currently I'm unable to reproduce the issue even though the setup didn't change much. IMDS access works with curl and with the client library even when enabling the addon. I'll close this issue for now, thanks for your support.

mibollma avatar Nov 05 '21 10:11 mibollma