Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

[timescale-multinode]feat: Add possibility to specify internal ip range #311

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ spec:
echo "*:*:*:postgres:${POSTGRES_PASSWORD_DATA_NODE}" > "${PGDATA}/../.pgpass"
chown postgres:postgres "${PGDATA}/../.pgpass" "${PGDATA}/postgresql_helm_customizations.conf"
chmod 0600 "${PGDATA}/../.pgpass"
{{- if .Values.internalIpRange }}
echo "Adding {{ .Values.internalIpRange }} in pg_hba.conf"
echo "host all all {{ .Values.internalIpRange }} trust" >> ${PGDATA}/pg_hba.conf
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't that be run on pod restarts too?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not think about this case, but you're right, coming from Kubernetes documentation :
"If the Pod restarts, or is restarted, all init containers must execute again." https://kubernetes.io/docs/concepts/workloads/pods/init-containers/

It's also the case for the command executed just above this one. How would you handle it ? Override the whole file instead of just appending this new line ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or I can do the same as it's done here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paulfantom updated according to your comment :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about it a bit more and even with grep this may go sideways.

Let's assume someone is doing an upgrade of the helm chart and changed internalIpRange value. In such a scenario grep would fail and echo would be run again, which in turn would result in pg_hba.conf having old and new configuration options.

For me it look like we have 2 options:

  1. Force full management of pg_hba.conf via ConfigMap. (I am not really a fan of this)
  2. Create line markers and modify only options between line markers.

A bit more explanation on option 2. On the first run of the helm chart, we would add 3 lines, something like:

# START of the section managed by helm chart
host all all {{ .Values.internalIpRange }} trust
# END of the section managed by helm chart

Later in all subsequent runs, we can use grep to look for such a section and edit only the content of this section. This way even if internalIpRange changed on upgrade, helm chart would be able to update it accordingly.

{{- end }}
volumeMounts:
- name: storage-volume
mountPath: "{{ .Values.persistentVolume.mountPath }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ spec:
echo "Writing custom PostgreSQL Parameters to ${PGDATA}/postgresql_helm_customizations.conf"
echo "cluster_name = '$(hostname)'" > "${PGDATA}/postgresql_helm_customizations.conf"
echo "${POSTGRESQL_CUSTOM_PARAMETERS}" | sort >> "${PGDATA}/postgresql_helm_customizations.conf"
{{- if .Values.internalIpRange }}
echo "Adding {{ .Values.internalIpRange }} in pg_hba.conf"
echo "host all all {{ .Values.internalIpRange }} trust" >> ${PGDATA}/pg_hba.conf
{{- end }}
# The TimescaleDB extension should not be available by default, as this interferes with the bootstrapping
# done by the access nodes. Therefore we drop the extensions from template1
echo "DROP EXTENSION timescaledb" | /docker-entrypoint.sh postgres --single -D "${PGDATA}" template1
Expand Down
3 changes: 3 additions & 0 deletions charts/timescaledb-multinode/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,6 @@ serviceAccount:
# The name of the ServiceAccount to use.
# If not set and create is true, a name is generated using the fullname template
name:

# This allows to specify the internal ip range of your cluster to add them to pg_hba.conf
internalIpRange: