【问题标题】:trable with go-templates helm3go-template helm 3 的问题
【发布时间】:2021-09-15 07:55:26
【问题描述】:

我正在尝试编写我的第一个掌舵图

这就是我的部署 在这部分: containerPort: {{ .Values.port }} ...它的工作 购买不适用于: 值:{{ .Values.port |引用 }} 值:{{ .Value.logs |引用 }} 我不明白为什么......而且错误对我没有任何帮助 请帮忙

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: {{ .Value.logs | quote }}
          livenessProbe:
            httpGet:
              path: /
              port: http
          readinessProbe:
            httpGet:
              path: /
              port: http

这是我的:

values.yaml

port: 8080
logs: "/logs/access.log"

replicaCount: 1

image:
  repository: #
  pullPolicy: IfNotPresent
  # Overrides the image tag whose default is the chart appVersion.
  tag: "develop"

lint 或 helm install 给出错误消息:

gitlab-runner:~$ helm install test ./test --dry-run --debug
install.go:173: [debug] Original chart version: ""
install.go:190: [debug] CHART PATH: /home/gitlab-runner/test

Error: template: test/templates/deployment.yaml:28:28: executing "test/templates/deployment.yaml" at <.Value.logs>: nil pointer evaluating interface {}.logs
helm.go:88: [debug] template: test/templates/deployment.yaml:28:28: executing "test/templates/deployment.yaml" at <.Value.logs>: nil pointer evaluating interface {}.logs


我不明白我做错了什么 我很抱歉我的英语不好^^

【问题讨论】:

  • 你有.Value.logs;它必须是Values,最后是s
  • 真的...天哪:D

标签: kubernetes kubernetes-helm go-templates helm3


【解决方案1】:

计划一

deployment.yaml

        - env:
          - name: PORT
            value: "{{ .Values.port }}"
          - name: LOGS
            value: "{{ .Value.logs }}"

values.yaml

port: 8080
logs: /logs/access.log

计划 2

deployment.yaml

        - env:
          - name: PORT
            value: {{ .Values.port | quote }}
          - name: LOGS
            value: {{ .Value.logs | quote }}

values.yaml

port: 8080
logs: /logs/access.log

【讨论】:

  • 是的.. ^^ 我在第二天解决了这个问题,谢谢你
猜你喜欢
  • 2021-02-28
  • 2020-05-14
  • 2022-01-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-03-31
相关资源
最近更新 更多