← Back to DevOps Commands

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.

kubectl commandsKubernetes CLIkubectl cheat sheetKubernetes troubleshootingDevOps commandsSRE commands
192

practical kubectl commands

27

command categories

L3 / SRE

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.

1

Confirm the cluster

Always confirm where kubectl is connected before production changes.

kubectl config current-context
2

Check nodes

Verify that the cluster has healthy and schedulable nodes.

kubectl get nodes
3

Check workloads

Get a quick view of workload health across namespaces.

kubectl get pods -A
4

Inspect the failure

Review container state, scheduling details and Kubernetes events.

kubectl describe pod <pod-name>
5

Check application logs

Use current or previous container logs to identify application failures.

kubectl logs <pod-name>
6

Check recent events

Correlate warnings, scheduling failures and recent cluster activity.

kubectl get events -A --sort-by=.lastTimestamp

Production 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 pods

Lists Pods in the current namespace.

kubectl get pods -n production

Lists 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 pods
kubectl get pods -A
kubectl get nodes
kubectl describe pod <pod-name>
kubectl logs <pod-name>
kubectl logs --previous <pod-name>
kubectl exec -it <pod-name> -- /bin/sh
kubectl apply -f deployment.yaml
kubectl get svc
kubectl get deployments
kubectl rollout status deployment/<name>
kubectl rollout undo deployment/<name>
kubectl get events --sort-by=.lastTimestamp
kubectl top pods
kubectl config current-context
kubectl auth can-i --list

kubectl Commands by Category

Use the command search below to find Kubernetes CLI commands by task. This reference covers commands commonly used during Kubernetes administration, DevOps operations, application support and production troubleshooting.

Kubernetes Command Reference

192 commands across 27 categories

192 commands across 27 categories

1. Kubernetes Cluster Information

8 commands
kubectl cluster-info

Displays the Kubernetes control plane and cluster service endpoints.

kubectl version

Displays client and server Kubernetes version information.

kubectl version --output=yaml

Displays Kubernetes client and server version information in YAML format.

kubectl api-versions

Lists API versions available from the Kubernetes API server.

kubectl api-resources

Lists supported Kubernetes resource types and their API groups.

kubectl get --raw=/healthz

Queries the Kubernetes API health endpoint.

kubectl get nodes

Lists all nodes in the current cluster.

kubectl get nodes -o wide

Shows additional node information such as IP address, OS and container runtime.

2. Get Kubernetes Resources

15 commands
kubectl get pods

Lists Pods in the current namespace.

kubectl get pods -A

Lists Pods across all namespaces.

kubectl get pods -o wide

Shows additional Pod information including IP address and node.

kubectl get all

Displays common resources such as Pods, Services, Deployments and ReplicaSets in the current namespace.

kubectl get namespaces

Lists all namespaces in the cluster.

kubectl get svc

Lists Services in the current namespace.

kubectl get deployments

Lists Deployments in the current namespace.

kubectl get replicasets

Lists ReplicaSets in the current namespace.

kubectl get daemonsets

Lists DaemonSets in the current namespace.

kubectl get statefulsets

Lists StatefulSets in the current namespace.

kubectl get jobs

Lists Jobs in the current namespace.

kubectl get cronjobs

Lists CronJobs in the current namespace.

kubectl get ingress

Lists Ingress resources.

kubectl get pvc

Lists PersistentVolumeClaims.

kubectl get pv

Lists PersistentVolumes in the cluster.

3. Namespaces

6 commands
kubectl get ns

Lists 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 commands
kubectl 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 yaml

Displays the complete Kubernetes Pod definition and status as YAML.

kubectl get pod <pod-name> -o json

Displays the complete Kubernetes Pod definition and status as JSON.

kubectl get deployment <deployment-name> -o wide

Displays additional Deployment information.

5. Pod Logs

8 commands
kubectl 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 commands
kubectl exec -it <pod-name> -- /bin/bash

Opens an interactive Bash shell inside a running container.

kubectl exec -it <pod-name> -- /bin/sh

Opens a shell when Bash is not available in the container.

kubectl exec <pod-name> -- env

