<p>I have a running k8s deployment, with one container.</p>
<p>I want to deploy 10 more containers, with a few differences in the deployment manifest (i.e command launched, container name, ...).</p>
<p>Rather than create 10 more .yml files with the whole deployment, I would prefer use templating. What can I do to achieve this ?</p>
<pre><code>---
apiVersion: v1
kind: CronJob
metadata:
  name: myname
  labels:
    app.kubernetes.io/name: myname
spec:
  schedule: &quot;*/10 * * * *&quot;
  jobTemplate:
    spec:
      template:
        metadata:
          labels:
            app.kubernetes.io/name: myname
        spec:
          serviceAccountName: myname
          containers:
            - name: myname
              image: 'mynameimage'
              imagePullPolicy: IfNotPresent
              command: [&quot;/my/command/to/launch&quot;]
          restartPolicy: OnFailure
</code></pre>

Cowboy
<p>You can either specify a set of containers to be created you can do that like this:</p>
<pre class="lang-sh prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: container1
        image: your-image
      - name: container2
        image: your-image
      - name: container3
        image: your-image
</code></pre>
<p>and you can repeat that container definition as many times as you want.</p>
<p>The other way around is to use a templating engine like helm/kustomize as mentioned above.</p>
