Commands for performing basic Kubernetes cluster troubleshooting.
Use one of the following commands to retrieve pod-related logs:
ncn-mw# kubectl logs POD_NAME
ncn-mw# kubectl logs POD_NAME -c CONTAINER_NAME
If the pods keeps crashing, open a log for the previous instance using the following command:
ncn-mw# kubectl logs -p POD_NAME
Use the following command to retrieve information about a node’s condition, such as OutOfDisk
, MemoryPressure
, DiskPressure
, etc.
ncn-mw# kubectl describe node NODE_NAME
Use the following command to retrieve information that can help debug pod-related errors.
ncn-mw# kubectl describe pod POD_NAME
Use the following command to list all of the containers in a pod, as shown in the following example:
ncn-mw# kubectl describe pod/cray-tftp-6f85767d76-b28gc -n default
Use the following command to connect to a pod:
ncn-mw# kubectl exec -it POD_NAME -c CONTAINER_NAME /bin/sh
Use the following command to execute a command inside a pod:
ncn-mw# kubectl exec POD_NAME ls /
Use the following command to connect to a currently running container:
ncn-mw# kubectl attach POD_NAME -i
Use the deployment command to scale a deployment up or down, as shown in the following examples:
ncn-mw# kubectl scale deployment APPLICATION_NAME --replicas=0
ncn-mw# kubectl scale deployment APPLICATION_NAME --replicas=3
Use the following command to remove components of the deployment’s manifest, such as services, network policies, and more:
ncn-mw# kubectl delete –f APPLICATION_NAME.yaml
Use the following command to reapply the deployment:
ncn-mw# kubectl apply –f APPLICATION_NAME.yaml
Pods can be configured to restart after getting deleted. Use the following command to delete a pod:
ncn-mw# kubectl delete pod POD_NAME
CAUTION: It is recommended to be careful while deleting deployments or pods, because doing so can have an effect on other pods.