Describe in detail what happens after executing the command kubectl apply -f deployment.yaml — in what order and on which cluster components.
sobes.tech AI
Answer from AI
After executing the command kubectl apply -f deployment.yaml, the following process occurs:
-
kubectl reads the
deployment.yamlfile and sends its contents to the Kubernetes API server via REST API. -
The API server receives the request and validates the manifest: checks syntax, schema, and user permissions.
-
If a resource (Deployment) with the same name already exists, the API server compares the current configuration with the new one and applies changes (patch). If not, it creates a new object.
-
The updated Deployment object is saved in etcd — the distributed cluster state storage.
-
The Deployment controller (running in the controller manager) detects changes in the Deployment object through watch on the API server.
-
The Deployment controller creates or updates the corresponding ReplicaSet and manages the number of pods to match the desired state.
-
The ReplicaSet controller creates or deletes pods to maintain the required number of replicas.
-
The Kubelet on nodes receives instructions to launch new pods and runs containers via the container runtime.
-
The state of pods and containers is updated and reflected in the API server, allowing kubectl to display current information.
Thus, the command initiates a chain of interactions between kubectl, the API server, etcd, controllers, and kubelet to bring the cluster state in line with the manifest.