<p>I have a deployment with 2 containers inside a single pod (<strong>container-test2</strong> and <strong>cloudsql-proxy</strong>).</p>

<p><strong>container-test2</strong> runs a docker image which passes ["my_app", "arg1", "arg2"] as CMD. I would like to run several instances of this container with different argument combinations. I would also like to run them in separate pods so that I can distribute them across nodes. I am not entirely sure how to do this.</p>

<p>I can successfully run the two containers but I don't know how to make container-test2 replicate with different arguments and make each container start inside an individual pod.</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: test
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: test
    spec:
      containers:
        - image: gcr.io/testing-11111/testology:latest
          name: container-test2
          command: ["my_app", "arg1", "arg2"]
          env:
            - name: DB_HOST
              # Connect to the SQL proxy over the local network on a fixed port.
              # Change the [PORT] to the port number used by your database
              # (e.g. 3306).
              value: 127.0.0.1:5432
            # These secrets are required to start the pod.
            # [START cloudsql_secrets]
            - name: DB_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: cloudsql-db-credentials
                  key: password
            - name: DB_USER
              valueFrom:
                secretKeyRef:
                  name: cloudsql-db-credentials
                  key: username
            # [END cloudsql_secrets]
          resources:
            requests:
              #memory: "64Mi"
              cpu: 0.1
            limits:
              memory: "375Mi"
              cpu: 0.15


        # Change [INSTANCE_CONNECTION_NAME] here to include your GCP
        # project, the region of your Cloud SQL instance and the name
        # of your Cloud SQL instance. The format is
        # $PROJECT:$REGION:$INSTANCE
        # Insert the port number used by your database.
        # [START proxy_container]
        - image: gcr.io/cloudsql-docker/gce-proxy:1.09
          name: cloudsql-proxy
          command: ["/cloud_sql_proxy", "--dir=/cloudsql",
                    "-instances=testing-11111:europe-west2:testology=tcp:5432",
                    "-credential_file=/secrets/cloudsql/credentials.json"]
          volumeMounts:
            - name: cloudsql-instance-credentials
              mountPath: /secrets/cloudsql
              readOnly: true
            - name: ssl-certs
              mountPath: /etc/ssl/certs
            - name: cloudsql
              mountPath: /cloudsql
        # [END proxy_container]
          resources:
            requests:
              #memory: "64Mi"
              cpu: 0.1
            limits:
              memory: "375Mi"
              cpu: 0.15

      # [START volumes]
      volumes:
        - name: cloudsql-instance-credentials
          secret:
            secretName: cloudsql-instance-credentials
        - name: ssl-certs
          hostPath:
            path: /etc/ssl/certs
        - name: cloudsql
          emptyDir:
      # [END volumes]
</code></pre>

<p>EDIT: Solution</p>

<p>I solved it by creating multiple copies of the deployment config into directory "deployments", amending the names and command and then running:</p>

<blockquote>
  <p>kubectl create -f deployments/</p>
</blockquote>

<ol>
<li><p>You can not make individual replicas run with different arguments, they would not be replicas as in "exact copy". If you want to run your application multiple times with different arguments, you need to use multiple deployments. </p></li>
<li><p>The containers of a replication run in their own Pod, e.g. there should be three Pods existing for a Deployment scaled to three replications</p></li>
</ol>
