Kubernetes Complete Command Cheat Sheet
Category Command Description
Namespaces kubectl get namespaces Displays all available namespaces in the cluster
Namespaces kubectl create namespace <name> Creates a new namespace
Namespaces kubectl delete namespace <name> Deletes a specified namespace
Pods kubectl get pods Lists all pods in the current namespace
Pods kubectl get pods -n <namespace> Lists all pods in a specified namespace
Pods kubectl describe pod <pod-name> Displays detailed information about a specific pod
Pods kubectl delete pod <pod-name> Deletes a specified pod
Deployments kubectl get deployments Lists all deployments in the current namespace
Deployments kubectl create deployment <name> --image=<image>
Creates a new deployment with the specified image
Deployments kubectl scale deployment <name> --replicas=<count>
Scales a deployment to the desired number of repli
Deployments kubectl rollout status deployment/<name> Monitors the rollout status of a deployment
Deployments kubectl rollout undo deployment/<name> Rolls back the last deployment
Deployments kubectl delete deployment <name> Deletes a specified deployment
Services kubectl get services Lists all services in the current namespace
Services kubectl expose deployment <name> --port=<port>
Exposes
--target-port=<target>
a deployment as a service
Services kubectl delete service <service-name> Deletes a specified service
Logs kubectl logs <pod-name> Displays logs of a specified pod
Logs kubectl logs <pod-name> -c <container-name> Displays logs of a specific container in a pod
Exec kubectl exec -it <pod-name> -- /bin/bash Accesses the shell of a running pod
Config kubectl config get-contexts Lists all kubeconfig contexts
Config kubectl config use-context <context-name> Switches to a specified context
Config kubectl config current-context Displays the current context
Apply kubectl apply -f <file>.yaml Applies configuration changes defined in a YAML fi
Delete kubectl delete -f <file>.yaml Deletes resources defined in a YAML file
Cluster Info kubectl cluster-info Displays the cluster master and services informatio
Nodes kubectl get nodes Lists all nodes in the cluster
Nodes kubectl describe node <node-name> Displays detailed info about a specific node
Resource Usage kubectl top nodes Shows CPU and memory usage for nodes
Resource Usage kubectl top pods Shows CPU and memory usage for pods
Secrets kubectl get secrets Lists all secrets
Secrets kubectl create secret generic <name> --from-literal=<key>=<value>
Creates a generic secret
ConfigMaps kubectl get configmaps Lists all ConfigMaps
ConfigMaps kubectl create configmap <name> --from-literal=<key>=<value>
Creates a ConfigMap from literal values
Persistent Volumes kubectl get pv Lists all Persistent Volumes
Persistent Volumes kubectl get pvc Lists all Persistent Volume Claims
Jobs kubectl get jobs Lists all jobs
CronJobs kubectl get cronjobs Lists all cron jobs
YAML kubectl explain <resource> Provides documentation for a resource type