kubectl cluster-info | Display cluster info |
kubectl config view | Show kubeconfig settings |
kubectl config current-context | Display current context |
kubectl config get-contexts | List all contexts |
kubectl config use-context <name> | Switch to context |
kubectl config set-context --current --namespace=<ns> | Set default namespace |
kubectl api-resources | List all resource types |
kubectl api-versions | List API versions |
kubectl get nodes | List all nodes |
kubectl get nodes -o wide | List nodes with details |
kubectl describe node <name> | Show node details |
kubectl top nodes | Show node resource usage |
kubectl cordon <node> | Mark node as unschedulable |
kubectl uncordon <node> | Mark node as schedulable |
kubectl drain <node> | Drain node for maintenance |
kubectl get pods | List pods in current namespace |
kubectl get pods -A | List pods in all namespaces |
kubectl get pods -o wide | List pods with more details |
kubectl get pods -w | Watch pods in real-time |
kubectl get pods -l app=<label> | List pods by label |
kubectl describe pod <name> | Show pod details |
kubectl delete pod <name> | Delete a pod |
kubectl delete pod <name> --force | Force delete pod |
kubectl logs <pod> | View pod logs |
kubectl logs <pod> -c <container> | View container logs |
kubectl logs <pod> -f | Stream pod logs |
kubectl logs <pod> --previous | View previous container logs |
kubectl logs <pod> --tail=100 | View last 100 lines |
kubectl exec -it <pod> -- /bin/sh | Open shell in pod |
kubectl exec <pod> -- <command> | Run command in pod |
kubectl top pods | Show pod resource usage |
kubectl port-forward <pod> 8080:80 | Forward local port to pod |
kubectl run <name> --image=<image> | Create pod from image |
kubectl run <name> --image=<image> --dry-run=client -o yaml | Generate pod YAML |
kubectl cp <pod>:/path /local/path | Copy from pod to local |
kubectl cp /local/path <pod>:/path | Copy from local to pod |
kubectl attach <pod> -i | Attach to running container |
kubectl get deployments | List deployments |
kubectl describe deployment <name> | Show deployment details |
kubectl create deployment <name> --image=<image> | Create deployment |
kubectl delete deployment <name> | Delete deployment |
kubectl edit deployment <name> | Edit deployment in editor |
kubectl scale deployment <name> --replicas=3 | Scale deployment |
kubectl autoscale deployment <name> --min=2 --max=10 | Set autoscaling |
kubectl set image deployment/<name> <container>=<image> | Update container image |
kubectl rollout status deployment/<name> | Check rollout status |
kubectl rollout history deployment/<name> | View rollout history |
kubectl rollout undo deployment/<name> | Rollback to previous |
kubectl rollout undo deployment/<name> --to-revision=2 | Rollback to specific revision |
kubectl rollout restart deployment/<name> | Restart deployment |
kubectl rollout pause deployment/<name> | Pause rollout |
kubectl rollout resume deployment/<name> | Resume rollout |
kubectl get replicasets | List ReplicaSets |
kubectl describe rs <name> | Show ReplicaSet details |
kubectl get rs -o wide | List ReplicaSets with details |
kubectl get services | List services |
kubectl get svc | List services (short) |
kubectl describe svc <name> | Show service details |
kubectl expose deployment <name> --port=80 --type=LoadBalancer | Expose deployment as service |
kubectl delete svc <name> | Delete service |
kubectl get endpoints | List endpoints |
kubectl get ingress | List ingress resources |
kubectl describe ingress <name> | Show ingress details |
kubectl delete ingress <name> | Delete ingress |
kubectl get networkpolicies | List network policies |
kubectl describe networkpolicy <name> | Show network policy details |
kubectl get configmaps | List ConfigMaps |
kubectl create configmap <name> --from-file=<path> | Create ConfigMap from file |
kubectl create configmap <name> --from-literal=key=value | Create ConfigMap from literal |
kubectl describe configmap <name> | Show ConfigMap details |
kubectl get secrets | List secrets |
kubectl create secret generic <name> --from-literal=key=value | Create generic secret |
kubectl create secret docker-registry <name> --docker-server=<url> --docker-username=<user> --docker-password=<pass> | Create Docker registry secret |
kubectl get secret <name> -o jsonpath="{.data.key}" | base64 -d | Decode secret value |
kubectl get pv | List PersistentVolumes |
kubectl get pvc | List PersistentVolumeClaims |
kubectl describe pv <name> | Show PV details |
kubectl describe pvc <name> | Show PVC details |
kubectl get storageclass | List storage classes |
kubectl get namespaces | List namespaces |
kubectl create namespace <name> | Create namespace |
kubectl delete namespace <name> | Delete namespace |
kubectl get all -n <namespace> | List all resources in namespace |
kubectl get serviceaccounts | List service accounts |
kubectl create serviceaccount <name> | Create service account |
kubectl get roles | List roles |
kubectl get rolebindings | List role bindings |
kubectl get clusterroles | List cluster roles |
kubectl get clusterrolebindings | List cluster role bindings |
kubectl auth can-i <verb> <resource> | Check permissions |
kubectl auth can-i --list | List all permissions |
kubectl get statefulsets | List StatefulSets |
kubectl describe statefulset <name> | Show StatefulSet details |
kubectl scale statefulset <name> --replicas=3 | Scale StatefulSet |
kubectl get daemonsets | List DaemonSets |
kubectl describe daemonset <name> | Show DaemonSet details |
kubectl get jobs | List jobs |
kubectl create job <name> --image=<image> | Create job |
kubectl describe job <name> | Show job details |
kubectl get cronjobs | List CronJobs |
kubectl create cronjob <name> --image=<image> --schedule="*/5 * * * *" | Create CronJob |
kubectl describe cronjob <name> | Show CronJob details |
kubectl apply -f <file.yaml> | Apply configuration from file |
kubectl apply -f <directory>/ | Apply all files in directory |
kubectl apply -f <url> | Apply from URL |
kubectl create -f <file.yaml> | Create resource from file |
kubectl replace -f <file.yaml> | Replace resource |
kubectl delete -f <file.yaml> | Delete resources from file |
kubectl diff -f <file.yaml> | Show diff before apply |
kubectl label pods <name> env=prod | Add label to pod |
kubectl label pods <name> env- | Remove label from pod |
kubectl annotate pods <name> description="text" | Add annotation |
kubectl get pods --show-labels | Show all labels |
kubectl get pods -l env=prod,tier=frontend | Filter by multiple labels |
kubectl get pods -o yaml | Output as YAML |
kubectl get pods -o json | Output as JSON |
kubectl get pods -o wide | Output with extra info |
kubectl get pods -o name | Output only names |
kubectl get pods -o jsonpath="{.items[*].metadata.name}" | Custom JSON path output |
kubectl get pods -o custom-columns='NAME:.metadata.name,STATUS:.status.phase' | Custom columns output |