Skip to content

Commit 174ae83

Browse files
committed
Elevate eoapi db user permissions and rely on pgstac for db migrations.
1 parent 327b911 commit 174ae83

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

helm-chart/eoapi/templates/pgstacbootstrap/eoapiuser-permissions-upgrade.yaml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
{{- if and .Values.postgrescluster.enabled .Values.pgstacBootstrap.enabled }}
22
---
3-
# This job is part of the upgrade process from pre-0.7.0 versions.
4-
# Prior to 0.7.0, database schema updates were run with superuser privileges.
5-
# This job ensures proper permissions are granted to the eoapi user during upgrade.
6-
# TODO: Remove with the next mayor verson and add to documentation that one needs to
7-
# through 0.7.x when upgrading.
3+
# The eoapi database user runs pgstac migrate and needs some elevated object
4+
# level permissions without being a superuser.
85
apiVersion: batch/v1
96
kind: Job
107
metadata:
118
name: pgstac-eoapiuser-permissions-upgrade
129
labels:
1310
app: pgstac-eoapiuser-permissions-upgrade
1411
annotations:
15-
helm.sh/hook: "post-upgrade"
12+
helm.sh/hook: "post-install,post-upgrade"
1613
helm.sh/hook-weight: "-7"
1714
helm.sh/hook-delete-policy: "before-hook-creation"
1815
spec:
@@ -33,11 +30,10 @@ spec:
3330
# Exit immediately if a command exits with a non-zero status
3431
set -e
3532
36-
# Run permission setup with superuser
37-
echo "Applying superuser permissions for upgrade from version {{ .Values.previousVersion }}..."
33+
# Run initial setup with superuser
34+
# - https://stac-utils.github.io/pgstac/pypgstac/#option-2-create-user-with-initial-grants
3835
PGUSER=postgres psql -f /opt/sql/initdb.sql
3936
40-
echo "Permissions upgrade complete"
4137
resources:
4238
{{- toYaml .Values.pgstacBootstrap.settings.resources | nindent 12 }}
4339
volumeMounts:
@@ -49,6 +45,11 @@ spec:
4945
secretKeyRef:
5046
name: {{ $.Values.postgrescluster.name | default $.Release.Name }}-pguser-postgres
5147
key: user
48+
- name: EOAPI_USER
49+
valueFrom:
50+
secretKeyRef:
51+
name: {{ $.Values.postgrescluster.name | default $.Release.Name }}-pguser-eoapi
52+
key: user
5253
- name: PGPORT
5354
valueFrom:
5455
secretKeyRef:

helm-chart/eoapi/values.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,19 @@ comment_db: >
6969
postgresql:
7070
# Management type: "postgrescluster" (default), "external-plaintext", or "external-secret"
7171
type: "postgrescluster"
72-
72+
7373
# Configuration for external PostgreSQL (used when type is "external-plaintext" or "external-secret")
7474
external:
7575
# Connection information
7676
host: ""
7777
port: "5432"
7878
database: "eoapi"
79-
79+
8080
# Credentials configuration (used when type is "external-plaintext")
8181
credentials:
8282
username: ""
8383
password: ""
84-
84+
8585
# Secret reference (used when type is "external-secret")
8686
existingSecret:
8787
name: ""

0 commit comments

Comments
 (0)