<p>I am new to kubernete and have a bit confused about <code>apply</code> and <code>rollout</code> command. If I update the kubernete configuration file, should I use <code>kubectl apply -f</code> or <code>kubectl rollout</code>?</p>
<p>if I update kubernete configuration and I run <code>kubectl apply -f</code>, it will terminate the running pod and create a new one.</p>
<p>but <code>rollout</code> also has <code>restart</code> command which is used to restart the pod. so when should I use <code>rollout restart</code>?</p>

<p>One major difference I can think of is <code>kubectl apply</code> can be used for all Kubernetes objects (<code>Pod</code>, <code>Deployment</code>, <code>ConfigMaps</code>, <code>Secrets</code>, etc.) where as the <code>kubectl rollout</code> applies specifically to objects that deals with some computation like <code>Deployments</code>, <code>Statefulsets</code>, etc.</p>
<p>Further, <code>kubectl rollout restart</code> is useful to restart the pods without requiring any changes in the <code>spec</code> fields which is not possible with <code>kubectl apply</code>. If we run <code>kubectl apply</code> with no changes in the <code>spec</code> fields, the pods will not get updated as there is no change to update.</p>
<p>Consider the scenario where some configuration (say, external certificate) is mounted to the pods as <code>ConfigMap</code> and any change in the <code>ConfigMap</code> do not cause the pods to get updated automatically. <code>kubectl rollout restart</code> can be useful in such scenarios to create new pods which can then read updated configurations from the <code>ConfigMap</code>.</p>
<p>Also, a important note from the <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#updating-a-deployment" rel="noreferrer">docs</a>:</p>
<blockquote>
<p>Note: A Deployment's rollout is triggered if and only if the
Deployment's Pod template (that is, .spec.template) is changed, for
example if the labels or container images of the template are updated.
Other updates, such as scaling the Deployment, do not trigger a
rollout.</p>
</blockquote>
