1️⃣ Cluster Commands
| Command | Description |
|---|---|
kubectl cluster-info | Displays cluster information |
kubectl get nodes -o wide | Lists all nodes with additional details |
2️⃣ Pod Commands
| Command | Description |
|---|---|
kubectl get pods | Lists all pods |
kubectl get pods -o wide | Shows pods with additional details |
kubectl get pods -l <label>=<value> | Lists pods with a specific label |
kubectl get pod <name> | Shows information about a specific pod |
kubectl describe pod <name> | Displays detailed pod information |
kubectl logs <pod> | Shows pod logs |
kubectl exec -it <pod> | Executes a command inside a pod |
kubectl delete pod <pod> | Deletes a pod |
kubectl explain pod <resource> | Displays pod resource documentation |
3️⃣ Deployment Commands
| Command | Description |
|---|---|
kubectl create deployment <name> --image=<image> | Creates a deployment |
kubectl get deployments | Lists all deployments |
kubectl describe deployment <name> | Shows deployment details |
kubectl scale deployment <name> --replicas=<number> | Scales deployment replicas |
kubectl rollout restart deployment/<name> | Restarts a deployment |
kubectl rollout status deployment/<name> | Shows rollout status |
4️⃣ Service Commands
| Command | Description |
|---|---|
kubectl get services | Lists all services |
kubectl describe service <name> | Shows service details |
kubectl expose pod <name> | Exposes a pod as a service |
kubectl delete service <name> | Deletes a service |
kubectl port-forward <pod> <local-port>:<remote-port> | Forwards local port to a pod |
5️⃣ ConfigMap & Secret Commands
| Command | Description |
|---|---|
kubectl create configmap <name> --from-literal=<key>=<value> | Creates a ConfigMap |
kubectl create secret generic <name> --from-literal=<key>=<value> | Creates a Secret |
kubectl get configmaps | Lists all ConfigMaps |
kubectl get secrets | Lists all Secrets |
kubectl describe configmap <name> | Shows ConfigMap details |
6️⃣ Namespace Commands
| Command | Description |
|---|---|
kubectl get namespaces | Lists all namespaces |
kubectl create namespace <name> | Creates a namespace |
kubectl delete namespace <name> | Deletes a namespace |
kubectl config set-context --current --namespace=<name> | Switches namespace |
7️⃣ Resource Commands
| Command | Description |
|---|---|
kubectl apply -f <file> | Applies a configuration file |
kubectl edit <type> <name> | Edits a resource |
kubectl delete -f <file> | Deletes resources from a file |
kubectl get <type> | Lists resources of a type |
kubectl describe <type> <name> | Shows resource details |
8️⃣ Statistics & Events Commands
| Command | Description |
|---|---|
kubectl top nodes | Shows node resource usage |
kubectl top pods | Shows pod resource usage |
kubectl events | Shows cluster events |
kubectl get events | Lists cluster events |
9️⃣ Permission Commands
| Command | Description |
|---|---|
kubectl get roles | Lists roles in the namespace |