Skip to content

Room 19

DNS & SERVICE DISCOVERY


The Signal Tower

  • Every Service gets a DNS name in Kubernetes, powered by CoreDNS.
  • A chain of services have been deployed - follow the DNS trail to find the hidden password.

📜 Mission Briefing

  1. Examine the CoreDNS deployment: kubectl get pods -n kube-system -l k8s-app=kube-dns.
  2. View the CoreDNS ConfigMap: kubectl get cm coredns -n kube-system -o yaml.
  3. Three services have been deployed: svc-alpha, svc-beta, svc-gamma in namespace dns-trail.
  4. From a test pod, resolve each service’s FQDN:
    kubectl run dns-test --image=busybox --rm -it -- nslookup svc-alpha.dns-trail.svc.cluster.local
    
  5. Curl svc-gamma.dns-trail - it returns the password.
  6. The password is coredns42.

Key Commands
Command Purpose
kubectl get svc -n kube-system CoreDNS service
kubectl get cm coredns -n kube-system -o yaml CoreDNS config
kubectl run test --image=busybox --rm -it -- nslookup SVC DNS resolution
kubectl exec POD -- cat /etc/resolv.conf Pod DNS config

How DNS Works in Kubernetes
# Service DNS format:
# <service>.<namespace>.svc.cluster.local
#
# Pod DNS format (for StatefulSets):
# <pod-name>.<service>.<namespace>.svc.cluster.local

# Short forms (within same namespace):
# <service>                        → my-service
# <service>.<namespace>            → my-service.production
# <service>.<namespace>.svc        → my-service.production.svc

# DNS resolution from a pod
kubectl run dns-test --image=busybox:1.36 --rm -it --restart=Never -- \
  nslookup kubernetes.default.svc.cluster.local

# Check pod's DNS configuration
kubectl exec my-pod -- cat /etc/resolv.conf
# nameserver 10.96.0.10
# search default.svc.cluster.local svc.cluster.local cluster.local

# CoreDNS Corefile (configuration)
kubectl get cm coredns -n kube-system -o yaml
# .:53 {
#     kubernetes cluster.local in-addr.arpa ip6.arpa {
#         pods insecure
#         fallthrough in-addr.arpa ip6.arpa
#     }
#     forward . /etc/resolv.conf
#     cache 30
#     loop
#     reload
#     loadbalance
# }

# Headless services (ClusterIP: None) return pod IPs directly
# Used with StatefulSets for stable DNS names per pod

Hints

Hint 1

Create a test pod for DNS lookups:

kubectl run dns-test --image=busybox:1.36 --rm -it --restart=Never -- sh
# Inside: nslookup svc-gamma.dns-trail

Hint 2

Or use wget directly:

kubectl run test --image=busybox --rm -it --restart=Never -- \
  wget -qO- http://svc-gamma.dns-trail

Hint 3

The password is coredns42.


🔓 Unlock Room 20

openssl enc -aes-256-cbc -d -a -pbkdf2 \
        -in ../room_20/README             \
        -out ../room_20/README.txt        \
        -pass pass:PASSWORD
cat ../room_20/README.txt