Cheat Sheetcheat sheetkubectlkubernetes

Kubernetes Commands at a Glance: kubectl Cheat Sheet

CAEPE Team··3 min read

A quick reference to commonly used kubectl commands for viewing and managing Kubernetes resources, including Pods, Deployments, Services, storage, and access controls. Find the command you need and click to copy it to your clipboard.

Keep in Mind

  • Replace placeholders such as <pod-name> and <namespace> with actual values. Angle brackets are documentation placeholders, not literal shell input.
  • Namespaced resources use the current namespace unless -n <namespace> is supplied. Check your kubectl context and namespace before making changes.
  • Commands under Applying and Updating Resources and kubectl auth reconcile modify cluster state. kubectl delete is destructive.
  • Secret YAML may contain base64-encoded sensitive data. Avoid copying it into logs, tickets, or public channels.
  • Label selectors such as app=frontend and environment=production are examples; substitute labels that exist in your cluster.

Nodes

Nodes commands
PurposeCommand
List nodes
kubectl get nodes
Inspect a node
kubectl describe node <node-name>
Show node details in wide format
kubectl get nodes -o wide
Show node objects as YAML
kubectl get nodes -o yaml
Show node labels
kubectl get nodes --show-labels
Filter nodes by a label
kubectl get nodes -l environment=production

Namespaces

Namespaces commands
PurposeCommand
List namespaces
kubectl get namespaces
Inspect a namespace
kubectl describe namespace <namespace>
Show namespaces as YAML
kubectl get namespaces -o yaml

Pods

Pods commands
PurposeCommand
List Pods in current namespace
kubectl get pods
Inspect a Pod
kubectl describe pod <pod-name>
Show Pod details
kubectl get pods -o wide
Show Pods as YAML
kubectl get pods -o yaml
Show Pod labels
kubectl get pods --show-labels
Filter Pods by label
kubectl get pods -l app=frontend

Deployments

Deployments commands
PurposeCommand
List Deployments
kubectl get deployments
Inspect a Deployment
kubectl describe deployment <deployment-name>
Show Deployment details
kubectl get deployments -o wide
Show Deployments as YAML
kubectl get deployments -o yaml
Show Deployment labels
kubectl get deployments --show-labels
Filter Deployments by label
kubectl get deployments -l app=frontend

DaemonSets

DaemonSets commands
PurposeCommand
List DaemonSets
kubectl get daemonsets
Inspect a DaemonSet
kubectl describe daemonset <daemonset-name>
Show DaemonSet details
kubectl get daemonsets -o wide
Show DaemonSets as YAML
kubectl get daemonsets -o yaml
Show DaemonSet labels
kubectl get daemonsets --show-labels
Filter DaemonSets by label
kubectl get daemonsets -l app=agent

ReplicaSets

ReplicaSets commands
PurposeCommand
List ReplicaSets
kubectl get replicasets
Inspect a ReplicaSet
kubectl describe replicaset <replicaset-name>
Show ReplicaSets as YAML
kubectl get replicasets -o yaml

Services

Services commands
PurposeCommand
List Services
kubectl get services
Inspect a Service
kubectl describe service <service-name>
Show Service details
kubectl get services -o wide
Show Services as YAML
kubectl get services -o yaml
Show Service labels
kubectl get services --show-labels
Filter Services by label
kubectl get services -l app=frontend

RBAC

RBAC commands
PurposeCommand
List ServiceAccounts
kubectl get serviceaccounts
Show ServiceAccounts as YAML
kubectl get serviceaccounts -o yaml
List namespace Roles
kubectl get roles
Show Roles as YAML
kubectl get roles -o yaml
List RoleBindings
kubectl get rolebindings
Show RoleBindings as YAML
kubectl get rolebindings -o yaml
List ClusterRoles
kubectl get clusterroles
Show ClusterRoles as YAML
kubectl get clusterroles -o yaml
List ClusterRoleBindings
kubectl get clusterrolebindings
Show ClusterRoleBindings as YAML
kubectl get clusterrolebindings -o yaml
Check permission to list Pods
kubectl auth can-i list pods
Reconcile RBAC resources from a file [modifies cluster]
kubectl auth reconcile -f my-rbac-rules.yaml

Secrets

Secrets commands
PurposeCommand
List Secrets
kubectl get secrets
Show Secret resources as YAML [sensitive]
kubectl get secrets -o yaml

ConfigMaps

ConfigMaps commands
PurposeCommand
List ConfigMaps
kubectl get configmaps
Show ConfigMaps as YAML
kubectl get configmaps -o yaml

StorageClasses

StorageClasses commands
PurposeCommand
List StorageClasses
kubectl get storageclasses
Show StorageClasses as YAML
kubectl get storageclasses -o yaml

PersistentVolumes

PersistentVolumes commands
PurposeCommand
List PersistentVolumes
kubectl get persistentvolumes
Show PersistentVolumes as YAML
kubectl get persistentvolumes -o yaml

PersistentVolumeClaims

PersistentVolumeClaims commands
PurposeCommand
List PersistentVolumeClaims
kubectl get persistentvolumeclaims
Show claims as YAML
kubectl get persistentvolumeclaims -o yaml

Ingress

Ingress commands
PurposeCommand
List Ingress resources
kubectl get ingress
Inspect an Ingress resource
kubectl describe ingress <ingress-name>
Show Ingress resources as YAML
kubectl get ingress -o yaml

Applying and Updating Resources

Applying and Updating Resources commands
PurposeCommand
Create or update resources from a manifest [modifies cluster]
kubectl apply -f deployment.yaml
Delete resources defined in a manifest [destructive]
kubectl delete -f deployment.yaml

References

Share:

Related Articles