Diagnostics and port-forwardingKubernetes
kubectl exec
Run commands within containerized workloads.
Command
kubectl exec -it -- /bin/sh
Example usage
Open interactive shells or run single commands inside pods.
kubectl exec -it <pod> -- /bin/sh
kubectl exec <pod> -- env
Related tags
Diagnostics and port-forwardingk8skubectlclusters