Useful Kubectl Commands

Categories: cheatsheet

Here are some common kubectl commands that I find myself using.

get namespaces

kubectl get ns

get deployments

kubectl -n NAMESPACE get pods

get pods

kubectl -n NAMESPACE get pods 

logs

The below command will returns logs for multiple container with the label

kubectl -n NAMESPACE logs -c CONTAINER_NAME -l app=LABEL_VALUE -f

describe pod

kubectl -n NAMESPACE describe pod POD_NAME

ssh to pod

kubectl -n NAMESPACE exec -it POD_NAME bash