简体   繁体   中英

In a Helm Chart, how can I block the upgrade until a deployment in it is complete?

I am using Rancher Pipelines and catalogs to run Helm Charts like this:

.rancher-pipeline.yml

stages:
- name: Deploy app-web
  steps:
  - applyAppConfig:
      catalogTemplate: cattle-global-data:chart-web-server
      version: 0.4.0
      name: ${CICD_GIT_REPO_NAME}-${CICD_GIT_BRANCH}-serv
      targetNamespace: ${CICD_GIT_REPO_NAME}
      answers:
        pipeline.sequence: ${CICD_EXECUTION_SEQUENCE}
        ...

- name: Another chart needs to wait until the previous one success
  ...

And in the chart-web-server app, it has a deployment:

deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ .Release.Name }}-dpy
  labels:
    {{- include "labels" . | nindent 4 }}
spec:
  replicas: 1
  selector:
    matchLabels:
      app: {{ .Release.Name }}
      {{- include "labels" . | nindent 6 }}
  template:
    metadata:
      labels:
        app: {{ .Release.Name }}
        {{- include "labels" . | nindent 8 }}
    spec:
      containers:
        - name: "web-server-{{ include "numericSafe" .Values.git.commitID }}"
          image: "{{ .Values.harbor.host }}/{{ .Values.web.imageTag }}"
          imagePullPolicy: Always
          env:
            ...
          ports:
            - containerPort: {{ .Values.web.port }}
              protocol: TCP
          resources:
            {{- .Values.resources | toYaml | nindent 12 }}

Now, I need the pipeline to be blocked until the deployment is upgraded since I want to do some server testing in the following stages.

My idea is to use Helm hook: If I can create a Job hooking post-install and post-upgrade and waiting for the deployment to be completed, I can then block the whole pipeline until the deployment (a web server) is updated.

Does this idea work? If so, how can I write such a blocking and detecting Job ?

Does not appear to be supported from what I can find of their code. It would appear they just shell out to helm upgrade , would need to use the --wait mode.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM