我试图使用 Helm Chart 来实现 Helm Kubernetes 部署。我想使用 helm 发布名称动态给出部署、应用程序和服务名称。
我已经实现了以下方法,它可以帮助我根据 helm 文件创建动态名称。
在_helper.tpl中编写以下方法
{{- define "sample-chart-getServiceName" -}}
{{- $arg1 := index . "arg1" -}}
{{- $fullName := include "sample-chart.fullname" . -}}
{{- printf "%s-%s" $fullName $arg1 -}}
{{- end -}}
Run Code Online (Sandbox Code Playgroud)
以及以下调用 yaml 文件中函数的方法
name: {{ include "sample-chart-getServiceName" (dict "arg1" "service") }}
Run Code Online (Sandbox Code Playgroud)