THpubs
THpubs

Reputation: 8172

How to pass a deployment's full name to a variable in helm values.yaml?

How to pass the fullname of a dependant chart into another chart in the values.yaml?

My values.yaml looks like this:

##
## 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

In there, I need to pass the name of the postgresql instance to prisma.

If I try to install this, it gives me the following error:

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

Upvotes: 1

Views: 1682

Answers (1)

ozlevka
ozlevka

Reputation: 2156

If your charts looking as:

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

in prisma values.yaml define:

dbhost: defaultdbhost

Then you can define in global values.yaml:

prisma:
  dbhost: mydbhost

And into prisma.yaml use:

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

For understand overriding values read this document

Upvotes: 1

Related Questions