File tree Expand file tree Collapse file tree 8 files changed +60
-3
lines changed
postgrescluster/templates Expand file tree Collapse file tree 8 files changed +60
-3
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616 - Automatic extent updater CronJob created when ` update_collection_extent ` is "false" (configurable schedule via ` extentUpdater.schedule ` )
1717- Added ConfigMap checksum annotations to automatically restart pods when configuration changes [ #344 ] ( https://github.com/developmentseed/eoapi-k8s/pull/344 )
1818- Tests for autoscaling
19+ - Added validation to require ` postgrescluster.enabled: false ` when using external databases [ #346 ] ( https://github.com/developmentseed/eoapi-k8s/pull/346 )
1920
2021### Changed
2122
Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ pgstacBootstrap:
7474| Parameter | Description | Default |
7575|-----------|-------------|---------|
7676| ` postgresql.type` | Database deployment type | `postgrescluster` |
77+ | `postgrescluster.enabled` | Enable PostgreSQL cluster. Must be set to `false` when using external databases | `true` |
7778| `ingress.enabled` | Enable ingress | `true` |
7879| `ingress.className` | Ingress controller class | `nginx` |
7980| `browser.enabled` | Enable STAC Browser interface | `true` |
Original file line number Diff line number Diff line change @@ -315,6 +315,9 @@ Validate PostgreSQL configuration
315315 { {- end } }
316316 { {- include " eoapi.validatePostgresCluster" . } }
317317{ {- else if eq .Values.postgresql.type " external-plaintext" } }
318+ { {- if .Values.postgrescluster.enabled } }
319+ { {- fail " When postgresql.type is 'external-plaintext', postgrescluster.enabled must be set to false" } }
320+ { {- end } }
318321 { {- if not .Values.postgresql.external.host } }
319322 { {- fail " When postgresql.type is 'external-plaintext', postgresql.external.host must be set" } }
320323 { {- end } }
@@ -325,6 +328,9 @@ Validate PostgreSQL configuration
325328 { {- fail " When postgresql.type is 'external-plaintext', postgresql.external.credentials.password must be set" } }
326329 { {- end } }
327330{ {- else if eq .Values.postgresql.type " external-secret" } }
331+ { {- if .Values.postgrescluster.enabled } }
332+ { {- fail " When postgresql.type is 'external-secret', postgrescluster.enabled must be set to false" } }
333+ { {- end } }
328334 { {- if not .Values.postgresql.external.existingSecret.name } }
329335 { {- fail " When postgresql.type is 'external-secret', postgresql.external.existingSecret.name must be set" } }
330336 { {- end } }
Original file line number Diff line number Diff line change 1+ {{/*
2+ This template validates the PostgreSQL configuration.
3+ It doesn't create any resources but ensures configuration consistency.
4+ */}}
5+ {{- include "eoapi.validatePostgresql" . }}
Original file line number Diff line number Diff line change @@ -68,3 +68,41 @@ tests:
6868 secretKeyRef :
6969 name : test-release-pguser-my-user
7070 key : user
71+
72+ - it : should fail when external-plaintext is used with postgrescluster enabled
73+ set :
74+ stac :
75+ enabled : true
76+ postgresql :
77+ type : external-plaintext
78+ external :
79+ host : test-db
80+ credentials :
81+ username : test
82+ password : test
83+ postgrescluster :
84+ enabled : true
85+ template : templates/services/stac/deployment.yaml
86+ asserts :
87+ - failedTemplate :
88+ errorMessage : When postgresql.type is 'external-plaintext', postgrescluster.enabled must be set to false
89+
90+ - it : should fail when external-secret is used with postgrescluster enabled
91+ set :
92+ stac :
93+ enabled : true
94+ postgresql :
95+ type : external-secret
96+ external :
97+ host : test-db
98+ existingSecret :
99+ name : my-secret
100+ keys :
101+ username : user
102+ password : pass
103+ postgrescluster :
104+ enabled : true
105+ template : templates/services/stac/deployment.yaml
106+ asserts :
107+ - failedTemplate :
108+ errorMessage : When postgresql.type is 'external-secret', postgrescluster.enabled must be set to false
Original file line number Diff line number Diff line change 1+ {{- if .Values.enabled }}
12{{- if or .Values.multiBackupRepos .Values.s3 .Values.gcs .Values.azure }}
23apiVersion : v1
34kind : Secret
2223 azure.conf : |-
2324 {{ include "postgres.azure" $args | b64enc }}
2425 {{- end }}
25- {{- end }}
26+ {{- end }}
2627{{- else if .Values.s3 }}
2728 {{- $args := dict "s3" .Values.s3 "index" 0 }}
2829 s3.conf : |-
3940 {{ include "postgres.azure" $args | b64enc }}
4041{{- end }}
4142{{- end }}
43+ {{- end }}
Original file line number Diff line number Diff line change 1+ {{- if .Values.enabled }}
12apiVersion : postgres-operator.crunchydata.com/v1beta1
23kind : PostgresCluster
34metadata :
@@ -227,3 +228,4 @@ spec:
227228 customReplicationTLSSecret :
228229{{ toYaml .Values.customReplicationTLSSecret | indent 4 }}
229230 {{- end }}
231+ {{- end }}
Original file line number Diff line number Diff line change @@ -39,18 +39,20 @@ Using Crunchydata's PostgreSQL Operator (`postgresql.type: "postgrescluster"`):
3939
4040| ** Values Key** | ** Description** | ** Default** | ** Choices** |
4141| :--------------| :----------------| :------------| :------------|
42- | ` postgrescluster.enabled ` | Enable PostgreSQL cluster | true | true/false |
42+ | ` postgrescluster.enabled ` | Enable PostgreSQL cluster. Must be set to ` false ` when using external databases | true | true/false |
4343| ` postgrescluster.name ` | Cluster name | Release name | any valid k8s name |
4444| ` postgrescluster.postgresVersion ` | PostgreSQL version | 16 | supported versions |
4545| ` postgrescluster.postGISVersion ` | PostGIS version | "3.4" | supported versions |
4646
4747### External Database
4848
49- For external databases, set ` postgresql.type ` to either:
49+ For external databases, set ` postgresql.type ` to either ` external-plaintext ` or ` external-secret ` and set ` postgrescluster.enabled: false ` .
5050
5151
52521 . Using plaintext credentials (` external-plaintext ` ):
5353``` yaml
54+ postgrescluster :
55+ enabled : false
5456postgresql :
5557 type : " external-plaintext"
5658 external :
You can’t perform that action at this time.
0 commit comments