diff --git a/.github/workflows/helm-tests.yml b/.github/workflows/helm-tests.yml index 8030925a..2b2c4d3a 100644 --- a/.github/workflows/helm-tests.yml +++ b/.github/workflows/helm-tests.yml @@ -120,6 +120,9 @@ jobs: run: | python -m pip install pytest httpx +# - name: Setup upterm session +# uses: lhotari/action-upterm@v1 + - name: run the tests run: | # first substitute test endpoints in the test files diff --git a/.github/workflows/tests/test_raster.py b/.github/workflows/tests/test_raster.py index 058b6686..a7520e64 100644 --- a/.github/workflows/tests/test_raster.py +++ b/.github/workflows/tests/test_raster.py @@ -6,7 +6,7 @@ timeout = httpx.Timeout(15.0, connect=60.0) client = httpx.Client(timeout=timeout) -raster_endpoint="http://k8s-gcorradi-nginxing-553d3ea33b-3eef2e6e61e5d161.elb.us-west-1.amazonaws.com/raster" +raster_endpoint="http://k8s-eoapi-ingressn-cd16d0ed58-580a04972ec20c3c.elb.us-west-1.amazonaws.com/raster" def test_raster_api(): diff --git a/README.md b/README.md index f8f23e31..913ae6bb 100644 --- a/README.md +++ b/README.md @@ -22,39 +22,13 @@ If you don't have a k8s cluster set up on AWS or GCP then follow an IaC guide be * [AWS EKS Cluster Setup](./docs/aws-eks.md) -* [TBD: GCP GKE Cluster Setup](./docs/gcp-gke.md) +* [GCP GKE Cluster Setup](./docs/gcp-gke.md) ## Helm Installation Once you have a k8s cluster set up you can `helm install` eoAPI as follows -1. `helm install` from this repo's `helm-chart/` folder: - - ```python - ###################################################### - # create os environment variables for required secrets - ###################################################### - $ export GITSHA=$(git rev-parse HEAD | cut -c1-10) - $ export PGUSER=s00pers3cr3t - $ export POSTGRES_USER=s00pers3cr3t - $ export POSTGRES_PASSWORD=superuserfoobar - $ export PGPASSWORD=foobar - - $ cd ./helm-chart - - $ helm install \ - --namespace eoapi \ - --create-namespace \ - --set gitSha=$GITSHA \ - --set db.settings.secrets.PGUSER=$PGUSER \ - --set db.settings.secrets.POSTGRES_USER=$POSTGRES_USER \ - --set db.settings.secrets.PGPASSWORD=$PGPASSWORD \ - --set db.settings.secrets.POSTGRES_PASSWORD=$POSTGRES_PASSWORD \ - eoapi \ - ./eoapi - ``` - -2. or `helm install` from https://devseed.com/eoapi-k8s/: +1. `helm install` from https://devseed.com/eoapi-k8s/: ```python # add the eoapi helm repo locally @@ -80,4 +54,28 @@ Once you have a k8s cluster set up you can `helm install` eoAPI as follows $ helm install -n eoapi --create-namespace eoapi eoapi/eoapi --version 0.1.2 -f config.yaml ``` +2. or `helm install` from this repo's `helm-chart/` folder: + + ```python + ###################################################### + # create os environment variables for required secrets + ###################################################### + $ export GITSHA=$(git rev-parse HEAD | cut -c1-10) + $ export PGUSER=s00pers3cr3t + $ export POSTGRES_USER=s00pers3cr3t + $ export POSTGRES_PASSWORD=superuserfoobar + $ export PGPASSWORD=foobar + + $ cd ./helm-chart + $ helm install \ + --namespace eoapi \ + --create-namespace \ + --set gitSha=$GITSHA \ + --set db.settings.secrets.PGUSER=$PGUSER \ + --set db.settings.secrets.POSTGRES_USER=$POSTGRES_USER \ + --set db.settings.secrets.PGPASSWORD=$PGPASSWORD \ + --set db.settings.secrets.POSTGRES_PASSWORD=$POSTGRES_PASSWORD \ + eoapi \ + ./eoapi + ``` diff --git a/docs/aws-eks.md b/docs/aws-eks.md index 75fd930e..3d329fa3 100644 --- a/docs/aws-eks.md +++ b/docs/aws-eks.md @@ -1,6 +1,6 @@ -# AWS EKS Cluster Walk-through +# AWS EKS Cluster Walkthrough -This walk-through 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`. +This walkthrough 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`. After creating the cluster we'll walk through installing the following add-ons and controllers: * `aws-ebs-csi-driver` @@ -215,8 +215,7 @@ $ helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx $ helm upgrade \ -i ingress-nginx \ ingress-nginx/ingress-nginx \ - --set controller.service.type=LoadBalancer - # these next two annotations are the most important otherwise nginx controller will create an "internal" NLB + --set controller.service.type=LoadBalancer \ --set controller.service.annotations."service\.beta\.kubernetes\.io/aws-load-balancer-type"="nlb" \ --set controller.service.annotations."service\.beta\.kubernetes\.io/aws-load-balancer-scheme"="internet-facing" \ --namespace diff --git a/helm-chart/eoapi/CHANGELOG.md b/helm-chart/eoapi/CHANGELOG.md index 1e120d48..f2ef2921 100644 --- a/helm-chart/eoapi/CHANGELOG.md +++ b/helm-chart/eoapi/CHANGELOG.md @@ -1,5 +1,10 @@ version numbers below correspond to helm chart `appVersion`: see ./helm-chart/eoapi/Chart.yaml --- +# 0.1.2 (2023-08-31) + +* move `command` blocks out to `values.yml` for [generalizing ticket](https://github.com/developmentseed/eoapi-k8s/issues/31) +* add `livenessProbe` for all deployments for [livenessProbe bug](https://github.com/developmentseed/eoapi-k8s/issues/26) + # 0.1.1 (2023-07-21) * For the shared-nginx ingress option [add root path with docs](https://github.com/developmentseed/eoapi-k8s/issues/18) pointing to path rewrites diff --git a/helm-chart/eoapi/Chart.yaml b/helm-chart/eoapi/Chart.yaml index fddfa12f..f23a91f1 100644 --- a/helm-chart/eoapi/Chart.yaml +++ b/helm-chart/eoapi/Chart.yaml @@ -23,4 +23,4 @@ version: "0.1.3" # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "0.1.1" +appVersion: "0.1.2" diff --git a/helm-chart/eoapi/templates/db/deployment.yaml b/helm-chart/eoapi/templates/db/deployment.yaml index bff11541..1735fe9c 100644 --- a/helm-chart/eoapi/templates/db/deployment.yaml +++ b/helm-chart/eoapi/templates/db/deployment.yaml @@ -21,9 +21,7 @@ spec: - name: pgstac image: {{ .Values.db.image.name }}:{{ .Values.db.image.tag }} args: - - "postgres" - - "-N" - - "500" + {{- toYaml .Values.db.command | nindent 12 }} envFrom: - secretRef: name: pgstac-secrets diff --git a/helm-chart/eoapi/templates/services/deployment.yaml b/helm-chart/eoapi/templates/services/deployment.yaml index 3264617b..b93f2633 100644 --- a/helm-chart/eoapi/templates/services/deployment.yaml +++ b/helm-chart/eoapi/templates/services/deployment.yaml @@ -31,19 +31,22 @@ spec: {{- end }} name: {{ $serviceName }} command: - - "uvicorn" - {{ if (eq $serviceName "vector") }} - - "tipg.main:app" - {{- else if (eq $serviceName "raster") }} - - "titiler.pgstac.main:app" - {{- else if (eq $serviceName "stac") }} - - "stac_fastapi.pgstac.app:app" - {{- end }} - - "--host=$(HOST)" - - "--port=$(PORT)" + {{- toYaml (index $v "command") | nindent 10 }} {{- if (and ($.Values.ingress.className) (eq $.Values.ingress.className "nginx")) }} - "--root-path=/{{ $serviceName }}" {{- end }}{{/* needed for proxies and path rewrites on NLB */}} + livenessProbe: + httpGet: + {{- if (eq $serviceName "stac") }} + path: /_mgmt/ping + {{- else }} + path: /healthz + {{- end }} + port: {{ $.Values.service.port }} + failureThreshold: 3 + initialDelaySeconds: 30 + periodSeconds: 15 + successThreshold: 1 ports: - containerPort: {{ $.Values.service.port }} resources: diff --git a/helm-chart/eoapi/values.yaml b/helm-chart/eoapi/values.yaml index 00b3e9d8..85defa06 100644 --- a/helm-chart/eoapi/values.yaml +++ b/helm-chart/eoapi/values.yaml @@ -37,6 +37,10 @@ db: image: name: ghcr.io/stac-utils/pgstac tag: v0.7.1 + command: + - "postgres" + - "-N" + - "500" # toggle to true||false if you want the db test fixtures loaded enable_data_fixtures: true settings: @@ -83,6 +87,11 @@ raster: image: name: ghcr.io/stac-utils/titiler-pgstac tag: uvicorn-0.4.1 + command: + - "uvicorn" + - "titiler.pgstac.main:app" + - "--host=$(HOST)" + - "--port=$(PORT)" settings: timeout: 10 # https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ @@ -120,6 +129,11 @@ stac: image: name: ghcr.io/stac-utils/stac-fastapi-pgstac tag: 2.4.9 + command: + - "uvicorn" + - "stac_fastapi.pgstac.app:app" + - "--host=$(HOST)" + - "--port=$(PORT)" settings: timeout: 10 # https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ @@ -144,6 +158,11 @@ vector: image: name: ghcr.io/developmentseed/tipg tag: uvicorn-0.2.0 + command: + - "uvicorn" + - "tipg.main:app" + - "--host=$(HOST)" + - "--port=$(PORT)" settings: timeout: 10 # https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/