【问题标题】:How to pass a deployment's full name to a variable in helm values.yaml?如何将部署的全名传递给 helm values.yaml 中的变量?
【发布时间】:2019-03-28 22:36:51
【问题描述】:

如何将依赖图表的fullname 传递到values.yaml 中的另一个图表中?

我的values.yaml 看起来像这样:

##
## Prisma chart configuration
##
prisma:
  enabled: true
  image:
    pullPolicy: Always
  auth:
    enabled: true
    secret: scret
  database:
    host: {{ template "postgresql.fullname" . }}
    port: 5432
    password: dbpass


##
## Postgreqsl chart configuration
##
postgresql:
  enabled: true
  imagePullPolicy: Always
  postgresqlUsername: prisma
  postgresqlPassword: dbpass
  persistence:
    enabled: true
    storageClass: storage-0

在那里,我需要将postgresql 实例的名称传递给prisma

如果我尝试安装它,它会给我以下错误:

error converting YAML to JSON: yaml: invalid map key: map[interface {}]interface {}{"template \"postgresql.fullname\" .":interface {}(nil)}

【问题讨论】:

标签: kubernetes kubernetes-helm


【解决方案1】:

如果您的图表看起来像:

charts
--- prisma
----- templates
------- prisma.yaml
----- values.yaml
--- postgresql
----- templates
------- postgresql.yaml
----- values.yaml
requirements.yaml
values.yaml

在 prisma values.yaml 中定义:

dbhost: defaultdbhost

然后可以在全局 values.yaml 中定义:

prisma:
  dbhost: mydbhost

并进入 prisma.yaml 使用:

prisma:
  enabled: true
  image:
    pullPolicy: Always
  auth:
    enabled: true
    secret: scret
  database:
    host: {{ .Values.dbhost }}
    port: 5432
    password: dbpass

为了理解覆盖值read this document

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-08
    • 1970-01-01
    • 1970-01-01
    • 2018-06-15
    • 2020-07-07
    • 2022-12-17
    • 2019-09-21
    相关资源
    最近更新 更多