A Kubernetes cluster:
- keeps up-to-date configuration based on what you've sent it
- checks the state of its objects
- compares the state to the configuration, and if there is any difference, changes the objects to match the configuration
Note that the configuration and the objects are distinct things. When you send a configuration for a new Pod to a cluster using kubectl apply
, you're not telling cluster "Create a new Pod". You're telling it to update its internal configuration based on what you've sent it. At some point after you do this, the cluster will run its normal periodic check on the objects and how they compare to the configuration. If there are differences, it'll make changes to the objects.
- The changes might be due to the updates in the configuration that you made with
kubectl apply
. - But they might also be due to something unrelated to anything you've done. For example, the configuration might state that there are to be 3 replicas of a Pod. But due to the failure of one of the cluster's nodes, it finds only 2. It'll then create a third Pod, without any intervention needed from you.