gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-05 02:51:49 27 4
gpt4 key购买 nike

模板中声明了两个范围,第二个范围错误:

Error: render error in "APPLICATION_NAME/templates/server.yaml": template: APPLICATION_NAME/templates/server.yaml:16:17: executing "APPLICATION_NAME/templates/server.yaml" at <.Values.services.def>: can't evaluate field Values in type interface {}

可在此处查看导致错误的范围:

paths:
{{- range $i, $svc := .Values.services.def }}
- path: "{{ $svc.path }}-{{ $x_version }}{{ $endpointPath }}($|(/.*))"
backend:
serviceName: {{ $fullName }}-{{ $svc.name }}
servicePort: {{ $svc.port }}
{{- end }}

这是包含两个范围的模板文件:

{{ if .Values.server.enabled -}}
{{- $fullName := include "generic.fullname" . -}}
{{- $appName := include "generic.name" . -}}
{{- $chartName := include "generic.chart" . -}}
{{- $namespace := .Values.namespace -}}
{{- $releaseName := .Release.Name -}}
{{- $managedbyName := .Release.Service -}}
{{- $dnsSuffix := .Values.dns_suffix -}}
{{- $x_version := .Values.server.x_version -}}
{{- range .Values.server.headerless_endpoints -}}
{{- $endpointPath := . -}}
apiVersion: configuration.konghq.com/v1
kind: ServerPlugin
metadata:
name: "{{ $fullName }}-headerless-endpoint-{{ lower $endpointPath | replace "/" "---" }}-plugin"
namespace: {{ $namespace }}
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: "{{ $fullName }}-server-headerless-{{ lower $endpointPath | replace "/" "---" }}-ingress"
namespace: {{ $namespace }}
labels:
app: {{ $appName }}
helm.sh/chart: {{ $chartName }}
release: {{ $releaseName }}
managed-by: {{ $managedbyName }}
annotations:
kubernetes.io/ingress.class: "server"
external-dns.alpha.kubernetes.io/hostname: ""
plugins.konghq.com: "{{ $fullName }}-headerless-endpoint-{{ lower $endpointPath | replace "/" "---" }}-plugin"
konghq.com/plugins: "{{ $fullName }}-headerless-endpoint-{{ lower $endpointPath | replace "/" "---" }}-plugin"
konghq.com/strip-path: "true"
spec:
rules:
- host: "internal.{{ $dnsSuffix }}"
http:
paths:
{{- range $i, $svc := .Values.services.def }}
- path: "{{ $svc.path }}-{{ $x_version }}{{ $endpointPath }}($|(/.*))"
backend:
serviceName: {{ $fullName }}-{{ $svc.name }}
servicePort: {{ $svc.port }}
{{- end }}
---
{{ end }}
{{- end }}

任何提示或指示将不胜感激。

最佳答案

修复方法是像这样将根标识符 $ 添加到第二个数组中

paths:
{{- range $i, $svc := $.Values.services.def }}
- path: "{{ $svc.path }}-{{ $x_version }}{{ $endpointPath }}($|(/.*))"
backend:
serviceName: {{ $fullName }}-{{ $svc.name }}
servicePort: {{ $svc.port }}
{{- end }}

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

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