如何在 Rancher 中通过 questions.yaml 传递哈希值
How to pass hashes over questions.yaml in Rancher
我尝试在 rancher UI 中通过我的 questions.yaml 传递哈希。
这就是我的散列在 values.yaml
中的定义方式
my-app:
ingress:
enabled: true
annotations: {"nginx.ingress.kubernetes.io/whitelist-source-range": "0.0.0.0/0", "kubernetes.io/tls-acme": "true"}
在我的questions.yaml中我定义了这个问题:
- variable: my-app.ingress.annotations
label: Ingress Annotations
type: string
ingress.yaml需要遍历每个元素
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-app
annotations:
kubernetes.io/ingress.class: nginx
{{- with .Values.my-app.ingress.annotations }}
{{ toYaml . | indent 4 }}
{{- end }}
spec:
tls:
- hosts:
我在UI中输入的字符串如下:
{"nginx.ingress.kubernetes.io/whitelist-source-range": "0.0.0.0/0", "kubernetes.io/tls-acme": "true"}
但这会在部署后导致此错误:
Failed to install app my-app. Error: UPGRADE FAILED: YAML parse
error on my-app/templates/ingress.yml: error converting
YAML to JSON: yaml: line 11: did not find expected key
我的猜测是,它被解释为字符串,因此不能迭代。
是否有通过 questions.yaml 传递哈希值的正确方法?
像关注ingress.yaml
一样更新ingress.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-app
annotations:
kubernetes.io/ingress.class: nginx
{{- with .Values.my-app.ingress.annotations }}
{{- toYaml . | nindent 4 }} #<-- change here
{{- end }}
spec:
tls:
- hosts:
{{-
(with the dash and space added) indicates that whitespace should be chomped left,
然后使用nindent
避免手动间距
nindent
is almost identical to indent
, but begins a new line.
我尝试在 rancher UI 中通过我的 questions.yaml 传递哈希。
这就是我的散列在 values.yaml
中的定义方式my-app:
ingress:
enabled: true
annotations: {"nginx.ingress.kubernetes.io/whitelist-source-range": "0.0.0.0/0", "kubernetes.io/tls-acme": "true"}
在我的questions.yaml中我定义了这个问题:
- variable: my-app.ingress.annotations
label: Ingress Annotations
type: string
ingress.yaml需要遍历每个元素
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-app
annotations:
kubernetes.io/ingress.class: nginx
{{- with .Values.my-app.ingress.annotations }}
{{ toYaml . | indent 4 }}
{{- end }}
spec:
tls:
- hosts:
我在UI中输入的字符串如下:
{"nginx.ingress.kubernetes.io/whitelist-source-range": "0.0.0.0/0", "kubernetes.io/tls-acme": "true"}
但这会在部署后导致此错误:
Failed to install app my-app. Error: UPGRADE FAILED: YAML parse error on my-app/templates/ingress.yml: error converting YAML to JSON: yaml: line 11: did not find expected key
我的猜测是,它被解释为字符串,因此不能迭代。
是否有通过 questions.yaml 传递哈希值的正确方法?
像关注ingress.yaml
一样更新ingress.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-app
annotations:
kubernetes.io/ingress.class: nginx
{{- with .Values.my-app.ingress.annotations }}
{{- toYaml . | nindent 4 }} #<-- change here
{{- end }}
spec:
tls:
- hosts:
{{-
(with the dash and space added) indicates that whitespace should be chomped left,
然后使用nindent
避免手动间距
nindent
is almost identical toindent
, but begins a new line.