How to use pods for debugging?
How to test network connectivity within the cluster?
If you want to check if a service or a pod can be reached from another pod in the cluster, you can create a separate pod with curl
, then check if it can reach the destination.
$ kubectl run curl --image=radial/busyboxplus:curl -i --tty --rm
If you don't see a command prompt, try pressing enter.
[ root@curl:/ ]$ curl -k https://10.200.xxx.xxx:10443
How to create pods in the cluster for debugging?
Start a pod with alpline Linux:
$ kubectl run -i --tty --rm debug --image=alpine --restart=Never -- sh
Start an interactive shell in busybox pod in your namespace; dies on exit.
$ kubectl run -i --tty busybox --image=busybox --restart=Never -- sh
Start a pod with nginx:
$ kubectl run nginx --image=nginx --port=80
$ kubectl expose pod nginx --port=80 --type=LoadBalancer
$ kubectl expose pod nginx --port=80 --type=NodePort
Start a pod Ubuntu and use curl
from the pod. (Useful for testing network connectivity from within the cluster.)
$ kubectl run -it ubuntu --image=ubuntu -- /bin/bash
# inside the pod:
> apt update && apt install curl
> curl xx.xx.xx.xx