Displays environment variables inside the container.

kubectl exec <pod-name> -- ls -la

Runs ls inside the container.

kubectl exec -it <pod-name> -c <container-name> -- /bin/sh

Opens a shell in a specific container of a multi-container Pod.

7. Create and Apply Resources

7 commands
kubectl apply -f deployment.yaml

Creates 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=client

Validates the manifest locally without creating the resource.

kubectl create deployment nginx --image=nginx

Creates a Deployment from the command line.

kubectl create namespace <namespace>

Creates a namespace.

kubectl create configmap <name> --from-literal=key=value

Creates a ConfigMap from a literal key-value pair.

kubectl create secret generic <name> --from-literal=key=value

Creates a generic Secret from a literal key-value pair. Avoid exposing sensitive values in shell history.

8. Delete Resources

7 commands
kubectl 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.yaml

Deletes 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 --force

Force 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 commands
kubectl get deployments

Lists 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=2

Displays 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=2

Rolls 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 commands
kubectl scale deployment <deployment-name> --replicas=3

Changes the desired number of replicas for a Deployment.

kubectl scale deployment <deployment-name> --replicas=0

Scales 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=70

Creates a HorizontalPodAutoscaler using CPU utilization targets.

11. Services and Networking

9 commands
kubectl get svc

Lists Kubernetes Services.

kubectl describe svc <service-name>

Displays Service configuration, ports and endpoints.

kubectl get endpoints

Displays endpoints associated with Services.

kubectl get endpointslices

Lists EndpointSlice resources used for Service endpoint information.

kubectl expose deployment <deployment-name> --port=80 --type=NodePort

Creates a Service exposing a Deployment.

kubectl expose deployment <deployment-name> --port=80 --target-port=8080 --type=ClusterIP

Creates a ClusterIP Service and maps the Service port to a container target port.

kubectl port-forward svc/<service-name> 8080:80

Forwards a local port to a Kubernetes Service for temporary debugging access.

kubectl port-forward pod/<pod-name> 8080:80

Forwards a local port directly to a Pod for temporary debugging.

kubectl get networkpolicies

Lists NetworkPolicy resources in the current namespace.

12. ConfigMaps and Secrets

7 commands
kubectl get configmaps

Lists ConfigMaps.

kubectl describe configmap <name>

Displays ConfigMap details.

kubectl get configmap <name> -o yaml

Displays a ConfigMap in YAML format.

kubectl get secrets

Lists Secrets.

kubectl describe secret <name>

Displays Secret metadata without directly printing decoded values.

kubectl get secret <name> -o yaml

Displays 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 commands
kubectl get events

Lists events in the current namespace.

kubectl get events -A

Lists events across all namespaces.

kubectl get events --sort-by=.lastTimestamp

Sorts events by their latest timestamp.

kubectl get events --field-selector type=Warning

Shows warning events in the current namespace.

kubectl get events -A --sort-by=.lastTimestamp

Displays cluster-wide events ordered by timestamp.

14. Resource Usage and Performance

5 commands
kubectl top nodes

Displays CPU and memory usage for nodes when Metrics Server is available.

kubectl top pods

Displays CPU and memory usage for Pods when Metrics Server is available.

kubectl top pods -A

Displays Pod resource usage across namespaces.

kubectl top pod <pod-name> --containers

Displays 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 commands
kubectl get pods --show-labels

Displays Pod labels.

kubectl get pods -l app=nginx

Lists 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=production

Adds 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 name

Returns matching Pod resource names only.

16. Context and Kubeconfig

8 commands
kubectl config get-contexts

Lists available kubectl contexts.

kubectl config current-context

Displays the currently selected context. Check this before production changes.

kubectl config use-context <context-name>

Switches to another Kubernetes context.

kubectl config view

Displays the current kubeconfig configuration. Protect sensitive credentials if present.

kubectl config view --minify

Displays 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 commands
kubectl 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=production

Adds 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=512Mi

Updates resource requests and limits for a Deployment container.

18. Jobs and CronJobs

7 commands
kubectl get jobs

Lists Jobs.

kubectl describe job <job-name>

