CI/CD update Multicontainer Pod

3/5/2019

I'm trying to build a Multi-container POD via a Pipeline and release via Helm Charts.

For a single container pod I can do this which works, pass the version and the location of the container to the helm chart:

    helm upgrade --install \
   --set image.repository=${CI_REGISTRY}/${ENVIRONMENT,,}/${CI_PROJECT_NAME} \
   --set image.tag=${CI_COMMIT_SHA} \
   ${CI_PROJECT_NAME} \

How do I pass a version or a location for a specific container if the help chart is a multi container pod ?

containers:
        - repo: myrepo/qa/helloworld1
          tag: e2fd70931d264490b2d25012e884897f970f5916
          pullPolicy: Always
          ports:
            container: 8090
          livenessProbe:
            initialDelaySeconds: 6
            tcpSocket:
              port: 8090
          resources:
              requests:
                memory: 128Mi
                cpu: 50m
              limits:
                memory: 128Mi
                cpu: 100m
        - repo: myrepo/qa/helloworld2
          tag: 6bb39948f2a5f926f7968480435ec39a4e07e721
          pullPolicy: Always
          ports:
            container: 8080
          livenessProbe:
            initialDelaySeconds: 6
            tcpSocket:
              port: 8080
          resources:
              requests:
                memory: 128Mi
                cpu: 50m
              limits:
                memory: 128Mi
                cpu: 100m
-- FreshMike
continuous-integration
docker
gitlab
kubernetes

1 Answer

3/5/2019

That depends on your helm chart. The reason you can pass the image.tag and image.repository sections is because inside of the helm chart templates there is a section specifying the following:

containers:
  - image: {{ .Values.image.repository }}/app-name:{{ .Values.image.tag }}

Helm templates a deployment.yaml. By default it replaces each of the Values in a chart with whatever defaults where specified in the values.yaml file that is part of that chart. Whenever you run a helm command such as helm install or helm upgrade --install and specify the --set flag, you are overriding the defaults specified in the values.yaml. See the docs on helm upgrade for more info on overriding the values in a chart.

To answer your question: it depends on how that chart is defined. What you often see is that in the values.yaml of a multi-container pod you define two sets of images, e.g.:

# values.yaml
image1:
  tag: <sha-here>
  repository: <repo-here>

image2:
  tag: <sha-here>
  repository: <repo-here>

and in the chart you can then refer to those values by specifying:

containers:
  - image: {{ .Values.image1.repository }}/app-name:{{ .Values.image1.tag }}

However, it depends on your specific Helm chart where you specify these values. Are you able to update your Helm Chart? Or is it an external Chart?

-- Blokje5
Source: StackOverflow