Skip to content

Commit 0b12f37

Browse files
feat: Added support for ConfigMap reference-based queryables configuration (#360)
1 parent fce645f commit 0b12f37

File tree

10 files changed

+625
-32
lines changed

10 files changed

+625
-32
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
### Added
1313

14+
- Added support for ConfigMap reference-based queryables configuration in addition to file-based queryables. Queryables can now be sourced from external ConfigMaps using `configMapRef`, from chart files using `file`, or a combination of both [#360](https://github.com/developmentseed/eoapi-k8s/pull/360)
15+
1416
## Changed
1517

1618
- Unified scripts and removed Makefile, combined all into one CLI command `eoapi-cli` [#359](https://github.com/developmentseed/eoapi-k8s/pull/359)
@@ -42,7 +44,7 @@ stac:
4244
### Added
4345
4446
- Exposed PgSTAC configuration options in Helm chart values (`pgstacBootstrap.settings.pgstacSettings`). These are dynamically applied via templated SQL during bootstrap. [#340](https://github.com/developmentseed/eoapi-k8s/pull/340)
45-
- Added `queue_timeout`, `use_queue`, and `update_collection_extent` settings for database performance tuning
47+
- Added `queue_timeout`, `use_queue`, and `update_collection_extent` settings for database performance tuning
4648
- Made existing context settings configurable (`context`, `context_estimated_count`, `context_estimated_cost`, `context_stats_ttl`)
4749
- Automatic queue processor CronJob created when `use_queue` is "true" (configurable schedule via `queueProcessor.schedule`)
4850
- Automatic extent updater CronJob created when `update_collection_extent` is "false" (configurable schedule via `extentUpdater.schedule`)

charts/eoapi/initdb-data/queryables/test-queryables.json

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,39 @@
11
{
2-
"$schema": "https://json-schema.org/draft/2019-09/schema",
3-
"$id": "https://stac-extensions.github.io/item-search/v1.0.0/schema.json",
4-
"title": "Test Queryables",
5-
"description": "Test queryables for eoapi",
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "http://localhost/stac/queryables",
4+
"title": "STAC Queryables.",
65
"type": "object",
76
"properties": {
7+
"id": {
8+
"$ref": "https://schemas.stacspec.org/v1.0.0/item-spec/json-schema/item.json#/definitions/core/allOf/2/properties/id",
9+
"title": "Item ID",
10+
"description": "Item identifier"
11+
},
12+
"datetime": {
13+
"type": "string",
14+
"title": "Acquired",
15+
"format": "date-time",
16+
"pattern": "(\\+00:00|Z)$",
17+
"description": "Datetime"
18+
},
19+
"geometry": {
20+
"$ref": "https://geojson.org/schema/Feature.json",
21+
"title": "Item Geometry",
22+
"description": "Item Geometry"
23+
},
24+
"platform": {
25+
"description": "Platform or satellite name",
26+
"type": "string",
27+
"title": "Platform"
28+
},
29+
"instruments": {
30+
"description": "Instrument(s) used",
31+
"type": "array",
32+
"title": "Instruments",
33+
"items": {
34+
"type": "string"
35+
}
36+
},
837
"eo:cloud_cover": {
938
"description": "Estimate of cloud cover as a percentage (0-100) of the entire scene",
1039
"type": "number",
@@ -25,19 +54,6 @@
2554
"title": "Sun Elevation",
2655
"minimum": -90,
2756
"maximum": 90
28-
},
29-
"platform": {
30-
"description": "Platform or satellite name",
31-
"type": "string",
32-
"title": "Platform"
33-
},
34-
"instruments": {
35-
"description": "Instrument(s) used",
36-
"type": "array",
37-
"title": "Instruments",
38-
"items": {
39-
"type": "string"
40-
}
4157
}
4258
},
4359
"additionalProperties": true

charts/eoapi/profiles/experimental.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ pgstacBootstrap:
6868

6969
# Queryables configuration for testing
7070
queryables:
71-
- file: "initdb-data/queryables/test-queryables.json"
71+
- name: test-queryables.json
72+
file: "initdb-data/queryables/test-queryables.json"
7273
indexFields: ["platform", "instruments"]
7374
deleteMissing: true
7475

charts/eoapi/templates/database/pgstacbootstrap/configmap.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ data:
4848
{{- end }}
4949
---
5050
{{- if .Values.pgstacBootstrap.settings.queryables }}
51+
{{- $hasFileBasedQueryables := false }}
52+
{{- range $config := .Values.pgstacBootstrap.settings.queryables }}
53+
{{- if $config.file }}
54+
{{- $hasFileBasedQueryables = true }}
55+
{{- end }}
56+
{{- end }}
57+
{{- if $hasFileBasedQueryables }}
5158
apiVersion: v1
5259
kind: ConfigMap
5360
metadata:
@@ -58,10 +65,12 @@ metadata:
5865
helm.sh/hook-delete-policy: "before-hook-creation,hook-succeeded"
5966
data:
6067
{{- range $config := .Values.pgstacBootstrap.settings.queryables }}
61-
{{- $filename := splitList "/" $config.file | last }}
62-
{{ $filename }}: |
68+
{{- if $config.file }}
69+
{{ $config.name }}: |
6370
{{- $.Files.Get $config.file | nindent 4 }}
6471
{{- end }}
72+
{{- end }}
73+
{{- end }}
6574
{{- end }}
6675
{{- end }}
6776
---

charts/eoapi/templates/database/pgstacbootstrap/job.yaml

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,14 @@ spec:
197197
# Load queryables configurations
198198
echo "Loading queryables configurations..."
199199
{{- range $idx, $config := .Values.pgstacBootstrap.settings.queryables }}
200-
{{- $filename := splitList "/" $config.file | last }}
201-
echo "Processing queryables file: {{ $filename }}"
200+
echo "Processing queryables: {{ $config.name }}"
202201
pypgstac load-queryables \
203202
{{- if $config.deleteMissing }}
204203
--delete-missing \
205204
{{- end }}
206205
{{- if $config.collections }}
207206
# Complex escaping needed due to multiple interpretation layers:
208-
# 1. Helm processes the template: \\\" becomes \" in the rendered YAML
207+
# 1. Helm processes the template: \\\\\" becomes \" in the rendered YAML
209208
# 2. YAML processes the string: \" becomes " in the shell script
210209
# 3. Shell receives: --collection-ids '["collection1","collection2"]'
211210
# 4. pypgstac gets a proper JSON array string as expected
@@ -214,21 +213,48 @@ spec:
214213
{{- if $config.indexFields }}
215214
--index-fields {{ join "," $config.indexFields }} \
216215
{{- end }}
217-
"/opt/queryables/{{ $filename }}"
216+
"/opt/queryables/{{ $config.name }}"
218217
{{- end }}
219218
220219
echo "Queryables loading complete"
221220
resources:
222221
{{- toYaml .Values.pgstacBootstrap.settings.resources | nindent 12 }}
223222
volumeMounts:
224-
- mountPath: /opt/queryables
225-
name: {{ .Release.Name }}-queryables-volume
223+
{{- range $idx, $config := .Values.pgstacBootstrap.settings.queryables }}
224+
{{- if $config.file }}
225+
- mountPath: /opt/queryables/{{ $config.name }}
226+
name: {{ $.Release.Name }}-queryables-volume
227+
subPath: {{ $config.name }}
228+
{{- else if $config.configMapRef }}
229+
- mountPath: /opt/queryables/{{ $config.name }}
230+
name: {{ $.Release.Name }}-queryables-configmapref-{{ $idx }}
231+
subPath: {{ $config.configMapRef.key }}
232+
{{- end }}
233+
{{- end }}
226234
env:
227235
{{- include "eoapi.postgresqlEnv" . | nindent 12 }}
228236
volumes:
237+
{{- $hasFileBasedQueryables := false }}
238+
{{- range $config := .Values.pgstacBootstrap.settings.queryables }}
239+
{{- if $config.file }}
240+
{{- $hasFileBasedQueryables = true }}
241+
{{- end }}
242+
{{- end }}
243+
{{- if $hasFileBasedQueryables }}
229244
- name: {{ .Release.Name }}-queryables-volume
230245
configMap:
231246
name: {{ .Release.Name }}-pgstac-queryables-config
247+
{{- end }}
248+
{{- range $idx, $config := .Values.pgstacBootstrap.settings.queryables }}
249+
{{- if $config.configMapRef }}
250+
- name: {{ $.Release.Name }}-queryables-configmapref-{{ $idx }}
251+
configMap:
252+
name: {{ $config.configMapRef.name }}
253+
items:
254+
- key: {{ $config.configMapRef.key }}
255+
path: {{ $config.configMapRef.key }}
256+
{{- end }}
257+
{{- end }}
232258
{{- with .Values.pgstacBootstrap.settings.affinity }}
233259
affinity:
234260
{{- toYaml . | nindent 8 }}

0 commit comments

Comments
 (0)