我想将以下CRD放入掌舵图中,但是它包含go raw模板。如何使头盔无法在{{
内翻译}}
和rawTemplate
。感谢您的答复。
https://github.com/kubeflow/katib/blob/master/examples/random-example.yaml
apiVersion: "kubeflow.org/v1alpha1"
kind: StudyJob
metadata:
namespace: katib
labels:
controller-tools.k8s.io: "1.0"
name: random-example
spec:
studyName: random-example
owner: crd
optimizationtype: maximize
objectivevaluename: Validation-accuracy
optimizationgoal: 0.99
requestcount: 4
metricsnames:
- accuracy
workerSpec:
goTemplate:
rawTemplate: |-
apiVersion: batch/v1
kind: Job
metadata:
name: {{.WorkerId}}
namespace: katib
spec:
template:
spec:
containers:
- name: {{.WorkerId}}
image: katib/mxnet-mnist-example
command:
- "python"
- "/mxnet/example/image-classification/train_mnist.py"
- "--batch-size=64"
{{- with .HyperParameters}}
{{- range .}}
- "{{.Name}}={{.Value}}"
{{- end}}
{{- end}}
restartPolicy: Never
答案 0 :(得分:1)
在Go模板语言中,表达式
{{ "{{" }}
将扩展为两个大括号,用于需要使用Go模板语法以Go模板语法生成文档的情况;例如
{{ "{{" }}- if .Values.foo }}
- name: FOO
value: {{ "{{" }} .Values.foo }}
{{ "{{" }}- end }}
(在使用这种语法生成YAML的Kubernetes Helm上下文中,请特别注意如何处理空格;请考虑使用helm template
来转储生成的内容。)