Práctica · De adentro hacia afuera
Practice · From the inside out
Pratica · Da dentro verso fuori
Paso 1 — probar desde un pod
Step 1 — test from a pod
Passo 1 — provare da un pod
k run t --rm -it --image=busybox:1.28 -- sh
nslookup kubernetes.default # el que SIEMPRE existe# the one that ALWAYS exists# quello che esiste SEMPRE
nslookup web
nslookup web.default.svc.cluster.local
nslookup web.otro-ns.svc.cluster.local
Paso 2 — la config del cliente
Step 2 — the client's config
Passo 2 — la config del client
k exec app -- cat /etc/resolv.conf
# nameserver 10.96.0.10 <- la ClusterIP del Service kube-dns# nameserver 10.96.0.10 <- the ClusterIP of the kube-dns Service# nameserver 10.96.0.10 <- la ClusterIP del Service kube-dns
# search default.svc.cluster.local svc.cluster.local cluster.local
# options ndots:5
# ¿Coincide con el Service real?# Does it match the real Service?# Coincide col Service reale?
k get svc -n kube-system kube-dns
Paso 3 — CoreDNS
Step 3 — CoreDNS
Passo 3 — CoreDNS
k get pods -n kube-system -l k8s-app=kube-dns
# 2 pods, deberían estar Running 1/1# 2 pods, they should be Running 1/1# 2 pod, dovrebbero essere Running 1/1
k logs -n kube-system -l k8s-app=kube-dns --tail=50
k describe pod -n kube-system -l k8s-app=kube-dns
# ¿El Service de DNS tiene endpoints? (¡el mismo chequeo de siempre!)# Does the DNS Service have endpoints? (the same check as always!)# Il Service del DNS ha endpoint? (lo stesso controllo di sempre!)
k get endpointslices -n kube-system -l kubernetes.io/service-name=kube-dns
Paso 4 — el Corefile
Step 4 — the Corefile
Passo 4 — il Corefile
k get cm -n kube-system coredns -o yaml
# errors / health / kubernetes cluster.local / forward . /etc/resolv.conf
k edit cm -n kube-system coredns
# Editar el CM NO reinicia CoreDNS: forzalo# Editing the CM does NOT restart CoreDNS: force it# Modificare la CM NON riavvia CoreDNS: forzalo
k rollout restart deploy -n kube-system coredns
k rollout status deploy -n kube-system coredns
Probar el servidor sin intermediarios
Testing the server with no middlemen
Provare il server senza intermediari
# Consultar directo a la IP de un pod de CoreDNS# Query a CoreDNS pod's IP directly# Interrogare direttamente l'IP di un pod di CoreDNS
k get pods -n kube-system -l k8s-app=kube-dns -o wide
nslookup web 10.244.0.5
# Si el pod responde pero el Service no → problema del Service kube-dns# If the pod answers but the Service does not → the kube-dns Service is the problem# Se il pod risponde ma il Service no → il problema è il Service kube-dns
⚠
Un deny-all de egress (M7) rompe el DNS de todos los pods del namespace y el síntoma es «nada resuelve», idéntico a CoreDNS caído. Si CoreDNS está Running y sano pero un namespace puntual no resuelve, mirá k get netpol -n <ns> antes que cualquier otra cosa.
An egress deny-all (M7) breaks DNS for every pod in the namespace and the symptom is "nothing resolves", identical to CoreDNS being down. If CoreDNS is Running and healthy but one particular namespace does not resolve, check k get netpol -n <ns> before anything else.
Un deny-all di egress (M7) rompe il DNS di tutti i pod del namespace e il sintomo è «non risolve nulla», identico a CoreDNS caduto. Se CoreDNS è Running e sano ma un namespace specifico non risolve, guarda k get netpol -n <ns> prima di ogni altra cosa.
Teoría · Cómo resuelve un pod
Theory · How a pod resolves
Teoria · Come risolve un pod
La cadena del DNS
The DNS chain
La catena del DNS
El kubelet escribe /etc/resolv.conf en cada pod apuntando a la ClusterIP del Service kube-dns (típicamente 10.96.0.10). Ese Service enruta a los pods de CoreDNS, que corren como Deployment en kube-system y responden consultando la API de Kubernetes.
The kubelet writes /etc/resolv.conf in every pod pointing at the kube-dns Service's ClusterIP (typically 10.96.0.10). That Service routes to the CoreDNS pods, which run as a Deployment in kube-system and answer by querying the Kubernetes API.
Il kubelet scrive /etc/resolv.conf in ogni pod puntando alla ClusterIP del Service kube-dns (tipicamente 10.96.0.10). Quel Service instrada ai pod di CoreDNS, che girano come Deployment in kube-system e rispondono interrogando l'API di Kubernetes.
El nombre completo
The full name
Il nome completo
<servicio>.<namespace>.svc.cluster.local. Desde el mismo namespace alcanza con el nombre corto; desde otro hace falta al menos servicio.namespace. Los pods headless (M6) agregan un nivel: <pod>.<servicio>.<namespace>.svc.cluster.local.
<service>.<namespace>.svc.cluster.local. From the same namespace the short name is enough; from another you need at least service.namespace. Headless pods (M6) add a level: <pod>.<service>.<namespace>.svc.cluster.local.
<servizio>.<namespace>.svc.cluster.local. Dallo stesso namespace basta il nome breve; da un altro serve almeno servizio.namespace. I pod headless (M6) aggiungono un livello: <pod>.<servizio>.<namespace>.svc.cluster.local.
ndots:5, el detalle raro
ndots:5, the odd detail
ndots:5, il dettaglio strano
Significa: «si el nombre tiene menos de 5 puntos, probá primero con los sufijos de search». Por eso web se intenta como web.default.svc.cluster.local antes que como dominio externo — y por eso resolver nombres de internet desde un pod genera varias consultas fallidas antes de acertar. Es lento pero correcto; no lo «arregles».
It means: "if the name has fewer than 5 dots, try the search suffixes first". That is why web is tried as web.default.svc.cluster.local before being treated as an external domain — and why resolving internet names from a pod produces several failed queries before hitting. It is slow but correct; do not "fix" it.
Significa: «se il nome ha meno di 5 punti, prova prima i suffissi di search». Per questo web viene tentato come web.default.svc.cluster.local prima che come dominio esterno — e per questo risolvere nomi di internet da un pod genera diverse query fallite prima di azzeccarci. È lento ma corretto; non «aggiustarlo».
busybox miente con los nombres con punto
busybox lies about dotted names
busybox mente sui nomi con punto
musl (la libc de busybox y alpine) no implementa ndots. Si el nombre trae aunque sea un punto, lo consulta como absoluto antes de probar los search. Con glibc (nginx, debian) pasa lo contrario: ndots:5 manda y los sufijos del cluster van primero.
Casi siempre da igual… salvo cuando el segundo tramo del nombre es un TLD real. Un namespace llamado red o net hace que web.red o web.net se resuelvan en internet y te devuelvan una IP pública que existe y hasta contesta. El diagnóstico se va al demonio persiguiendo un pod que nunca fue tuyo. Verificalo siempre con el FQDN completo (web.red.svc.cluster.local) o desde una imagen glibc.
musl (busybox's and alpine's libc) does not implement ndots. If the name carries even one dot, it queries it as absolute before trying the search suffixes. With glibc (nginx, debian) it is the opposite: ndots:5 rules and the cluster suffixes go first.
It almost never matters… except when the name's second label is a real TLD. A namespace called red or net makes web.red or web.net resolve on the internet and hand you a public IP that exists and even answers. The diagnosis then goes to pieces chasing a pod that was never yours. Always confirm with the full FQDN (web.red.svc.cluster.local) or from a glibc image.
musl (la libc di busybox e alpine) non implementa ndots. Se il nome contiene anche un solo punto, lo interroga come assoluto prima di provare i suffissi search. Con glibc (nginx, debian) è il contrario: comanda ndots:5 e i suffissi del cluster vengono per primi.
Quasi sempre è indifferente… tranne quando la seconda etichetta del nome è un TLD reale. Un namespace chiamato red o net fa sì che web.red o web.net si risolvano su internet e ti restituiscano un IP pubblico che esiste e magari risponde pure. La diagnosi va a rotoli inseguendo un pod che non è mai stato tuo. Conferma sempre col FQDN completo (web.red.svc.cluster.local) o da un'immagine glibc.
Las causas, en orden
The causes, in order
Le cause, in ordine
| Síntoma | Causa probable |
| Symptom | Likely cause |
| Sintomo | Causa probabile |
| Nada resuelve, en todo el cluster | Nothing resolves, cluster-wide | Non risolve nulla, in tutto il cluster | CoreDNS caído o sin endpoints | CoreDNS down or with no endpoints | CoreDNS caduto o senza endpoint |
| Nada resuelve, un solo ns | Nothing resolves, one ns only | Non risolve nulla, un solo ns | NetworkPolicy de egress | An egress NetworkPolicy | Una NetworkPolicy di egress |
| Resuelve interno, no externo | Internal resolves, external does not | Risolve interno, non esterno | forward del Corefile | The Corefile's forward | Il forward del Corefile |
| Un servicio puntual no resuelve | One particular service does not resolve | Un servizio specifico non risolve | El Service no existe / typo / ns | The Service does not exist / typo / ns | Il Service non esiste / refuso / ns |
| Resuelve a una IP vieja | Resolves to a stale IP | Risolve a un IP vecchio | Cache: TTL de 30s por defecto | Cache: 30s TTL by default | Cache: TTL di 30s di default |
CoreDNS Pending es CNI
CoreDNS Pending means CNI
CoreDNS Pending significa CNI
Si los pods de CoreDNS están en Pending o ContainerCreating recién instalado el cluster, no es un problema de DNS: es que falta el CNI (M7/M10). Arreglá eso y el DNS aparece solo.
If the CoreDNS pods are Pending or ContainerCreating on a freshly installed cluster, it is not a DNS problem: the CNI is missing (M7/M10). Fix that and DNS shows up on its own.
Se i pod di CoreDNS sono in Pending o ContainerCreating su un cluster appena installato, non è un problema di DNS: manca il CNI (M7/M10). Sistemalo e il DNS compare da solo.
★
nslookup kubernetes.default es tu canario: ese Service existe en todos los clusters, siempre. Si eso no resuelve, el problema es el DNS mismo y no el servicio que estabas buscando. Un comando, cero ambigüedad.
nslookup kubernetes.default is your canary: that Service exists in every cluster, always. If that does not resolve, the problem is DNS itself and not the service you were after. One command, zero ambiguity.
nslookup kubernetes.default è il tuo canarino: quel Service esiste in ogni cluster, sempre. Se quello non risolve, il problema è il DNS stesso e non il servizio che cercavi. Un comando, zero ambiguità.