<p>When we fire command <code>Kubectl apply -f &lt;file.yaml&gt;</code>, what happens in background?</p>

Mahesh
<p>In a nutshell, Kubernetes works by having a bunch of &quot;object&quot; or &quot;resource&quot; definitions (like Deployments, ConfigMaps and such), and continuously trying to match the state of the system to these definitions.</p>
<p>For example, if there is a Deployment definition, but there is no pod running for that, K8s will keep trying to spin up such a pod. This might fail due to many reasons - there might not be a node with enough free resources available, the image might not be found, and so on, but as soon as all obstacles are cleared, it will start the pod without further action from you.</p>
<p><code>kubectl apply -f file.yaml</code> then simply reads the content of that file and adds it to its internal store of definitions (where &quot;add&quot; can mean a complex situation if there are overwrites, merges or deletions involved; see the <code>man kubectl-apply</code> documentation for details).</p>
