Showing 83 of 83 commands

Cluster Info

Inspect cluster health, contexts, nodes, and client configuration

10 commands
kubectl version --clientbeginner

Show the installed kubectl client version without querying the cluster

kubectl cluster-infobeginner

Display the cluster control plane and core service endpoints

kubectl get nodesbeginner

List all nodes and their readiness status in the current cluster

kubectl get nodes -o widebeginner

List nodes with extra details like internal IPs, OS image, and container runtime

kubectl describe node <name>intermediate

Show detailed capacity, conditions, labels, taints, and pod allocation for a node

kubectl top nodesintermediate

View live CPU and memory usage for nodes from Metrics Server

kubectl config viewintermediate

Print the merged kubeconfig with clusters, users, and contexts

kubectl config current-contextbeginner

Show the currently selected kubeconfig context

kubectl config get-contextsbeginner

List all available kubeconfig contexts and highlight the active one

kubectl config use-context <ctx>beginner

Switch kubectl to a different cluster and user context

Pods

Create, inspect, access, and troubleshoot running pods

13 commands
kubectl get podsbeginner

List pods in the current namespace with basic readiness and status info

kubectl get pods -Abeginner

List pods across every namespace in the cluster

kubectl get pods -n <ns>beginner

List pods only in a specific namespace

kubectl get pods -o widebeginner

Show pods with extra details like node placement and pod IPs

kubectl describe pod <name>intermediate

Inspect pod metadata, container states, events, probes, and mounts

kubectl logs <pod>beginner

Fetch logs from the main container in a pod

kubectl logs <pod> -fbeginner

Stream logs from a pod in real time

kubectl logs <pod> --previousintermediate

View logs from the previously terminated container instance in a restarting pod

kubectl exec -it <pod> -- /bin/shintermediate

Open an interactive shell inside a pod using the default container

kubectl exec -it <pod> -c <container> -- bashintermediate

Open a shell inside a specific container in a multi-container pod

kubectl delete pod <name>beginner

Delete a pod and let its controller recreate it if managed

kubectl run nginx --image=nginxbeginner

Create a quick standalone pod directly from an image

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

Forward a local port to a pod port for direct debugging access

Deployments

Manage application rollouts, scaling, updates, and revisions

12 commands
kubectl get deploymentsbeginner

List deployments in the current namespace with desired and ready replica counts

kubectl describe deployment <name>intermediate

Inspect a deployment strategy, pod template, rollout conditions, and events

kubectl create deployment nginx --image=nginxbeginner

Create a deployment from a single image directly from the CLI

kubectl scale deployment <name> --replicas=3beginner

Change the number of desired pod replicas for a deployment

kubectl set image deployment/<name> <container>=<image>:tagintermediate

Update a container image and trigger a rolling rollout

kubectl rollout status deployment/<name>intermediate

Watch the rollout until the deployment successfully completes or fails

kubectl rollout history deployment/<name>intermediate

Show previous rollout revisions for a deployment

kubectl rollout undo deployment/<name>intermediate

Roll back the deployment to the previous revision

kubectl rollout undo deployment/<name> --to-revision=2advanced

Roll back the deployment to a specific stored revision

kubectl delete deployment <name>beginner

Delete a deployment and its managed ReplicaSets and pods

kubectl apply -f deployment.yamlbeginner

Create or update a deployment declaratively from a manifest file

kubectl edit deployment <name>advanced

Open the live deployment manifest in your editor for an immediate change

Services & Networking

Expose workloads, inspect traffic paths, and work with ingress and endpoints

11 commands
kubectl get svcbeginner

List services in the current namespace with type and cluster IP

kubectl get svc -Abeginner

List services across all namespaces

kubectl describe svc <name>intermediate

Inspect service ports, selectors, endpoints, and load balancer details

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

Expose a deployment internally within the cluster using a ClusterIP service

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

Expose a deployment externally through a cloud load balancer

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

Expose a deployment on a static port on each cluster node

kubectl get ingressbeginner

List ingress resources and their configured hosts and addresses

kubectl describe ingress <name>intermediate

Inspect ingress rules, TLS configuration, and backend service routing

