Kubernetes: How One Command Travels
How one command travels is the path from your keyboard to a running container. One kubectl command crosses the control plane and lands on a worker node.
Step one: kubectl sends the request
You type the command. kubectl sends it to the API server. kubectl scale asks for three copies, and lesson 21 teaches scaling in full.
kubectl scale deployment web --replicas=3Step two: the plan is stored
The API server writes the new desired state to etcd. Three copies are now the plan.
kubectl get deploymentsStep three: the scheduler picks nodes
A new pod needs a home. The scheduler picks a node with room for it.
kubectl get pods -o wideStep four: the kubelet starts it
The kubelet on the chosen node pulls the image and starts the container.
kubectl get podsExample
kubectl scale deployment web --replicas=3
kubectl get podsKey points
- kubectl: the command line tool that talks to a cluster.
- Desired state: the plan you declare, such as three copies of an app.
- Actual state: what is really running on the nodes right now.
- The API server takes your command and stores the new desired state in etcd.
- The scheduler picks a node for each pod that has no home yet.
- The kubelet on that node starts the containers.
In this example, the first command asks Kubernetes for three copies of the web app. The output confirms the change. The second command lists the pods. The output shows three running pods. The command has travelled from kubectl through the control plane to the worker node.
Note
Controllers keep watching, so a gap between desired and actual state gets closed.
Try it Yourself
Edit the code, then press Run.
Running is simulated · Rust Playground
Exercise
What happens first when you run a kubectl command?