Kubernetes Commands Cheat Sheet
Kubernetes Cluster Commands
kubectl cluster-info
-> Display cluster information.
kubectl get nodes -o wide
-> List all nodes in the cluster and show their IPs.
Kubernetes Pod Commands
kubectl get pods
-> List all pods.
kubectl get pods -o wide
-> Show detailed information about pods.
kubectl get pods -l <label>=<value>
-> List pods with a specific label.
kubectl get pod <name>
-> Show a specific pod.
kubectl describe pod <name>
-> Show pod's detailed information.
kubectl logs <pod>
-> View logs of a pod.
kubectl exec -it <pod> -- bash
-> Execute a command inside the pod.
kubectl delete pod <pod>
-> Delete a pod.
kubectl explain pod
-> Display a detailed overview of the Pod resource.
Kubernetes Deployment Commands
kubectl create deployment <name> --image=<image>
-> Create a deployment.
kubectl get deployments
-> List all deployments.
kubectl describe deployment <name>
-> Show details of a deployment.
kubectl scale deployment <name> --replicas=<number>
-> Scale replicas.
kubectl rollout restart deployment/<name>
-> Restart a deployment.
kubectl rollout status deployment/<name>
-> View rollout status.
kubectl create deployment <name> --image=<image> -o yaml
-> Create and output YAML.
kubectl create deployment <name> --image=<image> --dry-run=client
-> Create without applying.
kubectl create deployment <name> --image=<image> -o yaml --dry-run=client > name.yaml
-> Generate YAML and save.
Kubernetes Service Commands
Kubernetes Commands Cheat Sheet
kubectl get services
-> List all services.
kubectl describe service <name>
-> Show service details.
kubectl expose pod <name>
-> Expose a pod as a service.
kubectl delete service <name>
-> Delete a service.
kubectl port-forward <pod> <local-port>:<remote-port>
-> Forward a local port.
Kubernetes ConfigMap & Secret Commands
kubectl create configmap <name> --from-literal=<key>=<value>
-> Create a ConfigMap.
kubectl create secret generic <name> --from-literal=<key>=<value>
-> Create a Secret.
kubectl get configmaps
-> List all ConfigMaps.
kubectl get secrets
-> List all Secrets.
kubectl describe configmap <name>
-> Show ConfigMap details.
Kubernetes Namespace Commands
kubectl get namespaces
-> List all namespaces.
kubectl create namespace <name>
-> Create a namespace.
kubectl delete namespace <name>
-> Delete a namespace.
kubectl config set-context --current --namespace=<name>
-> Switch to a different namespace.
Kubernetes Resource Commands
kubectl apply -f <file>
-> Apply resources from a file.
kubectl edit <type> <name>
-> Edit a resource.
kubectl delete -f <file>
-> Delete a resource.
kubectl get <type>
-> List resources of a type.
kubectl describe <type> <name>
-> Show details of a resource.
Kubernetes Statistics & Event Commands
kubectl top nodes
Kubernetes Commands Cheat Sheet
-> Display node resource usage.
kubectl top pods
-> Display pod resource usage.
kubectl events
-> Show recent cluster events.
kubectl get events
-> List all events.
Kubernetes Permissions
kubectl get roles
-> List all roles.