Pods¶

List Running Pods¶

kubectl get pods -A


Kubernetes lets you divide your cluster into namespaces. Each namespace can have its own set of resources. The above command lists all running pods on every cluster. Pods in the kube-system namespace belong to Kubernetes and helps it function.

Describe Pods¶

kubectl describe pods <podname>


“SSH”¶

To connect to the application look at the namespaces:

kubectl get pods -A
kubectl exec -it -n <namespace> <pod> -c <container> -- bash


Logs¶

kubectl get pods -A
kubectl logs -f -n <namespace> <pod> -c <container>


This lets you view the logs of the running pod. The container running on the pod should be configured to output logs to STDOUT/STDERR.

Restart a Pod¶

If you pod is not responding or needs a restart the way to do it is to use the following command. This will delete the pod and replace it with a new pod if it is a part of a deployment.

kubectl delete pod <pod-name>


Troubleshooting¶

A pod can have various different errors. The common ones are:

• OOMError: The pod or underlying node ran out of memory and killed the pod.

• CrashLoopBackup: The application itself has an issue, use kubectl logs -f <pod> to find out why

• ImageNotFound: The docker image for the pod can’t be found.