我正在使用Rancher pipeline和catalogs来运行Helm Charts:
.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钩子:如果我可以创建一个Job
钩子post-install
和post-upgrade
并等待部署完成,然后我可以阻塞整个管道,直到部署(web服务器)更新。
这个想法可行吗?如果是这样,我怎么写这样的阻塞和检测Job
?
似乎不支持从我能找到他们的代码。看起来它们只是外壳到helm upgrade
,需要使用--wait
模式。