CI / CD更新多容器吊舱

时间:2019-03-05 18:12:10

标签: docker kubernetes continuous-integration gitlab

我正在尝试通过管道构建多容器POD,并通过Helm Charts发布。

对于单个容器吊舱,我可以做到这一点,将容器的版本和位置传递给头盔图:

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

如果帮助图表是多容器容器,如何传递特定容器的版本或位置?

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



1 个答案:

答案 0 :(得分:1)

这取决于您的掌舵表。之所以可以通过image.tag和image.repository部分,是因为在舵图模板中有一个部分指定了以下内容:

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

Helm模板为deployment.yaml。默认情况下,它将使用该图表一部分的values.yaml文件中指定的任何默认值替换图表中的每个值。每当您运行诸如helm installhelm upgrade --install之类的helm命令并指定--set标志时,都将覆盖values.yaml中指定的默认值。参见docs on helm upgrade for more info on overriding the values in a chart

要回答您的问题:这取决于该图表的定义方式。您经常看到的是,在多容器容器的values.yaml中,您定义了两组图像,例如:

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

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

,然后在图表中通过指定以下内容可以引用这些值:

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

但是,这取决于您在其中指定这些值的特定Helm图表。您可以更新头盔图表吗?还是外部图表?

相关问题