<p>I'm running a deployment in Kubernetes with a ConfigMap, including a set of configuration commands as a script. It works as expected when there's only 1 replica.</p>
<p>Is there a way where I can create a second pod that executes a different set of commands from the first pod?</p>
<p>For example when the first pod is being created, it will execute <code>script-1.sh</code>. But I want to execute a different script (maybe like <code>script-2.sh</code>) in the second pod and so on. Only for the first time pod I need to execute <code>script-1.sh</code>. For the next pods which are created, it should execute <code>script-2.sh</code> not <code>script-1.sh</code>.</p>
<p>Is there a way I can do this?</p>
<pre class="lang-yaml prettyprint-override"><code>volumeMounts:
  - name: config-script
    mountPath: /scripts
volumes:
  - name: config-script
    configMap:
      name: config-script-1
      defaultMode: 0744
</code></pre>

<p>No, you cannot do this with <code>Deployments</code>. A Deployment runs identical replicas of your application and you can't have different pods of same <code>Deployment</code> run different scripts.</p>
