Kubernetes CLI Reference
kubectl Commands Cheat Sheet
Complete kubectl commands cheat sheet for Kubernetes administration, DevOps, SRE, application support and production troubleshooting. Find practical commands for Pods, Deployments, Services, Nodes, namespaces, logs, networking, RBAC, storage, rollouts, debugging and cluster operations.
practical kubectl commands
command categories
production troubleshooting focus
30-Second kubectl Quick Start
If you are troubleshooting a Kubernetes application, start with read-only inspection commands. Confirm the cluster first, then move from cluster health to workload status, Pod details, logs and events before making a change.
Confirm the cluster
Always confirm where kubectl is connected before production changes.
kubectl config current-contextCheck nodes
Verify that the cluster has healthy and schedulable nodes.
kubectl get nodesCheck workloads
Get a quick view of workload health across namespaces.
kubectl get pods -AInspect the failure
Review container state, scheduling details and Kubernetes events.
kubectl describe pod <pod-name>Check application logs
Use current or previous container logs to identify application failures.
kubectl logs <pod-name>Check recent events
Correlate warnings, scheduling failures and recent cluster activity.
kubectl get events -A --sort-by=.lastTimestampProduction kubectl Safety Guide
kubectl can make immediate changes to live Kubernetes resources. In production, use an evidence-first workflow and verify the target cluster, namespace and resource before executing a change.
Verify context first
Run kubectl config current-context before operational changes. A correct command against the wrong cluster is still an incident.
Prefer evidence before changes
Collect status, events, logs and resource definitions before restarting, deleting or modifying workloads.
Understand controllers
Deleting a Pod managed by a Deployment, StatefulSet or DaemonSet can cause Kubernetes to create a replacement. Know what owns the resource.
Treat direct edits carefully
kubectl edit, patch, set image and scale can change live workloads. Use the appropriate change-management process for production.
Protect secrets
Avoid exposing credentials in shell history, command output, screenshots, tickets or shared logs.
Verify after changes
Use rollout status, Pod status, events, logs and application checks to confirm that the intended state was actually reached.
Production habit: before a destructive or mutating command, run kubectl config current-context and confirm the namespace and resource you intend to change.
What is kubectl?
kubectl is the Kubernetes command-line interface used to communicate with Kubernetes clusters through the Kubernetes API server. DevOps engineers, SREs and application support teams use kubectl to inspect workloads, deploy applications, troubleshoot Pods, manage Services and monitor cluster resources.
kubectl works against Kubernetes API resources, so the same command patterns can be used across managed Kubernetes platforms such as AKS, EKS and GKE as well as self-managed or on-premises Kubernetes environments, subject to the cluster configuration, authentication and installed resources.
kubectl Syntax
kubectl [command] [TYPE] [NAME] [flags]A typical kubectl command contains an operation such as get, describe, apply, delete or logs, followed by the Kubernetes resource type, resource name and optional flags.
kubectl get podsLists Pods in the current namespace.
kubectl get pods -n productionLists Pods in the production namespace.
Quick kubectl Command Reference
These are some of the most frequently used kubectl commands for Kubernetes administration, DevOps operations, SRE work and application support.
kubectl get podskubectl get pods -Akubectl get nodeskubectl describe pod <pod-name>kubectl logs <pod-name>kubectl logs --previous <pod-name>kubectl exec -it <pod-name> -- /bin/shkubectl apply -f deployment.yamlkubectl get svckubectl get deploymentskubectl rollout status deployment/<name>kubectl rollout undo deployment/<name>kubectl get events --sort-by=.lastTimestampkubectl top podskubectl config current-contextkubectl auth can-i --listKubernetes Command Reference
192 commands across 27 categories
1. Kubernetes Cluster Information
8 commandskubectl cluster-infoDisplays the Kubernetes control plane and cluster service endpoints.
kubectl versionDisplays client and server Kubernetes version information.
kubectl version --output=yamlDisplays Kubernetes client and server version information in YAML format.
kubectl api-versionsLists API versions available from the Kubernetes API server.
kubectl api-resourcesLists supported Kubernetes resource types and their API groups.
kubectl get --raw=/healthzQueries the Kubernetes API health endpoint.
kubectl get nodesLists all nodes in the current cluster.
kubectl get nodes -o wideShows additional node information such as IP address, OS and container runtime.
2. Get Kubernetes Resources
15 commandskubectl get podsLists Pods in the current namespace.
kubectl get pods -ALists Pods across all namespaces.
kubectl get pods -o wideShows additional Pod information including IP address and node.
kubectl get allDisplays common resources such as Pods, Services, Deployments and ReplicaSets in the current namespace.
kubectl get namespacesLists all namespaces in the cluster.
kubectl get svcLists Services in the current namespace.
kubectl get deploymentsLists Deployments in the current namespace.
kubectl get replicasetsLists ReplicaSets in the current namespace.
kubectl get daemonsetsLists DaemonSets in the current namespace.
kubectl get statefulsetsLists StatefulSets in the current namespace.
kubectl get jobsLists Jobs in the current namespace.
kubectl get cronjobsLists CronJobs in the current namespace.
kubectl get ingressLists Ingress resources.
kubectl get pvcLists PersistentVolumeClaims.
kubectl get pvLists PersistentVolumes in the cluster.
3. Namespaces
6 commandskubectl get nsLists all namespaces.
kubectl create namespace <namespace>Creates a namespace.
kubectl get pods -n <namespace>Lists Pods in a specific namespace.
kubectl get all -n <namespace>Lists common resources inside a specific namespace.
kubectl config set-context --current --namespace=<namespace>Sets the default namespace for the current kubectl context.
kubectl delete namespace <namespace>Deletes a namespace and the resources contained within it. Treat as a destructive production operation.
4. Describe and Inspect Resources
8 commandskubectl describe pod <pod-name>Shows detailed Pod information including events, containers, volumes and scheduling details.
kubectl describe node <node-name>Shows detailed information about a Kubernetes node.
kubectl describe deployment <deployment-name>Shows detailed Deployment configuration, replica status and events.
kubectl describe svc <service-name>Shows detailed Service configuration, ports and endpoint information.
kubectl describe ingress <ingress-name>Displays detailed Ingress configuration and routing information.
kubectl get pod <pod-name> -o yamlDisplays the complete Kubernetes Pod definition and status as YAML.
kubectl get pod <pod-name> -o jsonDisplays the complete Kubernetes Pod definition and status as JSON.
kubectl get deployment <deployment-name> -o wideDisplays additional Deployment information.
5. Pod Logs
8 commandskubectl logs <pod-name>Displays logs from a Pod.
kubectl logs -f <pod-name>Continuously follows Pod logs.
kubectl logs --tail=100 <pod-name>Displays the last 100 lines of logs.
kubectl logs --since=1h <pod-name>Displays logs generated during the specified time period.
kubectl logs --timestamps <pod-name>Includes timestamps in container logs.
kubectl logs --previous <pod-name>Displays logs from the previous terminated container instance.
kubectl logs <pod-name> -c <container-name>Displays logs from a specific container in a multi-container Pod.
kubectl logs -f <pod-name> -c <container-name>Follows logs from a specific container.
6. Execute Commands Inside Pods
5 commandskubectl exec -it <pod-name> -- /bin/bashOpens an interactive Bash shell inside a running container.
kubectl exec -it <pod-name> -- /bin/shOpens a shell when Bash is not available in the container.
kubectl exec <pod-name> -- envDisplays environment variables inside the container.
kubectl exec <pod-name> -- ls -laRuns ls inside the container.
kubectl exec -it <pod-name> -c <container-name> -- /bin/shOpens a shell in a specific container of a multi-container Pod.
7. Create and Apply Resources
7 commandskubectl apply -f deployment.yamlCreates or updates resources defined in a Kubernetes manifest.
kubectl apply -f ./manifests/Applies supported Kubernetes manifests from a directory.
kubectl apply -f deployment.yaml --dry-run=clientValidates the manifest locally without creating the resource.
kubectl create deployment nginx --image=nginxCreates a Deployment from the command line.
kubectl create namespace <namespace>Creates a namespace.
kubectl create configmap <name> --from-literal=key=valueCreates a ConfigMap from a literal key-value pair.
kubectl create secret generic <name> --from-literal=key=valueCreates a generic Secret from a literal key-value pair. Avoid exposing sensitive values in shell history.
8. Delete Resources
7 commandskubectl delete pod <pod-name>Deletes a specific Pod. If it is managed by a Deployment or another controller, Kubernetes may create a replacement.
kubectl delete deployment <deployment-name>Deletes a Deployment and its managed resources. Treat as a destructive operation.
kubectl delete svc <service-name>Deletes a Service and can interrupt application connectivity.
kubectl delete -f deployment.yamlDeletes resources defined in a Kubernetes manifest.
kubectl delete -f ./manifests/Deletes resources represented by manifests in a directory.
kubectl delete pod <pod-name> --grace-period=0 --forceForce deletes a Pod when normal graceful deletion is not completing. Use carefully because it bypasses normal graceful termination.
kubectl delete namespace <namespace>Deletes a namespace and its contained resources. Verify the target context before using this command.
9. Deployments and Rollouts
9 commandskubectl get deploymentsLists Deployments.
kubectl rollout status deployment/<deployment-name>Checks the rollout status of a Deployment.
kubectl rollout history deployment/<deployment-name>Displays Deployment rollout history.
kubectl rollout history deployment/<deployment-name> --revision=2Displays details for a specific Deployment revision.
kubectl rollout undo deployment/<deployment-name>Rolls a Deployment back to its previous revision.
kubectl rollout undo deployment/<deployment-name> --to-revision=2Rolls a Deployment back to a specific revision.
kubectl rollout restart deployment/<deployment-name>Triggers a rolling restart of a Deployment. A restart does not by itself fix an underlying application, configuration or dependency problem.
kubectl rollout pause deployment/<deployment-name>Pauses a Deployment rollout.
kubectl rollout resume deployment/<deployment-name>Resumes a paused Deployment rollout.
10. Scale Applications
4 commandskubectl scale deployment <deployment-name> --replicas=3Changes the desired number of replicas for a Deployment.
kubectl scale deployment <deployment-name> --replicas=0Scales a Deployment down to zero replicas. This stops its Pods and should be treated as a deliberate operational change.
kubectl get deployment <deployment-name>Shows the current and desired replica counts.
kubectl autoscale deployment <deployment-name> --min=2 --max=5 --cpu-percent=70Creates a HorizontalPodAutoscaler using CPU utilization targets.
11. Services and Networking
9 commandskubectl get svcLists Kubernetes Services.
kubectl describe svc <service-name>Displays Service configuration, ports and endpoints.
kubectl get endpointsDisplays endpoints associated with Services.
kubectl get endpointslicesLists EndpointSlice resources used for Service endpoint information.
kubectl expose deployment <deployment-name> --port=80 --type=NodePortCreates a Service exposing a Deployment.
kubectl expose deployment <deployment-name> --port=80 --target-port=8080 --type=ClusterIPCreates a ClusterIP Service and maps the Service port to a container target port.
kubectl port-forward svc/<service-name> 8080:80Forwards a local port to a Kubernetes Service for temporary debugging access.
kubectl port-forward pod/<pod-name> 8080:80Forwards a local port directly to a Pod for temporary debugging.
kubectl get networkpoliciesLists NetworkPolicy resources in the current namespace.
12. ConfigMaps and Secrets
7 commandskubectl get configmapsLists ConfigMaps.
kubectl describe configmap <name>Displays ConfigMap details.
kubectl get configmap <name> -o yamlDisplays a ConfigMap in YAML format.
kubectl get secretsLists Secrets.
kubectl describe secret <name>Displays Secret metadata without directly printing decoded values.
kubectl get secret <name> -o yamlDisplays a Secret manifest containing encoded data fields. Protect the output and do not treat base64 encoding as encryption.
kubectl create secret docker-registry <name> --docker-server=<registry> --docker-username=<username> --docker-password=<password>Creates an image-pull Secret for a private container registry. Avoid exposing credentials in shell history or process listings where possible.
13. Kubernetes Events
5 commandskubectl get eventsLists events in the current namespace.
kubectl get events -ALists events across all namespaces.
kubectl get events --sort-by=.lastTimestampSorts events by their latest timestamp.
kubectl get events --field-selector type=WarningShows warning events in the current namespace.
kubectl get events -A --sort-by=.lastTimestampDisplays cluster-wide events ordered by timestamp.
14. Resource Usage and Performance
5 commandskubectl top nodesDisplays CPU and memory usage for nodes when Metrics Server is available.
kubectl top podsDisplays CPU and memory usage for Pods when Metrics Server is available.
kubectl top pods -ADisplays Pod resource usage across namespaces.
kubectl top pod <pod-name> --containersDisplays CPU and memory usage for individual containers.
kubectl top node <node-name>Displays resource usage for a specific node.
15. Labels, Selectors and Annotations
7 commandskubectl get pods --show-labelsDisplays Pod labels.
kubectl get pods -l app=nginxLists Pods matching the specified label selector.
kubectl get pods -l 'environment in (production,staging)'Selects resources using a set-based label selector.
kubectl label pod <pod-name> environment=productionAdds or updates a label on a Pod.
kubectl label pod <pod-name> environment-Removes the specified label from a Pod.
kubectl annotate pod <pod-name> description='my pod'Adds or updates an annotation on a Pod.
kubectl get pods -l app=nginx -o nameReturns matching Pod resource names only.
16. Context and Kubeconfig
8 commandskubectl config get-contextsLists available kubectl contexts.
kubectl config current-contextDisplays the currently selected context. Check this before production changes.
kubectl config use-context <context-name>Switches to another Kubernetes context.
kubectl config viewDisplays the current kubeconfig configuration. Protect sensitive credentials if present.
kubectl config view --minifyDisplays only the configuration for the current context.
kubectl config set-context <context-name> --cluster=<cluster> --user=<user>Creates or updates a kubeconfig context.
kubectl config rename-context <old-name> <new-name>Renames an existing kubeconfig context.
kubectl config delete-context <context-name>Deletes a context from kubeconfig.
17. Patch and Edit Resources
6 commandskubectl edit deployment <deployment-name>Opens the live Deployment manifest in an editor. Treat direct production edits as controlled changes.
kubectl edit service <service-name>Opens a Service manifest for live editing.
kubectl patch deployment <deployment-name> -p '{"spec":{"replicas":3}}'Applies a targeted patch to a Kubernetes resource.
kubectl set image deployment/<deployment-name> <container-name>=<image>:<tag>Updates the container image used by a Deployment and normally triggers a rollout.
kubectl set env deployment/<deployment-name> ENV=productionAdds or updates an environment variable on a Deployment.
kubectl set resources deployment/<deployment-name> -c <container-name> --requests=cpu=100m,memory=128Mi --limits=cpu=500m,memory=512MiUpdates resource requests and limits for a Deployment container.
18. Jobs and CronJobs
7 commandskubectl get jobsLists Jobs.
kubectl describe job <job-name>Displays detailed Job status, Pod information and events.
kubectl create job <job-name> --image=busybox -- echo helloCreates a Job that runs a command.
kubectl get cronjobsLists CronJobs.
kubectl describe cronjob <cronjob-name>Displays CronJob schedule and execution information.
kubectl create job --from=cronjob/<cronjob-name> <job-name>Creates an immediate Job from an existing CronJob template.
kubectl delete job <job-name>Deletes a Kubernetes Job.
19. StatefulSets and DaemonSets
6 commandskubectl get statefulsetsLists StatefulSets.
kubectl rollout status statefulset/<name>Checks the rollout status of a StatefulSet.
kubectl rollout restart statefulset/<name>Restarts Pods managed by a StatefulSet.
kubectl get daemonsetsLists DaemonSets.
kubectl rollout status daemonset/<name>Checks the rollout status of a DaemonSet.
kubectl rollout restart daemonset/<name>Restarts Pods managed by a DaemonSet.
20. Storage
6 commandskubectl get pvLists PersistentVolumes in the cluster.
kubectl get pvcLists PersistentVolumeClaims in the current namespace.
kubectl describe pv <pv-name>Displays detailed PersistentVolume information.
kubectl describe pvc <pvc-name>Displays detailed PersistentVolumeClaim information.
kubectl get storageclassLists available StorageClasses.
kubectl get storageclass -o wideDisplays additional StorageClass information.
21. Ingress and Network Policies
5 commandskubectl get ingressLists Ingress resources.
kubectl describe ingress <ingress-name>Displays Ingress rules, backend Services and events.
kubectl get networkpolicyLists NetworkPolicy resources.
kubectl describe networkpolicy <policy-name>Displays NetworkPolicy selectors and ingress or egress rules.
kubectl get ingressclassLists available IngressClass resources.
22. RBAC and Security
8 commandskubectl get serviceaccountsLists ServiceAccounts in the current namespace.
kubectl get rolesLists namespace-scoped Roles.
kubectl get rolebindingsLists namespace-scoped RoleBindings.
kubectl get clusterrolesLists cluster-scoped ClusterRoles.
kubectl get clusterrolebindingsLists ClusterRoleBindings.
kubectl auth can-i get podsChecks whether the current identity can perform an action.
kubectl auth can-i create deployments -n <namespace>Checks whether the current identity can create Deployments in a namespace.
kubectl auth can-i --listLists the actions permitted for the current identity.
23. Kubernetes Debugging and Troubleshooting
10 commandskubectl get pods -o wideChecks Pod placement, IP addresses and node assignment.
kubectl describe pod <pod-name>Inspects scheduling, container state and Kubernetes events.
kubectl logs <pod-name>Inspects application output from the container.
kubectl logs --previous <pod-name>Checks logs from a previous crashed container.
kubectl get events --sort-by=.lastTimestampReviews recent Kubernetes events for failures and warnings.
kubectl get pod <pod-name> -o yamlDisplays the complete Pod specification and status.
kubectl get pods --field-selector=status.phase=FailedLists Pods currently in the Failed phase.
kubectl get pods --field-selector=status.phase=PendingLists Pods currently in the Pending phase.
kubectl get pods --field-selector=status.phase=RunningLists Pods currently in the Running phase.
kubectl get pods -A | grep -v RunningOn environments with grep available, helps identify Pods that are not Running.
24. Debug Containers and Temporary Troubleshooting Pods
5 commandskubectl debug pod/<pod-name> -it --image=busyboxStarts an ephemeral debugging container when the cluster supports ephemeral containers.
kubectl run debug --rm -it --image=busybox -- /bin/shCreates a temporary interactive Pod for network or application troubleshooting.
kubectl run curl --rm -it --image=curlimages/curl -- shStarts a temporary curl-capable container for HTTP and network diagnostics.
kubectl exec -it <pod-name> -- nslookup <service-name>Tests DNS resolution from inside a running Pod when the required utility exists.
kubectl exec -it <pod-name> -- wget -qO- http://<service-name>:<port>Tests HTTP connectivity from inside a Pod when wget is available.
25. Output, Formatting and Filtering
8 commandskubectl get pods -o nameDisplays resource names only.
kubectl get pods -o wideDisplays additional columns such as Pod IP and node.
kubectl get pods -o yamlDisplays matching resources as YAML.
kubectl get pods -o jsonDisplays matching resources as JSON.
kubectl get pods -o custom-columns=NAME:.metadata.name,STATUS:.status.phaseDisplays selected fields using custom columns.
kubectl get pods -o jsonpath='{.items[*].metadata.name}'Extracts specific values using JSONPath.
kubectl get pods --sort-by=.metadata.creationTimestampSorts resources by creation timestamp.
kubectl get pods -l app=nginx --no-headersLists matching resources without the table header.
26. Server-Side and Client-Side Validation
4 commandskubectl apply -f deployment.yaml --dry-run=clientPerforms client-side dry-run validation without creating the object.
kubectl apply -f deployment.yaml --dry-run=serverSends the request to the API server for server-side dry-run validation.
kubectl create deployment nginx --image=nginx --dry-run=client -o yamlGenerates a Deployment manifest without creating it.
kubectl create service clusterip nginx --tcp=80:80 --dry-run=client -o yamlGenerates a Service manifest without creating it.
27. Recommended Kubernetes DevOps Workflow
9 commandskubectl config current-contextConfirms the active cluster context before making changes.
kubectl get nodesVerifies that cluster nodes are available.
kubectl get pods -AChecks overall Pod health across namespaces.
kubectl apply -f ./manifests/Applies application manifests.
kubectl rollout status deployment/<deployment-name>Waits for a Deployment rollout to complete.
kubectl get pods -o wideVerifies Pod placement, status and IP information.
kubectl get svcVerifies application Services.
kubectl get ingressVerifies external routing when Ingress is used.
kubectl get events --sort-by=.lastTimestampReviews recent warnings and operational events.
Most Useful kubectl Commands for Troubleshooting
When a Kubernetes application is not working, start with non-destructive inspection commands. Confirm the active context, then check Pod status, events, logs, Deployment state, Services and endpoints before making changes.
kubectl config current-context kubectl get nodes kubectl get pods -A kubectl get pods -o wide kubectl describe pod <pod-name> kubectl logs <pod-name> kubectl logs --previous <pod-name> kubectl get events --sort-by=.lastTimestamp kubectl get deployment kubectl rollout status deployment/<deployment-name> kubectl get svc kubectl get endpoints kubectl describe node <node-name>
Kubernetes Troubleshooting Workflows
Use the symptom to choose the first diagnostic commands. The goal is to collect evidence before changing the workload.
Pod is stuck in Pending
kubectl get pod <pod-name> -o wide kubectl describe pod <pod-name> kubectl get events --sort-by=.lastTimestamp
Look for scheduling constraints, insufficient resources, taints, affinity rules, volume binding and other scheduler events.
Pod is in CrashLoopBackOff
kubectl get pod <pod-name> kubectl describe pod <pod-name> kubectl logs <pod-name> kubectl logs --previous <pod-name>
Compare the current and previous container state and logs before deciding whether the issue is application code, configuration, probes, dependencies or resources.
Pod is in ImagePullBackOff
kubectl get pod <pod-name> kubectl describe pod <pod-name> kubectl get events --sort-by=.lastTimestamp
Check the exact image reference and Pod events for authentication, authorization, DNS, TLS, network or missing-image errors.
Deployment rollout is failing
kubectl get deployment <deployment-name> kubectl rollout status deployment/<deployment-name> kubectl rollout history deployment/<deployment-name> kubectl describe deployment <deployment-name>
Check replica availability, rollout progress, revision history and the condition that is preventing the desired state from being reached.
Service is not reachable
kubectl get svc kubectl describe svc <service-name> kubectl get endpoints kubectl get endpointslices kubectl get pods -o wide
Verify Service selectors, ports, target ports and whether healthy Pods are actually registered as endpoints.
Check node health
kubectl get nodes kubectl get nodes -o wide kubectl describe node <node-name> kubectl top nodes
Inspect node conditions, capacity, allocatable resources, scheduling state and current resource usage.
Kubernetes Troubleshooting Guides
For common Kubernetes failure states, use the dedicated troubleshooting workflows after collecting the initial Pod, events and log evidence.
CrashLoopBackOff
Investigate repeated container restarts, previous logs, probes, configuration and resource failures.
Open troubleshooting guide →ImagePullBackOff / ErrImagePull
Troubleshoot image names, tags, private registries, imagePullSecrets, authentication, DNS and network errors.
Open troubleshooting guide →Kubernetes Production Troubleshooting Workflow
A repeatable troubleshooting workflow helps separate symptoms from causes and reduces unnecessary production changes.
Context
Confirm the cluster and namespace.
Status
Check Nodes, Pods and Deployments.
Events
Look for scheduling and Kubernetes warnings.
Logs
Check current and previous container logs.
Network
Check Services, endpoints and routing.
Read-Only vs Change Commands
During an incident, start with commands that collect evidence. Move to mutating commands only after the failure mode is understood and the intended change is clear.
Inspect
Examples: get, describe, logs, events, top, auth can-i and config current-context.
Change
Examples: apply, set image, scale, patch, edit and rollout restart.
Destructive
Examples: delete resources, force-delete Pods and delete namespaces. Confirm scope and impact before execution.
kubectl FAQ
What is kubectl?
kubectl is the Kubernetes command-line interface used to communicate with the Kubernetes API server and manage Kubernetes resources such as Pods, Deployments, Services, Nodes, ConfigMaps and Secrets.
What is the most commonly used kubectl command?
kubectl get pods is one of the most commonly used commands because it quickly shows Pod status in the current namespace. kubectl get pods -A can be used to inspect Pods across all namespaces.
How do I check why a Kubernetes Pod is failing?
Start with kubectl config current-context to confirm the target cluster, then use kubectl get pods, kubectl describe pod <pod-name>, kubectl logs <pod-name>, kubectl logs --previous <pod-name> and kubectl get events --sort-by=.lastTimestamp to investigate status, events and application logs.
How do I troubleshoot CrashLoopBackOff?
Start with kubectl get pod <pod-name>, then inspect kubectl describe pod <pod-name>, kubectl logs <pod-name>, kubectl logs --previous <pod-name> and recent events. CrashLoopBackOff can result from application failures, configuration problems, failed probes, missing dependencies or resource issues.
How do I troubleshoot ImagePullBackOff?
Inspect the Pod events with kubectl describe pod <pod-name> and verify the image name, tag, registry authentication and imagePullSecrets. Registry DNS, network, TLS and authorization failures can also prevent Kubernetes from pulling an image.
How do I check Kubernetes Deployment rollout status?
Use kubectl rollout status deployment/<deployment-name>. This shows whether the Deployment is progressing toward its desired state.
How do I rollback a Kubernetes Deployment?
Use kubectl rollout undo deployment/<deployment-name> to roll back to the previous revision, or use --to-revision=<revision> to target a specific revision. In production, first confirm the current context, revision history and impact of the rollback.
How do I check CPU and memory usage in Kubernetes?
Use kubectl top nodes and kubectl top pods when Metrics Server is available in the cluster.
How do I check which Kubernetes context is active?
Run kubectl config current-context. This is especially important before executing commands against production or another critical cluster.
What should I check before running a destructive kubectl command?
Confirm the active context and namespace, identify the exact resource, review its current state and understand whether a controller will recreate or modify dependent resources. For production changes, follow the applicable change-management and approval process.
DevOps Commands Tip
Before running a destructive kubectl command, confirm the active context and namespace. During incidents, collect status, events, logs and resource definitions first. This preserves useful diagnostic information and makes troubleshooting more systematic.