gpt4 book ai didi

kubernetes-helm - <.Chart.Name> : can't evaluate field Chart in type string

转载 作者:行者123 更新时间:2023-12-04 11:47:36 30 4
gpt4 key购买 nike

当我部署以下内容时,出现此错误:

{{- if .Values.front.ingress.enabled -}}
{{- $fullName := include "marketplace.fullname" . -}}
{{- $ingressPaths := .Values.front.ingress.paths -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ $fullName }}-{{ .Values.environment }}-front
labels:
app.kubernetes.io/name: {{ include "marketplace.name" . }}-{{ .Values.front.name }}
helm.sh/chart: {{ include "marketplace.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}-{{ .Values.front.name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.front.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.front.ingress.tls }}
tls:
{{- range .Values.front.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.front.ingress.hosts }}
- host: {{ . | quote }}
http:
paths:
{{- range $ingressPaths }}
- path: /
backend:
serviceName: {{ include "marketplace.name" . }}-{{ $.Values.front.name }}
servicePort: 3000
{{- end }}
{{- end }}
{{- end }}

错误:
  Error: UPGRADE FAILED: render error in "marketplace/templates/front-ingress.yaml": template: marketplace/templates/front-ingress.yaml:36:30: executing "marketplace/templates/front-ingress.yaml" at <include "marketplace...>: error calling include: template: marketplace/templates/_helpers.tpl:6:18: executing "marketplace.name" at <.Chart.Name>: can't evaluate field Chart in type string
marketplace.name在 _helpers.tpl 中定义:
{{- define "marketplace.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
.Chart.Name是一个内部变量,并解释了优先顺序 here但即使设置 nameOverride错误是一样的。

奇怪的是,如果我删除这个模板, .Chart.Name在任何其他模板中都可以正常工作,所以我认为问题与 range 的范围有关。用过的。

使用的值:
front:
ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: nginx-int
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/force-ssl-redirect: "false"
paths:
- /
hosts:
- myhost.mydomain.cloud
tls: []

最佳答案

请查看 related issue .

基于 this workaround ,您可以存储.在一个变量中,因为在 range 里面循环,.paths:的实际值

你也可能想更换 - path: /- path: {{ . }}

{{- if .Values.front.ingress.enabled -}}
{{- $fullName := include "bchart.fullname" . -}}
{{- $ingressPaths := .Values.front.ingress.paths -}}
{{- $dot := . }}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
...
...
{{- range $ingressPaths }}
- path: {{ . }}
backend:
serviceName: {{ include "bchart.name" $dot }}-{{ $.Values.front.name }}
servicePort: 3000
{{- end }}

关于kubernetes-helm - <.Chart.Name> : can't evaluate field Chart in type string,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54180804/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com