<p>I am currently facing a situation where I need to deploy a small cluster (only 4 pods for now) which will be containing 4 different microservices. This cluster has to be duplicated so I can have one PRODUCTION cluster and one DEVELOPMENT cluster.</p>

<p>Even if it's not hard from my point of view (Creating a cluster and then uploading docker images to pods with parameters in order to use the right resources connection strings), I am stuck at the CD/CI part..</p>

<blockquote>
  <p>From a CloudBuild trigger, how to push the Docker image to the right "cluster's pod", I have absolutely no idea AT ALL how to achieve it...</p>
</blockquote>

<p>There is my cloudbuild.yaml</p>

<pre><code>steps:
  #step 1 - Getting the previous (current) image
  - name: 'gcr.io/cloud-builders/docker'
    entrypoint: 'bash'
    args: [
      '-c',
      'docker pull gcr.io/{PROJECT_ID}/{SERVICE_NAME}:latest || exit 0'
    ]
  #step 2 - Build the image and push it to gcr.io
  - name: 'gcr.io/cloud-builders/docker'
    args: [
      'build',
      '-t',
      'gcr.io/{PROJECT_ID}/{SERVICE_NAME}',
      '-t',
      'gcr.io/{PROJECT_ID}/{SERVICE_NAME}:latest',
      '.'
    ]
  #step 3 - Deploy our container to our cluster
  - name: 'gcr.io/cloud-builders/kubectl'
    args: ['apply', '-f', 'service.yaml', '--force']
    env:
      - 'CLOUDSDK_COMPUTE_ZONE={CLUSTER_ZONE}'
      - 'CLOUDSDK_CONTAINER_CLUSTER={CLUSTER_NAME}'
  #step 4 - Set the image
  - name: 'gcr.io/cloud-builders/kubectl'
    args: [
      'set',
      'image',
      'deployment',
      '{SERVICE_NAME}',
      '{SERVICE_NAME}=gcr.io/{PROJECT_ID}/{SERVICE_NAME}'
    ]
    env:
      - 'CLOUDSDK_COMPUTE_ZONE={CLUSTER_ZONE}'
      - 'CLOUDSDK_CONTAINER_CLUSTER={CLUSTER_NAME}'
# push images to Google Container Registry with tags
images: [
  'gcr.io/{PROJECT_ID}/{SERVICE_NAME}',
  'gcr.io/{PROJECT_ID}/{SERVICE_NAME}:latest'
]
</code></pre>

<p>Can anyone help me out? I don't really know in which direction to go to..</p>

<p>Did you know <a href="https://helm.sh/docs/topics/charts/" rel="nofollow noreferrer">helm chart</a>? It is designed for different environment deployment. </p>

<p>With different <code>values.yaml</code> file, you can quickly deploy to different environment with same source code base.</p>

<p>For example, you can name the values.yaml file with environment.</p>

<pre><code>values-dev.yaml
values-sit.yaml
values-prod.yaml
</code></pre>

<p>the only differences are some varialbes, such as environment (dev/sit/prod), and namespaces. </p>

<p>so when you run the deployment, it will be: </p>

<pre><code>env=${ENVIRONMENT}
helm install -f values-${env}.yaml myredis ./redis
</code></pre>
