AKS icon indicating copy to clipboard operation
AKS copied to clipboard

[BUG] NPD DNS health check fails to discover CoreDNS IP on additional system/user node pools

Open janlauber opened this issue 1 year ago • 32 comments

Describe the bug Node Problem Detector's DNS health check script fails to discover the correct CoreDNS service IP on additional system and user node pools, resulting in persistent CoreDNSUnreachable warning events. The script successfully discovers the IP on the default system node pool but falls back to an incorrect hardcoded default (10.0.0.10) on other pools.

Root cause: AKS provisions different node pool types with inconsistent kubelet configurations. The default pool uses inline flags in /etc/default/kubelet while additional pools use a separate config file (/etc/default/kubeletconfig.json). The NPD discovery script only reads from the inline flags file, missing the config file approach entirely.


To Reproduce Steps to reproduce the behavior:

  1. Create an AKS cluster with Kubernetes 1.31+
  2. Create additional system node pools:
    az aks nodepool add \
      --resource-group <resource-group> \
      --cluster-name <cluster-name> \
      --name syspoolzone2 \
      --mode System
    
  3. Create user node pools:
    az aks nodepool add \
      --resource-group <resource-group> \
      --cluster-name <cluster-name> \
      --name apppool \
      --mode User
    
  4. SSH to a node in an additional pool:
    kubectl debug node/<additional-pool-node> \
      -it \
      --image=mcr.microsoft.com/cbl-mariner/busybox:2.0 \
      --profile=sysadmin
    
  5. Inside debug pod, access host filesystem:
    chroot /host
    
  6. Check kubelet configuration on additional pool:
    cat /etc/default/kubelet | grep cluster-dns
    # No output - flag is missing
    
  7. Compare with default pool:
    # On default system pool node:
    cat /etc/default/kubelet | grep cluster-dns
    # Output: KUBELET_FLAGS=...--cluster-dns=10.52.0.10...
    
  8. Check kubelet config file on additional pool:
    cat /etc/default/kubeletconfig.json | grep clusterDNS
    # Output: "clusterDNS": ["10.52.0.10"]
    
  9. Observe Node Problem Detector events:
    kubectl get events --all-namespaces --field-selector reason=CoreDNSUnreachable
    
  10. See persistent warnings on additional node pools only

Expected behavior All node pools should discover the correct CoreDNS service IP regardless of how the kubelet is configured (inline flags or config file), and DNS health checks should pass for all nodes.


Current behaviour Default system node pool:

  • NPD discovers correct IP (example: 10.52.0.10) from inline --cluster-dns flag
  • DNS test still fails because node-level DNS cannot reach CoreDNS
  • Events show: dns test to coredns:10.52.0.10 over udp failed after 2 attempts

Additional system/user node pools:

  • NPD discovers incorrect IP (10.0.0.10 - hardcoded fallback)
  • DNS test fails with wrong IP
  • Events show: dns test to coredns:10.0.0.10 over udp failed after 2 attempts
  • Misleading warning suggests CoreDNS is unreachable when it's actually correctly configured

Additional context

Proposed Solution

Update NPD's check_dns_common.sh to add fallback logic for parsing /etc/default/kubeletconfig.json when inline --cluster-dns flag is not found:

Code Change

Add this logic after the existing kubelet flags check and before the "Validate IP format" comment:

# NEW: If still empty, try reading from kubelet config JSON file
if [ -z "$coredns_ip" ] && [ -f "/etc/default/kubeletconfig.json" ]; then
    coredns_ip=$(grep -o '"clusterDNS"[[:space:]]*:[[:space:]]*\[[[:space:]]*"[0-9.]*"' /etc/default/kubeletconfig.json | \
        grep -o '[0-9]\{1,3\}\(\.[0-9]\{1,3\}\)\{3\}' | head -1)
fi

