Overleaf Helm 安装失败;在 <.enabled> 处执行“common.controller.ports”:无法评估类型接口 {}

问题描述 投票:0回答:1

我正在尝试使用 helm 在我的 kubernetes 集群中安装 Overleaf,我遇到了这个错误,真的不知道如何继续。

error calling include: template: overleaf/charts/common/templates/lib/controller/_ports.tpl:7:11: executing "common.controller.ports" at <.enabled>: can't evaluate field enabled in type interface {}  

我使用 helm 下载了 helm 图表和文件

_ports.tpl

1.  {{/*
2.   Ports included by the controller.
3.   */}}
4.   {{- define "common.controller.ports" -}}
5.     {{- $ports := list -}}
6.     {{- range .Values.service -}}
7.       {{- if .enabled -}}
8.         {{- range $name, $port := .ports -}}
9.           {{- $_ := set $port "name" $name -}}
10.          {{- $ports = mustAppend $ports $port -}}
11.        {{- end }}
12.      {{- end }}
13.    {{- end }}

我已遵循其values.yaml 文件中提供的内容

    service:
      # -- Enable a service for the code-server add-on.
      enabled: true
      type: ClusterIP
      # Specify the default port information
      ports:
        codeserver:
          port: 12321
          enabled: true
          protocol: TCP
          targetPort: codeserver
          ## Specify the nodePort value for the LoadBalancer and NodePort service types.
          ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport
          ##
          # nodePort:
      annotations: {}
      labels: {}

并在我的 yaml 文件中包含以下内容

  values:
    service:
      enabled: true
      type: ClusterIP

我不明白为什么它仍然说找不到

.Values.service
中启用的值。

kubernetes yaml kubernetes-helm flux overleaf
1个回答
0
投票

在您的 Helm 代码中,您有一个

range
循环
.Values.service

{{- range .Values.service -}}
  {{- if .enabled -}}
    ...
  {{- end }}
{{- end }}

这很可能意味着

service
旨在成为一个列表,而不是单个项目

# at the top level of values.yaml
service:
  - enabled: true
    ports: [...]
  - enabled: false
    ports: [...]

根据您显示的值文件的结构,

service:
本身不是列表,并且您不需要这个
range
循环。 您可以将其更改为
with
语句来重新绑定
.
特殊变量,而不是更改代码

{{- with .Values.service -}}{{/* only change the first word of this line */}}
  {{- if .enabled -}}
    ...

或阐明对特定值的引用。

{{- if .Values.service.enabled -}}
  {{- range $name, $port := .Values.service.ports -}}
    ...

(我觉得我在许多现实世界的图表中看到了第二种形式,重复

.Values.container
,但我自己会写第一种。)

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.