<p>I'm new to kubernetes and I'm following some tutorials here and there. I'm struggling to understand the different components and tools and one of these ones is kustomize. I saw different examples of kustomize usages and I don't understand one of them (even after searching it on the net). So can you explain to me the function of the following <code>kustomize</code> command:</p>

<pre><code>kustomize edit add configmap mnist-map-training --from-literal=trainSteps=200
</code></pre>

<p>Kubernetes is a tool basically that orchestrates docker containers. We create deployments, services, ingresses using yaml and these form the components of the cluster. However, lets say a team has come up with the kubernetes cluster configuration yaml files for development environment. For say, integration environment, the yaml files differ a little. It differs, even more for a production environment. So, the obvious and simple solution is to maintain three copies of yaml files. But it might not work out in the long run. A change applied to one environment may need to be applied in other environments. Missing the changes might cause issues.</p>

<p>Kustomize is a tool that address this issue. You create a <strong>base</strong> copy(as per our example, let's assume its development environment) of kubernetes yaml config files along with the kustomization file. The kustomization file in general, describes the resources(yaml files), configmaps, secrets to create. Then the diff to create the kubernetes cluster configuration in integration and production environments are created as <strong>overlays</strong>. You can use this <a href="https://kubectl.docs.k8s.io/pages/reference/kustomize.html" rel="nofollow noreferrer">link</a> for complete reference, though it is not latest, it might help. In addition there is documentation in <a href="https://github.com/kubernetes-sigs/kustomize/tree/master/examples" rel="nofollow noreferrer">github</a> as well.</p>

<p>Now regarding this command,</p>

<pre class="lang-sh prettyprint-override"><code>kustomize edit add configmap mnist-map-training --from-literal=trainSteps=200
</code></pre>

<p>This command edits the kustomize file in the current directory, to create a snippet like this:</p>

<pre><code>configMapGenerator:
- name: mnist-map-training
  literals:
  - trainSteps=200
</code></pre>

<p>When the <code>kustomize build</code> command is run this creates a configmap yaml like this:</p>

<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: mnist-map-training
data:
  trainSteps: "200"
</code></pre>
