0
votes

I am installing postgres as a dependency in my helm chart, and need to retrieve the connection details.

Postgres connection URIs in kubernetes are of the form: postgres://username:[email protected]:port/dbname

The username, password, namespace, port, and dbname are all easily accessible through .Values.postgresql...., and .Release.Namespace, but the service name is initialized using the subchart template common.names.fullname.

Accessing subchart templates is surprisingly not a thing, and probably wouldn't work anyways due to context changes.

What's a simple way to configure my application to access the database?

1

1 Answers

1
votes

I'm usually content to observe that the subchart obeys the typical Helm convention of naming its objects {{ .Release.Name }}-{{ .Chart.Name }}. If the subchart uses that convention, and I'm getting the database from a subchart named postgresql, then I can hard-code that value in my template code:

- name: PGHOST
  value: '{{ .Release.Name }}-postgresql'

My experience has generally been that the Bitnami charts (and the older stable charts) have been pretty good about using semantic versioning, so if this name changes then the major version of the chart will change.