Troubleshoot DNS

  • vi dns.yml
 1apiVersion: v1
 2kind: Pod
 3metadata:
 4  name: dnsutils
 5  namespace: default
 6spec:
 7  containers:
 8  - name: dnsutils
 9    image: registry.k8s.io/e2e-test-images/jessie-dnsutils:1.3
10    command:
11      - sleep
12      - "infinity"
13    imagePullPolicy: IfNotPresent
14  restartPolicy: Always
  • deploy dnsutils
1k apply -f dns.yml
2pod/dnsutils created
3
4kubectl get pods dnsutils
5NAME       READY   STATUS    RESTARTS   AGE
6dnsutils   1/1     Running   0          36s
  • Troubleshoot with dnsutils
 1kubectl exec -i -t dnsutils -- nslookup kubernetes.default
 2;; connection timed out; no servers could be reached
 3command terminated with exit code 1
 4
 5kubectl exec -ti dnsutils -- cat /etc/resolv.conf
 6search default.svc.cluster.local svc.cluster.local cluster.local psflab.local
 7nameserver 10.43.0.10
 8options ndots:5
 9
10kubectl get endpoints kube-dns --namespace=kube-system
11NAME       ENDPOINTS                                  AGE
12kube-dns   10.42.0.6:53,10.42.0.6:53,10.42.0.6:9153   5d1h
13
14kubectl get svc kube-dns --namespace=kube-system
15NAME       TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)                  AGE
16kube-dns   ClusterIP   10.43.0.10   <none>        53/UDP,53/TCP,9153/TCP   5d1h

CURL

 1cat << EOF > curl.yml 
 2apiVersion: v1
 3kind: Pod
 4metadata:
 5  name: curl
 6  namespace: default
 7spec:
 8  containers:
 9  - name: curl
10    image: curlimages/curl
11    command:
12      - sleep
13      - "infinity"
14    imagePullPolicy: IfNotPresent
15  restartPolicy: Always
16EOF
17
18k apply -f curl.yml 
19 
20#Test du DNS
21kubectl exec -i -t curl -- curl -v telnet://10.43.0.10:53
22kubectl exec -i -t curl -- curl -v telnet://kube-dns.kube-system.svc.cluster.local:53
23kubectl exec -i -t curl -- nslookup kube-dns.kube-system.svc.cluster.local
24
25curl -k -I --resolve subdomain.domain.com:52.165.230.62 https:/subdomain.domain.com/