Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: CI
on:
push:
branches:
- main
- '*'
tags:
- '*'
pull_request:
Expand Down
1 change: 1 addition & 0 deletions helm-chart/eoapi/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tmp/
1 change: 1 addition & 0 deletions helm-chart/eoapi/helm-template.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export PGPASSWORD=password
export POSTGRES_PASSWORD=password
export GITSHA=$(git rev-parse HEAD | cut -c1-10)

mkdir -p tmp
MANIFEST=./tmp/eoapi-manfests.yaml

echo "" > $MANIFEST
Expand Down
32 changes: 32 additions & 0 deletions helm-chart/eoapi/templates/db/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: initdb-sql-config
data:
initdb.sql: |
{{- range $path, $bytes := $.Files.Glob "initdb-data/*.sql" -}}
{{ $.Files.Get $path | nindent 4 }}
{{- end }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: initdb-json-config
data:
{{- range $path, $bytes := $.Files.Glob "initdb-data/*.json" -}}
{{- base $path | nindent 2 -}}: | {{- $.Files.Get $path | nindent 4 -}}
{{- end -}}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: initdb-sh-config
data:
load.sh: |
pypgstac pgready --dsn postgresql://username:password@pgstac/postgis
pypgstac load items /opt/initdb/json-data/noaa-eri-nashville2020.json --dsn postgresql://username:password@pgstac/postgis --method insert_ignore
pypgstac load collections /opt/initdb/json-data/noaa-emergency-response.json --dsn postgresql://username:password@pgstac/postgis --method insert_ignore
psql postgresql://username:password@pgstac/postgis -f /opt/initdb/sql-data/initdb.sql
# run it forever like a docker process should
tail -f /dev/null
34 changes: 31 additions & 3 deletions helm-chart/eoapi/templates/db/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,45 @@ spec:
- "-N"
- "500"
envFrom:
# NOTE: there's no reason we need to use a `ConfigMap` or `Secret` here to get os env vars into the pod.
# we could just template them out here immediately with `value: $_` but this allows us
# to store them in k8s intermediately and change them and then bounce deploys if needed
- secretRef:
name: pgstac-secrets
ports:
- containerPort: 5432
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: pgstac-claim
{{- if .Values.db.enable_data_fixtures }}
- name: loader
image: ghcr.io/stac-utils/pgstac:v0.7.1
command:
- "sh"
args:
- "/opt/initdb/load.sh"
envFrom:
- secretRef:
name: pgstac-secrets
ports:
- containerPort: 6543
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: pgstac-claim
- mountPath: /opt/initdb/sql-data
name: initdb-sql-volume
- mountPath: /opt/initdb/json-data
name: initdb-json-volume
- mountPath: /opt/initdb/
name: initdb-sh-volume
{{- end }}
volumes:
- name: pgstac-claim
persistentVolumeClaim:
claimName: pgstac-claim
- name: initdb-sql-volume
configMap:
name: initdb-sql-config
- name: initdb-json-volume
configMap:
name: initdb-json-config
- name: initdb-sh-volume
configMap:
name: initdb-sh-config
2 changes: 1 addition & 1 deletion helm-chart/eoapi/templates/db/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ stringData:
{{- range $envKey, $envValue := .Values.db.settings.secrets }}
{{ upper $envKey }}: "{{ $envValue }}"
{{- /* stac-utils seems to require different environment variable for postgres so handle here via if/else to
avoid having to pass more arg secrets passed */ -}}
avoid having to pass more arg secrets */ -}}
{{- if eq $envKey "PGPASSWORD" }}
POSTGRES_PASS: "{{ $envValue }}"
{{- end }}
Expand Down
41 changes: 41 additions & 0 deletions helm-chart/eoapi/tests/db_deploy_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
suite: db defaults deployment
templates:
- templates/db/deployment.yaml
tests:
- it: "db deploy defaults"
set:
db.enabled: true
db.enable_data_fixtures: false
asserts:
- isKind:
of: Deployment
- matchRegex:
path: metadata.name
pattern: ^pgstac$
- equal:
path: spec.strategy.type
value: "Recreate"
- equal:
path: spec.template.spec.containers[0].name
value: "pgstac"
- isNull:
path: spec.template.spec.containers[1].name
- it: "db deploy with fixtures"
set:
db.enabled: true
db.enable_data_fixtures: true
asserts:
- isKind:
of: Deployment
- matchRegex:
path: metadata.name
pattern: ^pgstac$
- equal:
path: spec.strategy.type
value: "Recreate"
- equal:
path: spec.template.spec.containers[0].name
value: "pgstac"
- equal:
path: spec.template.spec.containers[1].name
value: "loader"
3 changes: 0 additions & 3 deletions helm-chart/eoapi/tests/deploy_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ tests:
raster.enabled: false
stac.enabled: false
vector.enabled: true
gitSha: "ABC123"
asserts:
- isKind:
of: Deployment
Expand Down Expand Up @@ -37,7 +36,6 @@ tests:
raster.enabled: true
stac.enabled: false
vector.enabled: false
gitSha: "ABC123"
asserts:
- isKind:
of: Deployment
Expand Down Expand Up @@ -67,7 +65,6 @@ tests:
raster.enabled: false
stac.enabled: true
vector.enabled: false
gitSha: "ABC123"
asserts:
- isKind:
of: Deployment
Expand Down
Loading