Reputation: 7966
I would like to sh myself inside a kubernetes pod and execute a CURL command. Unfortunatly I can't find anywhere a working image with curl availble (and compatible with kubernetes)...
To exec into a container I'm doing a simple kubectl exec -it POD_ID /bin/bash
Does someone knows of a minimal docker image that contains a CURL binary and wont crash in kubernetes ?
PS: This is for testing purpose so it does not need to be rock solid or anything
Thx
UPDATE 1 This is the yaml I use to deploy all potential image :
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: blue
namespace: default
spec:
replicas: 1
template:
metadata:
labels:
name: blue
spec:
containers:
- name: blue-website
image: SOME_IMAGE:latest
resources:
requests:
cpu: 0.1
memory: 200
I don't think that its broken because it works on certain image.
Upvotes: 8
Views: 17821
Reputation: 2268
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
).
Upvotes: 21
Reputation: 1548
Use byrnedo/alpine-curl
image from https://hub.docker.com/r/byrnedo/alpine-curl/.
Also it's not neccessary to have latest
tag in the deployment. It works without it, just
containers:
- name: blue-website
image: byrnedo/alpine-curl
Upvotes: 3
Reputation: 5528
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/v1beta1
kind: Deployment
metadata:
name: blue
namespace: default
spec:
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
Upvotes: 4
Reputation: 4654
You can use this image nightfury1204/alpine-curl
I created above image for my own testing purpose.
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: curl
labels:
name: curl
spec:
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
Upvotes: 5