在 Helm Chart 中,如何在其中的部署完成之前阻止升级?
In a Helm Chart, how can I block the upgrade until a deployment in it is complete?
我正在使用 Rancher 管道和目录来 运行 Helm 图表,如下所示:
.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
...
并且在 chart-web-server
应用程序中,它有一个部署:
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 }}
现在,我需要在部署升级之前阻塞管道,因为我想在以下阶段进行一些服务器测试。
我的想法是使用 Helm hook:如果我可以创建一个 Job
挂钩 post-install
和 post-upgrade
并等待部署完成,我就可以阻止整个管道,直到更新部署(Web 服务器)。
这个想法行得通吗?如果是这样,我怎么写这样的阻塞和检测Job
?
从我能找到的他们的代码来看,似乎不受支持。看起来他们只是 shell 到 helm upgrade
,需要使用 --wait
模式。
我正在使用 Rancher 管道和目录来 运行 Helm 图表,如下所示:
.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
...
并且在 chart-web-server
应用程序中,它有一个部署:
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 }}
现在,我需要在部署升级之前阻塞管道,因为我想在以下阶段进行一些服务器测试。
我的想法是使用 Helm hook:如果我可以创建一个 Job
挂钩 post-install
和 post-upgrade
并等待部署完成,我就可以阻止整个管道,直到更新部署(Web 服务器)。
这个想法行得通吗?如果是这样,我怎么写这样的阻塞和检测Job
?
从我能找到的他们的代码来看,似乎不受支持。看起来他们只是 shell 到 helm upgrade
,需要使用 --wait
模式。