Kubectl Commands
Why kubectl Matters
Imagine Kubernetes as a vast city, with pods as houses, nodes as streets, and clusters as entire districts. To navigate this city, you need a map and a language to communicate with its control tower. That language is kubectl - the command‑line tool that lets you interact with Kubernetes clusters.
kubectl is the gateway to orchestration. Every deployment, scaling operation, or troubleshooting step begins here. Mastering kubectl is like learning the native tongue of Kubernetes.
The Evolution of kubectl
- Early Days (2014): kubectl was introduced alongside Kubernetes, offering basic commands to manage pods and nodes.
- Growth (2016–2019): As Kubernetes matured, kubectl expanded with declarative YAML support, namespaces, and advanced resource management.
- Today: kubectl is the universal interface for Kubernetes, used by developers, DevOps engineers, and SREs worldwide.
Core kubectl Commands
Logs:
kubectl logs <pod-name>
Retrieves logs from a running container.
Describe:
kubectl describe pod <pod-name>
Provides detailed information about a resource.
Deployments:
kubectl get deployments
Lists deployments and their replica counts.
Pods:
kubectl get pods
Shows running pods in the current namespace.
Nodes:
kubectl get nodes
Lists all worker nodes and their status.
Cluster Info:
kubectl cluster-info
Displays the control plane and services running in the cluster.
kubectl commands are the verbs of Kubernetes, telling the cluster what to do and showing you what’s happening.
Global Context
- Enterprises: kubectl is the daily tool for DevOps teams managing production workloads.
- Cloud Providers: Even managed services like EKS, AKS, and GKE rely on kubectl for cluster interaction.
- Community: kubectl plugins and extensions (like
kubectl krew) expand functionality, reflecting Kubernetes’ open‑source spirit.
Hands‑On Exercise
- Reflect: How does kubectl act as the bridge between you and the cluster’s control plane?
Scale it:
kubectl scale deployment hello --replicas=3
kubectl get pods
Deploy a simple app:
kubectl create deployment hello --image=nginx
kubectl get deployments
Run:
kubectl get nodes
kubectl get pods --all-namespaces
The Hacker’s Notebook
- kubectl is the language of Kubernetes - master it, and the cluster listens.
- Core commands are verbs: get, describe, logs, scale.
- Lesson for engineers: Don’t just memorize commands - understand the intent behind them.
- Hacker’s mindset: Treat kubectl as your toolkit. With a few commands, you can deploy, scale, and debug workloads across the globe.
