【发布时间】:2020-02-28 03:03:29
【问题描述】:
有没有办法将样板 YAML 从子图表模板移动到父 _helpers.tpl 或 values.yaml ?
掌舵项目
MyHelmApp
│
├── Chart.yaml
├── values.yaml
├── templates
│ ├── _helpers.tpl
│ ├── configmap.yaml
│ └── app-ingress-rules.yaml
│
└── charts
│
├── app1
│ ├── Chart.yaml
│ ├── templates
│ │ ├── _helpers.tpl
│ │ ├── deployment.yaml
│ │ └── service.yaml
│ └── values.yaml
├── app2
│ ├── Chart.yaml
│ ├── templates
│ │ ├── _helpers.tpl
│ │ ├── deployment.yaml
│ │ └── service.yaml
│ └── values.yaml
└── app3
├── Chart.yaml
├── templates
│ ├── _helpers.tpl
│ ├── deployment.yaml
│ └── service.yaml
└── values.yaml
详细说明:我有 3 个应用程序子图表,它们的模板中都有样板 YAML。这些模板中的值在父图表的 values.yaml 中定义,并且变量路径是相同的。例如:
app1、app2 和 app3 deployment.yaml 都包含...
livenessProbe:
httpGet:
path: {{ .Values.health.livenessProbe.path }}
port: {{ .Values.health.livenessProbe.port }}
initialDelaySeconds: {{ .Values.health.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.health.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.health.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.health.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.health.readinessProbe.failureThreshold }}
readinessProbe:
tcpSocket:
port: {{ .Values.health.readinessProbe.port }}
initialDelaySeconds: {{ .Values.health.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.health.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.health.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.health.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.health.readinessProbe.failureThreshold }}
values.yaml(在父图表中)
app1:
health:
livenessProbe:
path: /system_health
port: 8080
initialDelaySeconds: 15
periodSeconds: 20
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 3
readinessProbe:
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 3
app2:
health:
livenessProbe:
path: /system_health
port: 8080
initialDelaySeconds: 15
periodSeconds: 20
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 3
readinessProbe:
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 3
(etc)
回到问题:我想抓取子图表模板中相同的内容并将其移动到一个集中的位置,例如父图表的 _helpers.tpl 或 values.yaml;这可能吗?你能提供一个例子来说明你会如何做到这一点吗?
【问题讨论】:
标签: kubernetes yaml kubernetes-helm