Debugging Kubernetes

Sometimes the easiest way to understand what is happening in Kubernetes is just to have a pod that runs Linux … a general Linux … Ubuntu will do nicely.

A big shout out to Tim Downey for this article ( that lets you create a pod which you can exec and then just add the tools you need to to figure out what is going on from the inside of your cluster when it doesn't make sense from the outside.
Paraphrasing the approach in

Create a file called debug.yml containing:
apiVersion: v1
kind: Pod
name: ubuntu
app: ubuntu
- image: ubuntu
- "sleep"
- "604800"
imagePullPolicy: IfNotPresent
name: ubuntu
restartPolicy: Always

Use the command kubectl apply -f debug.yaml to start your pod.

Use the command kubectl exec -it ubuntu -- /bin/bash to get a command line in your pod.

Some useful things to add:

  • ping: apt install iputils-ping
  • host: apt install dnsutils
  • telnet: apt install telnet

And once you have one of these running you can debug all sorts of things including external endpoints with their services:

root@ubuntu:/# host atum-ra-http
atum-ra-http.default.svc.cluster.local has address
root@ubuntu:/# telnet atum-ra-http 80
Connected to atum-ra-http.default.svc.cluster.local.
Escape character is '^]'.

and see what actually comes back (or not when your declarative configuration file leads to unexpected results but parses perfectly).