You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Helm3首个自定义Chart开发go模板出现nil pointer报错求助

Helm Chart渲染异常问题排查结果

你配置里存在2个明确错误,修改后即可正常运行:

  • 拼写错误:环境变量中获取logs配置的写法为{{ .Value.logs | quote }},Helm内置的全局Values变量为复数形式,缺少末尾的s,正确写法应为{{ .Values.logs | quote }},这也是报错信息nil pointer evaluating interface {}.logs的直接原因。你之前containerPort配置能正常生效,正是因为对应字段使用了正确的{{ .Values.port }}写法。
  • Deployment结构错误:你的containers数组下多写了一个-分隔符,把env、livenessProbe、readinessProbe属性错误定义为第二个容器的配置,这些属性应该和name、image、ports属于同一个容器的同层级配置。

修正后的deployment.yaml完整内容

apiVersion: apps/v1
kind: Deployment
metadata:
  name: test-deployment
  labels:
    app: test
spec:
  replicas: 1
  selector:
    matchLabels:
      app: test
  template:
    metadata:
      labels:
        app: test
    spec:
      containers:
        - name: test
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
          ports:
            - name: http
              containerPort: {{ .Values.port }}
              protocol: TCP
          env:
            - name: PORT
              value: {{ .Values.port | quote }}
            - name: LOGS
              value: {{ .Values.logs | quote }}
          livenessProbe:
            httpGet:
              path: /
              port: http
          readinessProbe:
            httpGet:
              path: /
              port: http

验证步骤

修改完成后先执行helm lint ./test做本地语法校验,无报错后再执行helm install相关命令即可。

内容的提问来源于stack exchange,提问作者Swarovsky

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.03 17:39:04