Test DNS inside the cluster

Start a throwaway pod to resolve a cluster name; this checks CoreDNS and the kube-dns service.

kubectl run dnsutils --image=tutum/dnsutils -it --rm --restart=Never -- nslookup kubernetes.default

tool
troubleshooting32 commands
tags
troubleshootingk8sdnsdebug

More troubleshooting commands

  • dig +short @$(kubectl -n kube-system get svc kube-dns -o jsonpath='{.spec.clusterIP}') <name>.<ns>.svc.cluster.local

    Send the query straight to the CoreDNS clusterIP; with ndots:5, short names cause many extra queries.

  • kubectl -n kube-system get cm coredns -o yaml; kubectl -n kube-system logs deploy/coredns --tail=50

    Check the Corefile (forward, cache) and the latest logs for SERVFAIL and upstream errors.

  • nmap --script ssl-enum-ciphers -p 443 <host>

    Grade the supported TLS versions and ciphers on a port and flag weak or deprecated ones.

  • openssl s_client -connect <host>:443 -servername <host> -showcerts 2>/dev/null | grep -E 'Verify|s:|i:'

    Show the full chain with the right SNI; the Verify line catches missing intermediate certificates.

  • for h in $(cat hosts.txt); do echo -n "$h "; echo | openssl s_client -connect $h:443 -servername $h 2>/dev/null | openssl x509 -noout -enddate; done

    Print the notAfter date for every host in hosts.txt to see which certificates expire soon.

all 32 troubleshooting commands