Rationale

  • Uses only standard POSIX tools (grep, no jq dependency)
  • Maintains existing code style and patterns
  • Handles both single and multiple IPs in array
  • Minimal performance impact
  • Non-breaking change - only adds fallback capability
  • Same IP regex pattern as existing kubelet flags check

Discovery Chain After Fix

1. Try iptables NAT rules
   └─ Fails: Cilium eBPF has no NAT rules
   
2. Try LocalDNS corefile
   └─ Fails: LocalDNS not enabled
   
3. Try /etc/default/kubelet inline flag
   ├─ Default pool: ✅ Succeeds
   └─ Additional pools: Fails, continue
   
4. NEW: Try /etc/default/kubeletconfig.json
   └─ Additional pools: ✅ Succeeds
   
5. Fallback to hardcoded 10.0.0.10
   └─ Only reached if config completely missing


Workarounds

Enable LocalDNS

When LocalDNS feature becomes generally available:

  1. Request Azure subscription admin to register LocalDNSPreview feature
  2. Enable LocalDNS on node pools using updated AzAPI provider or Azure CLI
  3. LocalDNS provides proper node-level DNS resolution independent of NPD script discovery

Environment

Cluster Configuration:

  • AKS Kubernetes version: 1.33.3
  • Node OS: Azure Linux V3 (AKSAzureLinux-V3gen2-202511.07.0)
  • Network plugin: Cilium with kube-proxy replacement mode
  • CNI mode: eBPF
  • VM SKU: Standard_D4as_v6

Affected Node Pools:

  • System node pools: syspoolzone2, syspoolzone3
  • User node pools: apppoolzone1, apppoolzone2, apppoolzone3

Unaffected:

  • Default system node pool (zone 1) - uses legacy inline flags approach

Events Evidence

Events on Additional Pools

kubectl get events --all-namespaces --field-selector reason=CoreDNSUnreachable

NAMESPACE   LAST SEEN        TYPE      REASON              OBJECT                           MESSAGE
            11m (recurring)  Warning   CoreDNSUnreachable  node/aks-syspoolzone2-xxxxx-0   dns test to coredns:10.0.0.10 over udp failed after 2 attempts
            11m (recurring)  Warning   CoreDNSUnreachable  node/aks-syspoolzone3-xxxxx-0   dns test to coredns:10.0.0.10 over udp failed after 2 attempts
            (repeating every 5 minutes)

Events on Default Pool

            11m (recurring)  Warning   CoreDNSUnreachable  node/aks-system-xxxxx-0          dns test to coredns:10.52.0.10 over udp failed after 2 attempts

Note: Even though zone 1 has the correct IP, it still fails because node-level DNS cannot reach CoreDNS (I think this is separate issue with node DNS configuration and Cilium eBPF and resolves itself after some time).


Technical Context

Cilium eBPF Impact

