如何将部署的全名传递给helm values.yaml中的变量?

时间:2019-03-28 06:53:36

标签: kubernetes kubernetes-helm

如何将依赖图表的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)}

1 个答案:

答案 0 :(得分:1)

如果您的图表显示为:

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

在pyramida values.yaml中定义:

dbhost: defaultdbhost

然后您可以在全局值中定义。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