Open a shell in a pod

Starts an interactive bash shell in a running container

kubectl exec -it <pod> -n <ns> -- bash

tool
kubectl73 commands
tags
podsdebug

More kubectl commands

  • kubectl port-forward svc/<name> 8080:80 -n <ns>

    Forwards a service port from the cluster to localhost:8080

  • kubectl rollout status deployment/<name> -n <ns>

    Waits until the rollout finishes or fails; useful in CI

  • kubectl rollout undo deployment/<name> -n <ns>

    Returns the deployment to the previous revision

  • kubectl scale deployment/<name> --replicas=3 -n <ns>

    Changes the number of replicas right away

  • kubectl get events -A --sort-by='.lastTimestamp'

    Recent cluster events, oldest first; handy for a post-incident review

all 73 kubectl commands