【发布时间】:2019-02-19 18:30:21
【问题描述】:
我正在使用 Jenkins X 并尝试根据我要推广的环境通过 values.yaml 文件设置不同的变量。例如,在将发布从暂存升级到生产时,我希望我的 environment-xxxx-production 存储库中的 values.yaml 文件覆盖我的项目存储库中的值。
根据https://github.com/jenkins-x/jx/issues/1667#issuecomment-420901836 这个评论,这应该只需将变量放在environment-xxxx-production 存储库中即可。
我的项目中的示例deployment.yaml 文件。
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: {{ template "fullname" . }}
labels:
draft: {{ default "draft-app" .Values.draft }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
spec:
replicas: {{ .Values.replicaCount }}
template:
metadata:
labels:
draft: {{ default "draft-app" .Values.draft }}
app: {{ template "fullname" . }}
{{- if .Values.podAnnotations }}
annotations:
{{ toYaml .Values.podAnnotations | indent 8 }}
{{- end }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: {{ .Values.service.internalPort }}
{{/*
Here's the section in question.
*/}}
{{- if .Values.env }}
env:
{{- if .Values.prBranch }}
- name: MY_ENV
value: "some_value"
{{- else }}
{{ toYaml .Values.env | indent 10 }}
{{- end }}
{{- end }}
livenessProbe:
httpGet:
path: {{ .Values.probePath }}
port: {{ .Values.service.internalPort }}
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
successThreshold: {{ .Values.livenessProbe.successThreshold }}
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
readinessProbe:
httpGet:
path: {{ .Values.probePath }}
port: {{ .Values.service.internalPort }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
successThreshold: {{ .Values.readinessProbe.successThreshold }}
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
resources:
{{ toYaml .Values.resources | indent 12 }}
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
示例项目values.yaml 包含以下内容:
env:
- name: MY_ENV
value: "some_staging_value"
样本environment-xxxx-production values.yaml 包含以下内容:
env:
- name: MY_ENV
value: some_production_value
我当然可以让预览和暂存环境变量正常工作。
但是,当我将应用程序推广到生产环境时,env
environment-xxxx-production 中的列表不会覆盖 env
在项目本身的values.yaml 文件中列出。
【问题讨论】:
标签: jenkins kubernetes-helm jenkins-x