Kubernetes (kubectl) Cheatsheet

Essential Kubectl Commands

Cluster Info

  • kubectl cluster-info: Display information about the cluster.
  • kubectl get nodes: List all nodes in the cluster.

Deployments

  • kubectl get deployments: List deployments.
  • kubectl describe deployment <name>: View details of a deployment.
  • kubectl apply -f <filename.yaml>: Create or update a resource from a file.
  • kubectl delete -f <filename.yaml>: Delete a resource from a file.

Pods

  • kubectl get pods: List all pods in the current namespace.
  • kubectl logs <pod-name>: Print the logs for a pod.
  • kubectl exec -it <pod-name> -- /bin/sh: Execute a command in a container.