Skip to content

Commit d0dc7fa

Browse files
feat(pgstac): add support for loading queryables configurations in pgstac bootstrap
1 parent 878a10d commit d0dc7fa

File tree

3 files changed

+109
-0
lines changed

3 files changed

+109
-0
lines changed

charts/eoapi/templates/pgstacbootstrap/configmap.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,23 @@ data:
4646
{{- base $path | nindent 2 -}}: | {{- $.Files.Get $path | nindent 4 -}}
4747
{{- end }}
4848
{{- end }}
49+
---
50+
{{- if .Values.pgstacBootstrap.settings.queryables }}
51+
apiVersion: v1
52+
kind: ConfigMap
53+
metadata:
54+
name: {{ $.Release.Name }}-pgstac-queryables-config
55+
annotations:
56+
helm.sh/hook: "post-install,post-upgrade"
57+
helm.sh/hook-weight: "-7"
58+
helm.sh/hook-delete-policy: "before-hook-creation,hook-succeeded"
59+
data:
60+
{{- range $config := .Values.pgstacBootstrap.settings.queryables }}
61+
{{- $filename := splitList "/" $config.file | last }}
62+
{{ $filename }}: |
63+
{{- $.Files.Get $config.file | nindent 4 }}
64+
{{- end }}
65+
{{- end }}
4966
{{- end }}
5067
---
5168
{{- if .Values.postgrescluster.enabled }}

charts/eoapi/templates/pgstacbootstrap/job.yaml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,81 @@ spec:
156156
{{- end }}
157157
backoffLimit: 3
158158
{{- end }}
159+
160+
{{- if and .Values.pgstacBootstrap.enabled .Values.pgstacBootstrap.settings.queryables }}
161+
---
162+
apiVersion: batch/v1
163+
kind: Job
164+
metadata:
165+
name: {{ .Release.Name }}-pgstac-load-queryables
166+
labels:
167+
app: {{ .Release.Name }}-pgstac-load-queryables
168+
annotations:
169+
helm.sh/hook: "post-install,post-upgrade"
170+
helm.sh/hook-weight: "-3"
171+
helm.sh/hook-delete-policy: "before-hook-creation"
172+
spec:
173+
template:
174+
metadata:
175+
labels:
176+
app: {{ .Release.Name }}-pgstac-load-queryables
177+
spec:
178+
restartPolicy: Never
179+
containers:
180+
- name: pgstac-load-queryables
181+
image: {{ .Values.pgstacBootstrap.image.name }}:{{ .Values.pgstacBootstrap.image.tag }}
182+
command:
183+
- "/bin/sh"
184+
- "-c"
185+
args:
186+
- |
187+
# Exit immediately if a command exits with a non-zero status
188+
set -e
189+
190+
# Database connection configured through standard PG* environment variables
191+
# Environment variables are already set by the container
192+
193+
# Wait for the database to be ready
194+
echo "Waiting for database to be ready..."
195+
pypgstac pgready
196+
197+
# Load queryables configurations
198+
echo "Loading queryables configurations..."
199+
{{- range $idx, $config := .Values.pgstacBootstrap.settings.queryables }}
200+
{{- $filename := splitList "/" $config.file | last }}
201+
echo "Processing queryables file: {{ $filename }}"
202+
pypgstac load-queryables \
203+
{{- if $config.deleteMissing }}
204+
--delete-missing \
205+
{{- end }}
206+
{{- if $config.collections }}
207+
--collection-ids "[\\\"{{ join "\\\",\\\"" $config.collections }}\\\"]" \
208+
{{- end }}
209+
{{- if $config.indexFields }}
210+
--index-fields {{ join "," $config.indexFields }} \
211+
{{- end }}
212+
"/opt/queryables/{{ $filename }}"
213+
{{- end }}
214+
215+
echo "Queryables loading complete"
216+
resources:
217+
{{- toYaml .Values.pgstacBootstrap.settings.resources | nindent 12 }}
218+
volumeMounts:
219+
- mountPath: /opt/queryables
220+
name: {{ .Release.Name }}-queryables-volume
221+
env:
222+
{{- include "eoapi.postgresqlEnv" . | nindent 12 }}
223+
volumes:
224+
- name: {{ .Release.Name }}-queryables-volume
225+
configMap:
226+
name: {{ .Release.Name }}-pgstac-queryables-config
227+
{{- with .Values.pgstacBootstrap.settings.affinity }}
228+
affinity:
229+
{{- toYaml . | nindent 8 }}
230+
{{- end }}
231+
{{- with .Values.pgstacBootstrap.settings.tolerations }}
232+
tolerations:
233+
{{- toYaml . | nindent 8 }}
234+
{{- end }}
235+
backoffLimit: 3
236+
{{- end }}

charts/eoapi/values.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,20 @@ pgstacBootstrap:
163163
# General configuration options
164164
loadSamples: true # Set to false to disable sample data loading
165165

166+
# Queryables configuration
167+
# List of queryables configurations to load using pypgstac load-queryables
168+
# Each item specifies a file path and optional parameters
169+
# Example:
170+
# queryables:
171+
# - file: "initdb-data/queryables/common-queryables.json"
172+
# indexFields: ["id", "datetime", "collection"]
173+
# deleteMissing: true
174+
# - file: "initdb-data/queryables/collection-specific.json"
175+
# collections: ["my-collection-1", "my-collection-2"]
176+
# indexFields: []
177+
# deleteMissing: true
178+
queryables: []
179+
166180
# Wait configuration for init containers waiting for pgstac jobs
167181
# These parameters control how long services wait for pgstac migration jobs to complete
168182
waitConfig:

0 commit comments

Comments
 (0)