Executing into k8s pod (kubernetes)

Today I am going to save here this command. It’s very simple although I cannot remember it!

kubectl exec --stdin --tty pod-name-xxz -- /bin/bash

15/10/2021 – UDPATE
Because I was lazy to remember it, I wrote bash function which does most of the job instead of me. It takes one argument which is pod name and I stored in my .bashrc so it’s available everythere together with my bash.

kex () {
    kubectl exec --stdin --tty $1 -- /bin/bash
}

Links:
https://kubernetes.io/docs/tasks/debug-application-cluster/get-shell-running-container/