kubectl exec
command
Syntax
kubectl exec <pod-name> [-c container] -- <command> [args]
Parameters
| Parameters | Description | Examples | Level |
|---|---|---|---|
-it |
( TTY) | kubectl exec -it web-pod -- /bin/bash |
Common |
-c --container |
( Pod) | kubectl exec -it web-pod -c sidecar -- sh |
Common |
-n --namespace |
kubectl exec -it web-pod -n production -- sh |
Common |
Examples
Shell
kubectl exec -it web-app-6f7b8c9d-k2m4n -- /bin/bash
bash /bin/sh
command
kubectl exec web-pod -- cat /etc/config/app.conf
-it
kubectl exec web-pod -- env
kubectl exec web-pod -- curl -s http://backend-svc:8080/health
Pod
Common Errors
OCI runtime exec failed: exec failed: unable to start container processcommand, /bin/sh /bin/bash
container not runningRunning, Pod
Tips
- -- command,
- Alpine sh bash
- exec,