gpt4 book ai didi

kubernetes - Helm chart 错误无法评估类型接口(interface) {} 中的字段值

转载 作者:行者123 更新时间:2023-12-03 23:54:10 26 4
gpt4 key购买 nike

我知道这是某种与语法/yaml 结构相关的错误,但消息太神秘了,我不知道问题出在哪里:

Error: render error in "mychart/templates/ingress.yaml": template: mychart/templates/ingress.yaml:35:37: executing "mychart/templates/ingress.yaml" at <.Values.network.appP...>: can't evaluate field Values in type interface {}

这是在我的 values.yaml 中:
network:
appPort: 4141

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

为什么不 {{ .Values.network.appPort }}工作?我在其他地方使用过具有相同结构的值

最佳答案

不就是范围问题吗?

尝试如下

{{- $fullName := include "mychart.fullname" . -}}
{{- $networkAppPort := .Values.network.appPort -}}
...
.... omitted code
...
http:
paths:
{{- range .paths }}
- path: {{ . }}
backend:
serviceName: {{ $fullName }}
servicePort: {{ $networkAppPort }}
{{- end }}
{{- end }}

关于kubernetes - Helm chart 错误无法评估类型接口(interface) {} 中的字段值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56671452/

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