|
1 | 1 | {{- if and .Values.postgrescluster.enabled .Values.pgstacBootstrap.enabled }} |
2 | 2 | --- |
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. |
8 | 5 | apiVersion: batch/v1 |
9 | 6 | kind: Job |
10 | 7 | metadata: |
11 | 8 | name: pgstac-eoapiuser-permissions-upgrade |
12 | 9 | labels: |
13 | 10 | app: pgstac-eoapiuser-permissions-upgrade |
14 | 11 | annotations: |
15 | | - helm.sh/hook: "post-upgrade" |
| 12 | + helm.sh/hook: "post-install,post-upgrade" |
16 | 13 | helm.sh/hook-weight: "-7" |
17 | 14 | helm.sh/hook-delete-policy: "before-hook-creation" |
18 | 15 | spec: |
|
34 | 31 | set -e |
35 | 32 |
|
36 | 33 | # Run permission setup with superuser |
37 | | - echo "Applying superuser permissions for upgrade from version {{ .Values.previousVersion }}..." |
38 | | - PGUSER=postgres psql -f /opt/sql/initdb.sql |
39 | | -
|
| 34 | + echo "Applying elevated permissions" |
| 35 | + PGUSER=postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE \"$PGDATABASE\" TO \"$EOAPI_USER\";" |
40 | 36 | echo "Permissions upgrade complete" |
41 | 37 | resources: |
42 | 38 | {{- toYaml .Values.pgstacBootstrap.settings.resources | nindent 12 }} |
|
49 | 45 | secretKeyRef: |
50 | 46 | name: {{ $.Values.postgrescluster.name | default $.Release.Name }}-pguser-postgres |
51 | 47 | key: user |
| 48 | + - name: EOAPI_USER |
| 49 | + valueFrom: |
| 50 | + secretKeyRef: |
| 51 | + name: {{ $.Values.postgrescluster.name | default $.Release.Name }}-pguser-eoapi |
| 52 | + key: user |
52 | 53 | - name: PGPORT |
53 | 54 | valueFrom: |
54 | 55 | secretKeyRef: |
|
0 commit comments