Need a CURL binary availble inside kubernetes pod
You can skip the manifest and use kubectl run
to spin up one of these pods on demand.i.e.
kubectl run curl -it --rm --image=curlimages/curl -- sh
This would create a deployment named curl
from the curlimages/curl
image and give you an interactive (-it
) shell inside it. When you exit, the deployment will be deleted (--rm
).
You can use this image nightfury1204/alpine-curl
I created above image for my own testing purpose.
apiVersion: apps/v1kind: StatefulSetmetadata: name: curl labels: name: curlspec: serviceName: "curl" selector: matchLabels: app: curl replicas: 1 template: metadata: labels: app: curl spec: containers: - name: curl image: nightfury1204/alpine-curl command: - "sh" - "-c" - > while true; do sleep 3600; done
To exec into the pod use this kubectl exec -it curl-0 sh
You getting CrashLoopBackOff
because container completes after starting as it does not have any task to process. Easy workaround is to run a command in the container to keep it running indefinitely. So that you can exec into the container and run curl.
Here, is modified yaml to do this:
apiVersion: apps/v1beta1kind: Deploymentmetadata: name: blue namespace: defaultspec: replicas: 1 template: metadata: labels: name: blue spec: containers: - name: blue-website image: scrapinghub/httpbin:latest command: - sleep - "3600" resources: requests: cpu: 0.1 memory: 200