The kubectl Command
kubectl is the command-line tool you use to talk to a Kubernetes cluster.
kubectl <verb> <resource> [name] [flags]kubectl (pronounced "kube-control" or "kube-cuttle") is how you send instructions to the cluster's API server. Almost every action — creating, viewing, updating, deleting — goes through it.
The common shape of a command
Most commands follow the pattern kubectl VERB RESOURCE NAME:
kubectl get pods— list Pods.kubectl describe pod my-pod— show full details.kubectl delete pod my-pod— remove a Pod.kubectl apply -f file.yaml— create/update from a file.kubectl logs my-pod— read a container's logs.
Useful shortcuts
Add -o wide for more columns, -o yaml to see the full object, and -n NAMESPACE to target a namespace. Use -A to look across all namespaces.
Example
# See everything in the current namespace
kubectl get all
# Detailed, human-readable view of one Pod
kubectl describe pod my-app
# Stream live logs from a Pod
kubectl logs -f my-app
# Run a one-off command inside a running container
kubectl exec -it my-app -- /bin/shWhen to use it
- A developer uses kubectl logs to tail output from a crashing production pod and identify the exception causing the crash.
- An SRE uses kubectl exec to open an interactive shell inside a running container and inspect live environment variables.
- A CI/CD pipeline uses kubectl apply in the deploy stage to update a Deployment image tag to the newly built version.
More examples
Get resources across types
Shows the most common kubectl get commands for listing pods, deployments, services, and all resources in a namespace.
kubectl get pods
kubectl get deployments
kubectl get services
kubectl get all -n defaultApply and delete manifests
Demonstrates declarative management: apply converges the cluster state to the file spec, delete removes those same resources.
# Create or update from a YAML file
kubectl apply -f deployment.yaml
# Remove resources declared in the same file
kubectl delete -f deployment.yamlDebug with describe, logs, exec
Chains three diagnostic commands: inspect events, tail recent logs, and open an interactive shell inside the pod.
kubectl describe pod my-pod
kubectl logs my-pod --tail=50
kubectl exec -it my-pod -- /bin/sh
Discussion