How to run curl in Kubernetes

Why curl in K8S

  • for troubleshooting
  • diagnose an issue with your app in Kubernetes.

Small Container Image for curl

Note: busybox - Official Image base image not include curl

How to use curl image

Create a new Temporary Pod (curlImages)

  • Initial curl image with iterative shell
#Intial curl image with iteratve shell
kubectl run pingkungcurl1--image=curlimages/curl -i --tty -- sh

/ $ curl http://sample-svc.testapi
{"message":"pingkung_a123"}
  • curl with internal IP
#curl with internal ip
kubectl run --rm -it --tty pingkungcurl1 --image=curlimages/curl --restart=Never -- 10.244.69.251:5001
  • curl with k8s service (Pattern service.namespace)
#curl with service
kubectl run --rm -it --tty pingkungcurl1 --image=curlimages/curl --restart=Never -- dbpub-svc-svc.dbzone:5001

Discover more from naiwaen@DebuggingSoft

Subscribe to get the latest posts sent to your email.