kubectl get endpointsintermediate

Show which pod IPs are currently backing each service

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

Forward a local port to a service for testing without external exposure

kubectl delete svc <name>beginner

Delete a service resource by name

Namespaces

Organize workloads and scope kubectl operations by environment or team

8 commands
kubectl get namespacesbeginner

List all namespaces in the cluster

kubectl create namespace <name>beginner

Create a new namespace for an application, team, or environment

kubectl delete namespace <name>intermediate

Delete a namespace and everything contained inside it

kubectl get all -n <namespace>beginner

List the main workload and service resources in a target namespace

kubectl config set-context --current --namespace=<name>intermediate

Set the default namespace for the current context to reduce repeated -n flags

kubectl get pods --all-namespacesbeginner

List pods across every namespace using the long-form namespace flag

kubectl get quota -n <namespace>intermediate

View resource quota usage and hard limits for a namespace

kubectl describe namespace <name>intermediate

Inspect a namespace including labels, annotations, quotas, and limit ranges

ConfigMaps & Secrets

Manage runtime configuration, credentials, and image pull secrets

9 commands
kubectl get configmapsbeginner

List ConfigMaps in the current namespace

kubectl describe configmap <name>intermediate

Show the keys and metadata stored in a ConfigMap

kubectl create configmap my-config --from-literal=key=valuebeginner

Create a ConfigMap from one or more literal key-value pairs

kubectl create configmap my-config --from-file=config.envintermediate

Create a ConfigMap from a local file such as an env file or config artifact

kubectl get secretsbeginner

List secrets in the current namespace

kubectl describe secret <name>intermediate

Inspect secret metadata and available keys without printing decoded values

kubectl create secret generic my-secret --from-literal=password=abcbeginner

Create a generic secret from literal key-value pairs

kubectl create secret docker-registry regcred --docker-server=... --docker-username=... --docker-password=...advanced

Create an image pull secret for a private container registry

kubectl get secret <name> -o jsonpath='{.data.key}' | base64 -dadvanced

Decode a specific secret key value from base64 for troubleshooting

Storage

Inspect persistent volumes, claims, and storage classes backing workloads

8 commands
kubectl get pvbeginner

List cluster-wide persistent volumes and their binding state

kubectl get pvcbeginner

List persistent volume claims in the current namespace

kubectl get pvc -n <namespace>beginner

List persistent volume claims in a specific namespace

kubectl describe pv <name>intermediate

Inspect a persistent volume including reclaim policy, capacity, and claim binding

kubectl describe pvc <name>intermediate

Inspect a claim including requested size, access modes, and mounted workloads

kubectl delete pvc <name>intermediate

Delete a persistent volume claim and release its bound volume according to policy

kubectl get storageclassbeginner

List available storage classes and identify the default provisioner

kubectl describe storageclass <name>intermediate

Inspect provisioner parameters, reclaim policy, and binding mode for a storage class

Troubleshooting

Trace failures, inspect events, and safely manage node maintenance operations

12 commands
kubectl get events --sort-by=.metadata.creationTimestampintermediate

List cluster events in chronological order to surface the newest failures last

kubectl get events -n <ns> --field-selector=reason=Failedintermediate

Filter namespace events down to failure-related entries only

kubectl describe pod <name> | grep -A 10 Eventsadvanced

Extract the events section from a pod description for quick CLI triage

kubectl logs <pod> --since=1hintermediate

Show logs generated within the last hour to narrow noisy output

kubectl logs <pod> --tail=100beginner

Show only the most recent log lines from a pod

kubectl top podsintermediate

View CPU and memory usage for pods in the current namespace

kubectl top pods -n <namespace>intermediate

View CPU and memory usage for pods in a specific namespace

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

List only pods that are still waiting to schedule or start

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

List pods whose last phase is Failed for cleanup or investigation

kubectl drain <node> --ignore-daemonsetsadvanced

Safely evict workloads from a node before maintenance or termination

kubectl cordon <node>advanced

Mark a node unschedulable so new pods are not placed on it

kubectl uncordon <node>advanced

Mark a node schedulable again after maintenance is complete