Difference between revisions of "Kubectl exec"
Jump to navigation
Jump to search
Tags: Mobile web edit, Mobile edit |
|||
(41 intermediate revisions by 8 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{lowercase}} | ||
+ | kubectl [[exec]] | ||
+ | [[kubectl exec --stdin --tty]] | ||
+ | [[kubectl exec -it]] | ||
+ | [[kubectl exec --help]] | ||
− | |||
+ | [[kubectl exec -it myalpine -- /bin/sh]] | ||
+ | [[kubectl exec myalpine -- df -kh]] | ||
+ | kubectl exec -it ubuntu -- bash | ||
+ | [[Error from server (NotFound)]]: pods "ubuntu" [[not found]] | ||
− | == Related | + | kubectl exec [[--tty]] -i redis-client --namespace default [[--]] [[bash]] |
+ | |||
+ | https://kubernetes.io/docs/tasks/debug/debug-application/get-shell-running-container/ | ||
+ | * <code>[[kubectl]] exec -it my-redis-pod -- /bin/bash</code> (Get a shell to a running container (https://kubernetes.io/docs/tasks/debug-application-cluster/get-shell-running-container/)) | ||
+ | |||
+ | * <code>[[kubectl]] exec -it my-redis-pod [[-c]] my-redis-container -- /bin/bash</code> | ||
+ | |||
+ | kubectl -n your_namespace exec your-pod-name1 -- bash | ||
+ | |||
+ | [[kubectl exec -it]] -c your-pod-name-3 bash | ||
+ | [[error: you must specify at least one command for the container]] | ||
+ | |||
+ | [[Error: unable to upgrade connection: container not found]] | ||
+ | |||
+ | [[Error from server]] ([[NotFound]]): pods "your-pod-name" [[not found]] | ||
+ | |||
+ | |||
+ | kubectl exec my-redis-pod -c my-redis-container /sbin/killall5 | ||
+ | kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead. | ||
+ | command terminated with exit code 2 | ||
+ | |||
+ | kubectl exec my-redis-pod -c my-redis-container /sbin/killall | ||
+ | kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead. | ||
+ | OCI runtime exec failed: exec failed: container_linux.go:367: starting container process caused: exec: "/sbin/killall": stat | ||
+ | /sbin/killall: no such file or directory: unknown | ||
+ | command terminated with exit code 126 | ||
+ | |||
+ | [[kubectl exec]] envar-demo -- [[printenv]] | ||
+ | |||
+ | kubectl exec -it your-container-name -- [[bash]] | ||
+ | Defaulted container "yourapp-[[rabbitmq]]" out of: yourapp-rabbitmq, yourapp-rabbitmq-metrics | ||
+ | |||
+ | == Related == | ||
* <code>[[docker exec]]</code> | * <code>[[docker exec]]</code> | ||
+ | * <code>[[podman exec]]</code> | ||
+ | * <code>[[crictl exec]]</code> | ||
* <code>[[kubectl logs]]</code> | * <code>[[kubectl logs]]</code> | ||
+ | * <code>[[kubectl get pods]]</code> | ||
+ | * <code>[[kubectl attach]]</code> | ||
+ | * <code>[[kubectl debug]]</code> | ||
+ | * <code>[[sh]], [[ash]], [[bash]]</code> | ||
+ | * <code>[[kubectl run]]</code>: <code>[[kubectl run ubuntu --image=ubuntu]]</code> | ||
+ | * [[Amazon ECS Exec Checker]] | ||
== Activities == | == Activities == | ||
− | * [[Get a shell to a running container]] | + | * [[Get a shell to a running container]]: <code>[[kubectl exec -it]]</code> |
== See also == | == See also == | ||
− | * {{kubectl}} | + | * {{kubectl exec}} |
− | * {{K8s}} | + | * {{K8s tr}} |
+ | |||
[[Category:Kubernetes]] | [[Category:Kubernetes]] | ||
[[Category:CKAD]] | [[Category:CKAD]] |
Latest revision as of 11:24, 25 October 2023
kubectl exec kubectl exec --stdin --tty kubectl exec -it kubectl exec --help
kubectl exec -it myalpine -- /bin/sh kubectl exec myalpine -- df -kh
kubectl exec -it ubuntu -- bash Error from server (NotFound): pods "ubuntu" not found
kubectl exec --tty -i redis-client --namespace default -- bash
https://kubernetes.io/docs/tasks/debug/debug-application/get-shell-running-container/
kubectl exec -it my-redis-pod -- /bin/bash
(Get a shell to a running container (https://kubernetes.io/docs/tasks/debug-application-cluster/get-shell-running-container/))
kubectl -n your_namespace exec your-pod-name1 -- bash
kubectl exec -it -c your-pod-name-3 bash error: you must specify at least one command for the container
Error: unable to upgrade connection: container not found
Error from server (NotFound): pods "your-pod-name" not found
kubectl exec my-redis-pod -c my-redis-container /sbin/killall5 kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead. command terminated with exit code 2
kubectl exec my-redis-pod -c my-redis-container /sbin/killall kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead. OCI runtime exec failed: exec failed: container_linux.go:367: starting container process caused: exec: "/sbin/killall": stat /sbin/killall: no such file or directory: unknown command terminated with exit code 126
kubectl exec envar-demo -- printenv
kubectl exec -it your-container-name -- bash Defaulted container "yourapp-rabbitmq" out of: yourapp-rabbitmq, yourapp-rabbitmq-metrics
Related[edit]
docker exec
podman exec
crictl exec
kubectl logs
kubectl get pods
kubectl attach
kubectl debug
sh, ash, bash
kubectl run
:kubectl run ubuntu --image=ubuntu
- Amazon ECS Exec Checker
Activities[edit]
See also[edit]
kubectl exec, kubectl exec -it
- K8s troubleshooting:
kubectl logs, kubectl top, kubectl get events -A, kubectl describe pod
, Liveness, Readiness,Kubernetes events
, Pulling image, OOMKilled, ProbeWarning, Reason,FailedScheduling
,errImagePull, ImagePullBackOff
, Kubelet conditions:MemoryPressure, DiskPressure, KubeletHasSufficientPID, KubeletReady, kubectl [ debug | attach | exec ] kubectl cluster-info dump, SimKube, KWOK
Advertising: