Skip to content

Commit

Permalink
Complete management of existing secrets for external postgres (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexGacon committed Jan 5, 2024
1 parent ea6afc8 commit 4d33ea1
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 17 deletions.
15 changes: 11 additions & 4 deletions charts/geonode/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,35 @@
{{- define "database_postgres_password_secret_key_ref" -}}
{{- if (index .Values "postgres-operator" "enabled") -}}
"{{ .Values.postgres.username }}.{{ include "postgres_pod_name" . }}.credentials.postgresql.acid.zalan.do"
{{- else if .Values.postgres.external_postgres.enabled -}}
{{- else if and .Values.postgres.external_postgres.enabled (not .Values.postgres.external_postgres.secret.existingSecretName ) -}}
"{{ .Release.Name }}-postgres-external-secrets"
{{- else -}}
"{{.Values.postgres.external_postgres.secret.existingSecretName }}"
{{- end -}}
{{- end -}}

# secret key reference for the password of user: .Values.postgres.geonode_databasename_and_username
{{- define "database_geonode_password_secret_key_ref" -}}
{{- if (index .Values "postgres-operator" "enabled") -}}
"{{ .Values.postgres.geonode_databasename_and_username }}.{{ include "postgres_pod_name" . }}.credentials.postgresql.acid.zalan.do"
{{- else if .Values.postgres.external_postgres.enabled -}}
{{- else if and .Values.postgres.external_postgres.enabled (not .Values.postgres.external_postgres.secret.existingSecretName ) -}}
"{{ .Release.Name }}-geonode-external-secrets"
{{- else -}}
"{{.Values.postgres.external_postgres.secret.existingSecretName }}"
{{- end -}}
{{- end -}}

# secret key reference for the password of user: .Values.postgres.geonode_databasename_and_username
# secret key reference for the password of user: .Values.postgres.geodata_databasename_and_username
{{- define "database_geodata_password_secret_key_ref" -}}
{{- if (index .Values "postgres-operator" "enabled") -}}
"{{ .Values.postgres.geodata_databasename_and_username }}.{{ include "postgres_pod_name" . }}.credentials.postgresql.acid.zalan.do"
{{- else if .Values.postgres.external_postgres.enabled -}}
{{- else if and .Values.postgres.external_postgres.enabled (not .Values.postgres.external_postgres.secret.existingSecretName ) -}}
"{{ .Release.Name }}-geodata-external-secrets"
{{- else -}}
"{{.Values.postgres.external_postgres.secret.existingSecretName }}"
{{- end -}}
{{- end -}}

{{- define "pycsw_pod_name" -}}
{{ .Release.Name }}-{{ .Values.pycsw.pod_name }}
{{- end -}}
Expand Down
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 @@ -100,17 +100,17 @@ spec:
valueFrom:
secretKeyRef:
name: {{ include "database_geonode_password_secret_key_ref" . }}
key: password
key: geonode_password
- name: GEONODE_GEODATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "database_geodata_password_secret_key_ref" . }}
key: password
key: geodata_password
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "database_postgres_password_secret_key_ref" . }}
key: password
key: postgres_password
- name: GEODATABASE_URL
value: "postgis://$(GEONODE_GEODATABASE):$(GEONODE_GEODATABASE_PASSWORD)@$(DATABASE_HOST):$(DATABASE_PORT)/$(GEONODE_GEODATABASE)"
- name: DATABASE_URL
Expand Down Expand Up @@ -207,17 +207,17 @@ spec:
valueFrom:
secretKeyRef:
name: {{ include "database_geonode_password_secret_key_ref" . }}
key: password
key: geonode_password
- name: GEONODE_GEODATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "database_geodata_password_secret_key_ref" . }}
key: password
key: geodata_password
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "database_postgres_password_secret_key_ref" . }}
key: password
key: postgres_password
- name: GEODATABASE_URL
value: "postgis://$(GEONODE_GEODATABASE):$(GEONODE_GEODATABASE_PASSWORD)@$(DATABASE_HOST):$(DATABASE_PORT)/$(GEONODE_GEODATABASE)"
- name: DATABASE_URL
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 @@ -76,7 +76,7 @@ spec:
valueFrom:
secretKeyRef:
name: {{ include "database_geodata_password_secret_key_ref" . }}
key: password
key: geodata_password

volumeMounts:
- name: "{{ include "persistant_volume_name" . }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ metadata:
namespace: {{ .Release.Namespace }}
type: Opaque
data:
username: {{ .Values.postgres.geodata_databasename_and_username | b64enc }}
password: {{ .Values.postgres.external_postgres.secret.geodata_password | b64enc }}
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,6 @@ metadata:
namespace: {{ .Release.Namespace }}
type: Opaque
data:
username: {{ .Values.postgres.username | b64enc }}
password: {{ .Values.postgres.external_postgres.secret.geonode_password | b64enc }}
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,6 @@ metadata:
namespace: {{ .Release.Namespace }}
type: Opaque
data:
username: {{ .Values.postgres.username | b64enc }}
password: {{ .Values.postgres.external_postgres.secret.postgres_password | b64enc }}
postgres_username: {{ .Values.postgres.username | b64enc }}
postgres_password: {{ .Values.postgres.external_postgres.secret.postgres_password | b64enc }}
{{ end }}

0 comments on commit 4d33ea1

Please sign in to comment.