Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fixes #145] Bug: Database connection issue when using postgres-operator #146

Merged
Show file tree
Hide file tree
Changes from all commits
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
30 changes: 29 additions & 1 deletion charts/geonode/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
{{- end -}}



# Database definitions
{{- define "database_hostname" -}}
{{- if (index .Values "postgres-operator" "enabled") -}}
Expand Down Expand Up @@ -76,6 +77,34 @@
{{- end -}}
{{- end -}}

# define password key name in geonode postgres secret
{{- define "database_geonode_password_key_ref" -}}
{{- if (index .Values "postgres-operator" "enabled") -}}
password
{{- else if .Values.postgres.external_postgres.enabled -}}
geonode-password
{{- end -}}
{{- end -}}

# define password key name in geodata postgres secret
{{- define "database_geodata_password_key_ref" -}}
{{- if (index .Values "postgres-operator" "enabled") -}}
password
{{- else if .Values.postgres.external_postgres.enabled -}}
geodata-password
{{- end -}}
{{- end -}}

# define password key name in postgres postgres secret
{{- define "database_postgres_password_key_ref" -}}
{{- if (index .Values "postgres-operator" "enabled") -}}
password
{{- else if .Values.postgres.external_postgres.enabled -}}
postgres-password
{{- end -}}
{{- end -}}


{{- define "pycsw_pod_name" -}}
{{ .Release.Name }}-{{ .Values.pycsw.pod_name }}
{{- end -}}
Expand All @@ -102,4 +131,3 @@ amqp://{{ .Values.rabbitmq.auth.username }}:{{ .Values.rabbitmq.auth.password }}
{{- define "boolean2str" -}}
{{ . | ternary "True" "False" }}
{{- end -}}

12 changes: 6 additions & 6 deletions charts/geonode/templates/geonode/geonode-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,17 @@ spec:
valueFrom:
secretKeyRef:
name: {{ include "database_geonode_password_secret_key_ref" . }}
key: geonode_password
key: password
- name: GEONODE_GEODATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "database_geodata_password_secret_key_ref" . }}
key: geodata_password
key: password
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "database_postgres_password_secret_key_ref" . }}
key: postgres_password
key: password
- name: GEODATABASE_URL
value: "postgis://$(GEONODE_GEODATABASE):$(GEONODE_GEODATABASE_PASSWORD)@$(DATABASE_HOST):$(DATABASE_PORT)/$(GEONODE_GEODATABASE)"
- name: DATABASE_URL
Expand Down Expand Up @@ -212,17 +212,17 @@ spec:
valueFrom:
secretKeyRef:
name: {{ include "database_geonode_password_secret_key_ref" . }}
key: geonode_password
key: {{ include "database_geonode_password_key_ref" . }}
- name: GEONODE_GEODATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "database_geodata_password_secret_key_ref" . }}
key: geodata_password
key: {{ include "database_geodata_password_key_ref" . }}
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "database_postgres_password_secret_key_ref" . }}
key: postgres_password
key: {{ include "database_postgres_password_key_ref" . }}
- name: GEODATABASE_URL
value: "postgis://$(GEONODE_GEODATABASE):$(GEONODE_GEODATABASE_PASSWORD)@$(DATABASE_HOST):$(DATABASE_PORT)/$(GEONODE_GEODATABASE)"
- name: DATABASE_URL
Expand Down
2 changes: 2 additions & 0 deletions charts/geonode/templates/geonode/geonode-env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ data:
DATABASE_HOST: {{ include "database_hostname" . | quote }}
DATABASE_PORT: {{ include "database_port" . | quote }}

# enables ssl encrypted psql connection (required by postgres-operator databases)
PGSSLMODE: "require"
POSTGRES_USER: {{ .Values.postgres.username | quote }}
GEONODE_DATABASE: {{ .Values.postgres.geonode_databasename_and_username | quote }}
GEONODE_GEODATABASE: {{ .Values.postgres.geodata_databasename_and_username | quote }}
Expand Down
2 changes: 1 addition & 1 deletion charts/geonode/templates/geoserver/geoserver-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ spec:
valueFrom:
secretKeyRef:
name: {{ include "database_geodata_password_secret_key_ref" . }}
key: geodata_password
key: {{ include "database_geodata_password_key_ref" . }}

volumeMounts:
- name: "{{ include "persistant_volume_name" . }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ metadata:
namespace: {{ .Release.Namespace }}
type: Opaque
data:
geodata_username: {{ .Values.postgres.geodata_databasename_and_username | b64enc }}
geodata_password: {{ .Values.postgres.external_postgres.secret.geodata_password | b64enc }}
{{ end }}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ metadata:
namespace: {{ .Release.Namespace }}
type: Opaque
data:
geonode_username: {{ .Values.postgres.geonode_databasename_and_username | b64enc }}
geonode_password: {{ .Values.postgres.external_postgres.secret.geonode_password | b64enc }}
{{ end }}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ metadata:
namespace: {{ .Release.Namespace }}
type: Opaque
data:
postgres_username: {{ .Values.postgres.username | b64enc }}
postgres_password: {{ .Values.postgres.external_postgres.secret.postgres_password | b64enc }}
{{ end }}
Loading