<p><code>kubectl apply &lt;file.yaml&gt; --save-config</code> creates or updates a deployment and saves the deployment as metadata.</p>
<p>In the documentation it says</p>
<blockquote>
<p>--save-config[=false]: If true, the configuration of current object will be saved in its annotation. This is useful when you want to perform kubectl apply on this object in the future.</p>
</blockquote>
<p>Why do I need <code>save-config</code>? I can still update my deployment using <code>kubectl apply</code> if I do not <code>--save-config</code>.</p>

User12547645
<h2>kubectl apply</h2>
<p><code>kubectl apply</code> use the data in an annotation <code>kubectl.kubernetes.io/last-applied-configuration</code> to see e.g. if any fields has been removed since the last apply. This is needed because some fields or annotations may have been added live in the cluster by e.g. a controller or mutating webhook.</p>
<p>See e.g. <a href="https://luispreciado.blog/posts/kubernetes/core-concepts/kubectl-apply" rel="noreferrer">Understanding the Kubectl Apply Command</a></p>
<blockquote>
<p>I can still update my deployment using kubectl apply if I do not --save-config</p>
</blockquote>
<p>Yes, <code>--save-config</code> is only used when migrating from an <em>imperative</em> workflow. See more details below. The following <code>kubectl apply</code> commands does not need <code>--save-config</code> flag because the annotation is already there.</p>
<h2>Workflows with kubectl</h2>
<p>When working with configurations for Kubernetes, this can be done in multiple ways, they are both <em>imperative</em> or <em>declarative</em>:</p>
<ul>
<li><a href="https://kubernetes.io/docs/tasks/manage-kubernetes-objects/imperative-command/" rel="noreferrer">Managing Kubernetes Objects Using Imperative Commands</a></li>
<li><a href="https://kubernetes.io/docs/tasks/manage-kubernetes-objects/imperative-config/" rel="noreferrer">Imperative Management of Kubernetes Objects Using Configuration Files</a></li>
<li><a href="https://kubernetes.io/docs/tasks/manage-kubernetes-objects/declarative-config/" rel="noreferrer">Declarative Management of Kubernetes Objects Using Configuration Files</a></li>
</ul>
<p><code>kubectl apply</code> is used for <em>declarative</em> configuration management.</p>
<h2>Migrating from imperative to declarative config mangement</h2>
<p>Using <code>kubectl</code> with the <code>--save-config</code> flag is a way to write config to the annotation <code>kubectl.kubernetes.io/last-applied-configuration</code> that <code>kubectl apply</code> uses. This is useful when migrating from an <em>imperative</em>  to an <em>declarative</em> workflow.</p>
<ul>
<li><a href="https://kubernetes.io/docs/tasks/manage-kubernetes-objects/declarative-config/#migrating-from-imperative-command-management-to-declarative-object-configuration" rel="noreferrer">Migrating from imperative command management to declarative object configuration</a></li>
<li><a href="https://kubernetes.io/docs/tasks/manage-kubernetes-objects/declarative-config/#migrating-from-imperative-object-configuration-to-declarative-object-configuration" rel="noreferrer">Migrating from imperative object configuration to declarative object configuration</a></li>
</ul>