Displays detailed Job status, Pod information and events.

kubectl create job <job-name> --image=busybox -- echo hello

Creates a Job that runs a command.

kubectl get cronjobs

Lists 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 commands
kubectl get statefulsets

Lists 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 daemonsets

Lists 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 commands
kubectl get pv

Lists PersistentVolumes in the cluster.

kubectl get pvc

Lists 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 storageclass

Lists available StorageClasses.

kubectl get storageclass -o wide

Displays additional StorageClass information.

21. Ingress and Network Policies

5 commands
kubectl get ingress

Lists Ingress resources.

kubectl describe ingress <ingress-name>

Displays Ingress rules, backend Services and events.

kubectl get networkpolicy

Lists NetworkPolicy resources.

kubectl describe networkpolicy <policy-name>

Displays NetworkPolicy selectors and ingress or egress rules.

kubectl get ingressclass

Lists available IngressClass resources.

22. RBAC and Security

8 commands
kubectl get serviceaccounts

Lists ServiceAccounts in the current namespace.

kubectl get roles

Lists namespace-scoped Roles.

kubectl get rolebindings

Lists namespace-scoped RoleBindings.

kubectl get clusterroles

Lists cluster-scoped ClusterRoles.

kubectl get clusterrolebindings

Lists ClusterRoleBindings.

kubectl auth can-i get pods

Checks 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 --list

Lists the actions permitted for the current identity.

23. Kubernetes Debugging and Troubleshooting

10 commands
kubectl get pods -o wide

Checks 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=.lastTimestamp

Reviews recent Kubernetes events for failures and warnings.

kubectl get pod <pod-name> -o yaml

Displays the complete Pod specification and status.

kubectl get pods --field-selector=status.phase=Failed

Lists Pods currently in the Failed phase.

kubectl get pods --field-selector=status.phase=Pending

Lists Pods currently in the Pending phase.

kubectl get pods --field-selector=status.phase=Running

Lists Pods currently in the Running phase.

kubectl get pods -A | grep -v Running

On environments with grep available, helps identify Pods that are not Running.

24. Debug Containers and Temporary Troubleshooting Pods

5 commands
kubectl debug pod/<pod-name> -it --image=busybox

Starts an ephemeral debugging container when the cluster supports ephemeral containers.

kubectl run debug --rm -it --image=busybox -- /bin/sh

Creates a temporary interactive Pod for network or application troubleshooting.

kubectl run curl --rm -it --image=curlimages/curl -- sh

Starts 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 commands
kubectl get pods -o name

Displays resource names only.

kubectl get pods -o wide

Displays additional columns such as Pod IP and node.

kubectl get pods -o yaml

Displays matching resources as YAML.

kubectl get pods -o json

Displays matching resources as JSON.

kubectl get pods -o custom-columns=NAME:.metadata.name,STATUS:.status.phase

Displays selected fields using custom columns.

kubectl get pods -o jsonpath='{.items[*].metadata.name}'

Extracts specific values using JSONPath.

kubectl get pods --sort-by=.metadata.creationTimestamp

Sorts resources by creation timestamp.

kubectl get pods -l app=nginx --no-headers

Lists matching resources without the table header.

26. Server-Side and Client-Side Validation

4 commands
kubectl apply -f deployment.yaml --dry-run=client

Performs client-side dry-run validation without creating the object.

kubectl apply -f deployment.yaml --dry-run=server

Sends the request to the API server for server-side dry-run validation.

kubectl create deployment nginx --image=nginx --dry-run=client -o yaml

Generates a Deployment manifest without creating it.

kubectl create service clusterip nginx --tcp=80:80 --dry-run=client -o yaml

Generates a Service manifest without creating it.

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.

View Kubernetes troubleshooting guides →

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.

Kubernetes Production Troubleshooting Workflow

A repeatable troubleshooting workflow helps separate symptoms from causes and reduces unnecessary production changes.

1

Context

Confirm the cluster and namespace.

2

Status

Check Nodes, Pods and Deployments.

3

Events

Look for scheduling and Kubernetes warnings.

4

Logs

Check current and previous container logs.

5

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.