Challenge 3
Use the following command to break something in the cluster
curl -s https://learn.exoscale.dev/cka/ch/set3.sh | bashIt seems not possible to reach any services in the cluster. Understand the problem is and fix it.
Solution
- Test
Let’s create a new Pod and expose it with a ClusterIP Service
kubectl run nginx --image=nginx:1.20 --port 80 --exposeLet’s new get an interactive shell in an Alpine based Pod
kubectl run -ti --rm debug --image=alpine -- shWe cannot reach the nginx Pod from the debug one:
/ # wget http://nginx
wget: bad address 'nginx'Going one step further we can see the name resolution is not working fine:
/ # nslookup nginx
;; connection timed out; no servers could be reached- Checking the cluster’s internal DNS
kubectl get deploy -n kube-system
NAME READY UP-TO-DATE AVAILABLE AGE
coredns 0/0 0 0 2d17hSeems like there is no replica running for the dns (should be 2 by default)
- Fixing the thing
Let’s increase the number of replicas to 2
kubectl -n kube-system scale deploy/coredns --replicas=2- Verification
The name resolution is now working:
Server: 10.96.0.10
Address: 10.96.0.10:53
Name: nginx.default.svc.cluster.local
Address: 10.96.188.129
...From a new debug Pod the nginx Pod can be reached:
/ # wget -O- nginx
Connecting to nginx (10.96.188.129:80)
writing to stdout
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>