|
56 | 56 |
|
57 | 57 | INFO "GET PODS" |
58 | 58 | kubectl get pods |
| 59 | + kubectl get pods -n kube-system |
59 | 60 | INFO "DESCRIBE PODS" |
60 | 61 | kubectl describe pods |
61 | 62 | for name in $(kubectl get pods -o json | jq -r .items[].metadata.name) |
62 | 63 | do |
63 | 64 | kubectl logs $name |
| 65 | + kubectl exec -it $name -- cat /etc/resolv.conf |
64 | 66 | done |
65 | 67 |
|
| 68 | + INFO "Patching CoreDNS to use 8.8.8.8" |
| 69 | + kubectl get configmap coredns -n kube-system -o yaml | \ |
| 70 | + sed 's/forward . \/etc\/resolv.conf/forward . 8.8.8.8/' | \ |
| 71 | + kubectl apply -f - |
| 72 | + |
| 73 | + INFO "Restarting CoreDNS" |
| 74 | + kubectl delete pod -n kube-system -l k8s-app=kube-dns |
| 75 | + kubectl rollout status deployment coredns -n kube-system |
| 76 | + |
66 | 77 | INFO "Connecting to dnstest-{0,1,2}.dnstest.default.svc.cluster.local" |
67 | | - kubectl run -i --rm --image=alpine --restart=Never dnstest-shell -- sh -exc 'for f in $(seq 0 2); do wget -O- http://dnstest-${f}.dnstest.default.svc.cluster.local; done' |
| 78 | +# kubectl run -i --rm --image=alpine --restart=Never dnstest-shell -- sh -exc 'for f in $(seq 0 2); do wget -O- http://dnstest-${f}.dnstest.default.svc.cluster.local; done' |
| 79 | +# kubectl run -i --rm --image=debian:bookworm-slim --restart=Never dnstest-shell -- sh -exc ' |
| 80 | +# apt-get update && apt-get install -y wget; |
| 81 | +# for f in $(seq 0 2); do |
| 82 | +# wget -O- http://dnstest-${f}.dnstest.default.svc.cluster.local; |
| 83 | +# done' |
| 84 | + |
| 85 | + COREDNS_IP=$(kubectl get pod -n kube-system -l k8s-app=kube-dns -o jsonpath='{.items[0].status.podIP}') |
| 86 | + INFO "CoreDNS Pod IP is: $COREDNS_IP" |
| 87 | + kubectl run -i --rm --image=busybox:1.28 --restart=Never dns-test -- nslookup google.com $COREDNS_IP |
| 88 | + |
| 89 | + INFO "Connecting to dnstest-{0,1,2}.dnstest.default.svc.cluster.local" |
| 90 | + kubectl run -i --rm --image=busybox:1.28 --restart=Never dnstest-shell -- sh -exc ' |
| 91 | + echo "--- Resolv.conf ---" |
| 92 | + cat /etc/resolv.conf |
| 93 | + |
| 94 | + echo "--- Testing External DNS (google.com) ---" |
| 95 | + nslookup google.com || echo "External DNS Failed" |
| 96 | +
|
| 97 | + echo "--- Testing Internal DNS (dnstest-0) ---" |
| 98 | + nslookup dnstest-0.dnstest || echo "Internal DNS Failed" |
68 | 99 |
|
| 100 | + for f in 0 1 2; do |
| 101 | + wget -qO- http://dnstest-${f}.dnstest.default.svc.cluster.local |
| 102 | + done' |
69 | 103 | INFO "Deleting Service \"dnstest\"" |
70 | 104 | kubectl delete service dnstest |
71 | 105 | INFO "Deleting StatefulSet \"dnstest\"" |
|
0 commit comments