【问题标题】:validation error due to "nil" objects when values are passed with --set in HELM在 HELM 中使用 --set 传递值时由于“nil”对象导致的验证错误
【发布时间】:2020-10-01 06:19:37
【问题描述】:

我正在尝试使用helm3 中的--set 传递一个值。但是,看起来 yaml 文件没有提取/解析值。

我的文件夹结构如下:(还有一些其他图表,但为简单起见,我删除了它们)

k8shelmcharts
├── Chart.yaml
└── charts
    ├── postgresdb
    │   ├── Chart.yaml
    │   ├── templates
    │   │   ├── postgres.configmap.yml
    │   │   ├── postgres.deployment.yml
    │   │   ├── postgres.secrets.yml
    │   │   └── postgres.service.yml
    │   └── values.yaml

postgres.secrest.yml 文件的内容是:

apiVersion: v1
kind: Secret
metadata:
  name: postgres-secret
  type: Opaque
data:
  # property-like keys; each key maps to a simple value
  password: {{ .Values.password }}

(我也试过.Values.global.password

当我尝试通过运行命令安装图表时(从 helm 图表的根目录,即:k8shelmcharts 文件夹)helm install testapp . --set password=postgrespasssword --debug --dry-run

我得到错误:

Error: unable to build kubernetes objects from release manifest: error validating "": error validating data: unknown object type "nil" in Secret.data.password
helm.go:94: [debug] error validating "": error validating data: unknown object type "nil" in Secret.data.password

如果我尝试使用helm template testflaskapp . --set password=postgrespassword --debug --dry-run 生成模板,我可以看到postgres.secret.yml 文件中似乎没有填充密码-

# Source: flask-k8s-app/charts/postgresdb/templates/postgres.secret.yml
apiVersion: v1
kind: Secret
metadata:
  name: postgres-secret
data:
  # property-like keys; each key maps to a simple value
  password:

对我缺少的内容有任何帮助,以便我可以--set 值并将它们成功拉入 yaml 文件吗?谢谢!

【问题讨论】:

    标签: kubernetes kubernetes-helm


    【解决方案1】:

    选项 1:

    helm install testapp . --set postgresdb.password=postgrespasssword --debug --dry-run
    

    该变量应称为postgresdb.password,在postgres.secrets.yml 中应保留{{ .Values.password }}

    选项 2

    helm install testapp . --set global.password=postgrespasssword --debug --dry-run
    

    变量应该叫global.password,postgres.secrets.yml 应该改成{{ .Values.global.password }}

    我猜第一个选项更可取,因为您可能仅在 postgresdb 子图表中使用 postgress 密码。

    参考:Subcharts and Global Values

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-31
      • 2010-10-22
      • 1970-01-01
      相关资源
      最近更新 更多