Get logs of the previous container

Logs from the container that crashed or restarted last time; the real error is usually here

kubectl logs <pod> --previous -n <ns>

tool
kubectl73 commands
tags
logsdebug

More kubectl commands

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

    Starts an interactive bash shell in a running container

  • 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

all 73 kubectl commands