The issue is amplified (made visible) by Cilium's kube-proxy replacement:

  • Traditional kube-proxy creates iptables NAT rules (NPD's first discovery method)
  • Cilium eBPF bypasses iptables entirely
  • With no iptables, NPD falls back to kubelet flags (second method)
  • Missing flags cause discovery to fail on additional pools

Without Cilium eBPF, the iptables-based discovery would succeed on all pools, masking this configuration inconsistency.


Related Issues

  • LocalDNS Feature: When enabled, will provide proper node-level DNS resolution independent of NPD script discovery (resolves both the discovery issue and underlying node DNS problem)
  • Kubelet Configuration Standardization: Future AKS versions should standardize kubelet configuration approach across all node pool types

Suggested Next Steps

  1. Immediate: Update NPD scripts to support /etc/default/kubeletconfig.json parsing
  2. Short-term: Communicate known limitation in AKS documentation
  3. Medium-term: Promote LocalDNS feature as standard for all clusters?
  4. Long-term: Migrate default system pools to config file approach (breaking change for future major version)

janlauber avatar Nov 18 '25 23:11 janlauber

@janlauber - Thank you for such amazing notes and investigation. Yes, we are aware of this issue and have created a PR with the fix. Due to holiday season, the rollout with the fix may get delayed. For now, the message can be ignored and does not have any other impact.

SriHarsha001 avatar Nov 19 '25 01:11 SriHarsha001

To be clear, kubeletconfig.json file is created on node with customization configuration. https://learn.microsoft.com/en-us/azure/aks/custom-node-configuration?tabs=linux-node-pools

jacobbaek avatar Nov 20 '25 09:11 jacobbaek

@SriHarsha001 can you please provide an update, thanks!

sjwaight avatar Dec 04 '25 21:12 sjwaight

Hi there thank you for responding. Are there any news regarding this? @SriHarsha001

janlauber avatar Dec 19 '25 12:12 janlauber

My tickets waiting for a solution from microsoft are all several months old. 🥇

chrisaq avatar Jan 13 '26 10:01 chrisaq

Sorry I missed to update this thread. The bug was fixed a month ago and had to wait for the rollout to start due to code freeze during holidays.

SriHarsha001 avatar Jan 14 '26 21:01 SriHarsha001

My tickets waiting for a solution from microsoft are all several months old. 🥇

Sorry for your experience, I request you to create a support case or follow up with the engineer working on your case for updates.

SriHarsha001 avatar Jan 14 '26 21:01 SriHarsha001

Sorry I missed to update this thread. The bug was fixed a month ago and had to wait for the rollout to start due to code freeze during holidays.

Sounds good, do you konw when this rollout will start?

chrisaq avatar Jan 15 '26 08:01 chrisaq

Hi @SriHarsha001 , is there a plan to rollout the fix? We are facing a lot of issues on production due to this bug.

KumarAshish-fareye avatar Jan 16 '26 05:01 KumarAshish-fareye

hey @SriHarsha001 we are also hitting this one

JordanP avatar Jan 19 '26 14:01 JordanP

Apologize for the delay. I just got back to work this week.

This bug was fixed in Nov 2025 and should have been rolled out to all regions starting from 01/04/2026.

I created a new test cluster and verified the fix.

Please note - This is only a warning message that shows up in node events and should not have any impact to the availability of the node.

On my test cluster that I created today -

Inside the node - 
cat /etc/default/kubeletconfig.json

  "clusterDNS": [
    "10.100.0.10"
  ],

kubectl get events --all-namespaces --field-selector reason=CoreDNSUnreachable
No resources found

Please perform node image update - https://learn.microsoft.com/en-us/azure/aks/upgrade-node-image to get the latest VHD.

SriHarsha001 avatar Feb 05 '26 18:02 SriHarsha001

cc @varora24

SriHarsha001 avatar Feb 05 '26 18:02 SriHarsha001

Thanks for the update. Closing this issue as resolved.

varora24 avatar Feb 05 '26 19:02 varora24

How do we check what node image this was fixed from?

tbertenshaw avatar Feb 19 '26 11:02 tbertenshaw

Hi @tbertenshaw , You can track the rollout of AKS node image versions across regions using the AKS release tracker. Since this was fixed in the January release, you can upgrade to any node image version starting with 202601.XX. We recommend upgrading to the latest available image, as it includes the most recent security and CVE fixes.

varora24 avatar Feb 19 '26 18:02 varora24

We have the latest image version running on the cluster nodes but still seem to see this issue occuring as warning:

Image Image

Did we mis something or is the bug not as fixed as this thread describes

tom171296 avatar Feb 24 '26 07:02 tom171296

Can you open the SR request as below with details?

saewoni avatar Feb 26 '26 05:02 saewoni

Going to re-open as I think the SR automation didn't fire as this is closed.

sjwaight avatar Feb 26 '26 05:02 sjwaight

@tom171296 please see the SR request. Thanks.

sjwaight avatar Feb 26 '26 06:02 sjwaight

I think this is not done yet

janlauber avatar Mar 12 '26 20:03 janlauber