diff --git a/.github/workflows/helm-tests.yml b/.github/workflows/helm-tests.yml index 10eef735..745118b5 100644 --- a/.github/workflows/helm-tests.yml +++ b/.github/workflows/helm-tests.yml @@ -40,6 +40,7 @@ jobs: # - helm versions at https://github.com/helm/helm/tags k3s-channel: latest helm-version: v3.8.2 + metrics-enabled: false docker-enabled: true - name: last commit sha if PR @@ -61,42 +62,35 @@ jobs: SALT=$(echo "${RANDOM}${RANDOM}${RANDOM}" | cut -c1-3) echo "RELEASE_NAME=eoapi$COMMITSHA$SALT" >> $GITHUB_ENV + - name: helm install crunchydata postgres operator + run: | + helm upgrade --install --set disable_check_for_upgrades=true pgo oci://registry.developers.crunchydata.com/crunchydata/pgo + - name: helm render/install eoapi templates run: | - export PGUSER=username - export POSTGRES_USER=username - export PGPASSWORD=password - export POSTGRES_PASSWORD=password export GITSHA='${{github.sha}}' cd helm-chart - helm install --set disable_check_for_upgrades=true pgo oci://registry.developers.crunchydata.com/crunchydata/pgo - helm install $RELEASE_NAME \ - --namespace eoapitest \ - --create-namespace \ - --set db.settings.secrets.POSTGRES_HOST=pgstac-$RELEASE_NAME \ - --set db.settings.secrets.POSTGRES_HOST_READER=pgstac-$RELEASE_NAME \ - --set db.settings.secrets.POSTGRES_HOST_WRITER=pgstac-$RELEASE_NAME \ - --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 \ + --namespace default \ -f ./eoapi/values.yaml \ - -f ./eoapi/test-unittest-values.yaml \ + -f ./eoapi/test-k3s-unittest-values.yaml \ ./eoapi - name: sleep for 10s seconds while services boot shell: bash run: sleep 10s +# - name: Setup upterm session +# uses: lhotari/action-upterm@v1 + - id: watchservices name: watch services boot timeout-minutes: 10 continue-on-error: true run: | - kubectl config set-context --current --namespace=eoapitest + kubectl config set-context --current --namespace=default while [[ -z "$(kubectl get pod | grep "^raster-$RELEASE_NAME-.*$" | cut -d' ' -f1 | xargs -I{} kubectl logs pod/{} | grep "GET /.*/healthz" | head -n 1)" ]]; do echo "still waiting for raster service to start..." sleep 1 @@ -124,9 +118,6 @@ jobs: run: | python -m pip install pytest httpx -# - name: Setup upterm session -# uses: lhotari/action-upterm@v1 - - name: run the tests id: testrunner continue-on-error: true @@ -135,7 +126,7 @@ jobs: kubectl get ingress --all-namespaces -o jsonpath='{range .items[0]}kubectl describe ingress {.metadata.name} -n {.metadata.namespace}{end}' | sh kubectl get middleware.traefik.io --all-namespaces -o custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name' --no-headers | while read -r namespace name; do kubectl describe middleware.traefik.io "$name" -n "$namespace"; done - kubectl config set-context --current --namespace=eoapitest + kubectl config set-context --current --namespace=default PUBLICIP='http://'$(kubectl -n kube-system get svc traefik -o jsonpath='{.status.loadBalancer.ingress[0].ip}') echo '#################################' echo vector=$PUBLICIP/vector$RELEASE_NAME @@ -151,9 +142,9 @@ jobs: head -n 5 .github/workflows/tests/test_stac.py pytest .github/workflows/tests/test_stac.py - sed -i "s|raster_endpoint\=.*$|raster_endpoint\='$PUBLICIP/raster$RELEASE_NAME'|g" .github/workflows/tests/test_raster.py - head -n 5 .github/workflows/tests/test_raster.py - pytest .github/workflows/tests/test_raster.py +# sed -i "s|raster_endpoint\=.*$|raster_endpoint\='$PUBLICIP/raster$RELEASE_NAME'|g" .github/workflows/tests/test_raster.py +# head -n 5 .github/workflows/tests/test_raster.py +# pytest .github/workflows/tests/test_raster.py - name: error if tests failed if: steps.testrunner.outcome == 'failure' @@ -222,6 +213,10 @@ jobs: gcloud components install gke-gcloud-auth-plugin gcloud container clusters get-credentials k8seed-labs-cluster --zone us-central1-f + - name: helm install crunchydata postgres operator + run: | + helm upgrade --install --set disable_check_for_upgrades=true pgo oci://registry.developers.crunchydata.com/crunchydata/pgo + - name: helm render/install eoapi templates run: | export GITSHA='${{github.sha}}' @@ -232,13 +227,16 @@ jobs: --namespace $RELEASE_NAME \ --create-namespace \ -f ./eoapi/values.yaml \ - -f ./eoapi/test-unittest-values.yaml \ + -f ./eoapi/test-gcp-unittest-values.yaml \ ./eoapi - name: sleep for 10s seconds while services boot shell: bash run: sleep 10s +# - name: Setup upterm session +# uses: lhotari/action-upterm@v1 + - id: watchservices name: watch services boot timeout-minutes: 10 @@ -276,9 +274,6 @@ jobs: run: | python -m pip install pytest httpx -# - name: Setup upterm session -# uses: lhotari/action-upterm@v1 - - name: run the tests id: testrunner continue-on-error: true diff --git a/helm-chart/eoapi/templates/_helpers.tpl b/helm-chart/eoapi/templates/_helpers.tpl index 52b9aa97..0ef2452c 100644 --- a/helm-chart/eoapi/templates/_helpers.tpl +++ b/helm-chart/eoapi/templates/_helpers.tpl @@ -182,3 +182,13 @@ validate: {{- end -}} +{{/* +validate: +that you can only use traefik as ingress when `testing=true` +*/}} +{{- define "eoapi.validateTraefik" -}} +{{- if and (not .Values.testing) (eq .Values.ingress.className "traefik") $ -}} + {{- fail "you cannot use traefik yet outside of testing" -}} +{{- end -}} + +{{- end -}} \ No newline at end of file diff --git a/helm-chart/eoapi/templates/services/ingress-traefik.yaml b/helm-chart/eoapi/templates/services/ingress-traefik.yaml index 34b54536..d8d88390 100644 --- a/helm-chart/eoapi/templates/services/ingress-traefik.yaml +++ b/helm-chart/eoapi/templates/services/ingress-traefik.yaml @@ -1,3 +1,4 @@ +{{- include "eoapi.validateTraefik" . -}} {{- if and .Values.ingress.enabled (eq .Values.ingress.className "traefik") }} apiVersion: traefik.io/v1alpha1 kind: Middleware @@ -7,7 +8,7 @@ metadata: spec: replacePathRegex: regex: "^/(raster|vector|stac){{ $.Release.Name }}(/|$)(.*)" - replacement: "/$3" + replacement: "$1{{ $.Release.Name }}/$3" {{- end }} --- {{- if (and (.Values.ingress.enabled) (eq .Values.ingress.className "traefik")) }} @@ -43,7 +44,7 @@ spec: {{- if (or (eq $serviceName "raster") (eq $serviceName "stac") (eq $serviceName "vector")) }} {{- if (and (index $v "enabled") (not $.Values.testing)) }} - pathType: Prefix - path: "/{{ $serviceName }}(/|$)(.*)" + path: "/{{ $serviceName }}" backend: service: name: {{ $serviceName }} @@ -51,7 +52,7 @@ spec: number: {{ $.Values.service.port }} {{- else if (and (index $v "enabled") ($.Values.testing)) }} - pathType: Prefix - path: "/{{ $serviceName }}{{ $.Release.Name }}(/|$)(.*)" + path: "/{{ $serviceName }}{{ $.Release.Name }}" backend: service: name: {{ $serviceName }}-{{ $.Release.Name }} diff --git a/helm-chart/eoapi/test-gcp-unittest-values.yaml b/helm-chart/eoapi/test-gcp-unittest-values.yaml new file mode 100644 index 00000000..05b1c6e6 --- /dev/null +++ b/helm-chart/eoapi/test-gcp-unittest-values.yaml @@ -0,0 +1,48 @@ +# used in GH Actions `.github/workflows/helm-tests.yml.jobs.integration-tests` +testing: true +ingress: + enabled: true + className: "nginx" +pgstacBootstrap: + enabled: true + settings: + resources: + requests: + cpu: "256m" + memory: "1024Mi" + limits: + cpu: "512m" + memory: "1024Mi" +raster: + enabled: true + settings: + resources: + limits: + cpu: "768m" + memory: "4096Mi" + requests: + cpu: "256m" + memory: "1024Mi" +stac: + enabled: true + settings: + resources: + limits: + cpu: "1280m" + memory: "1536Mi" + requests: + cpu: "512m" + memory: "1024Mi" +vector: + enabled: true + settings: + resources: + limits: + cpu: "768m" + memory: "1536Mi" + requests: + cpu: "256m" + memory: "1024Mi" + envVars: + # needs to on so we can call /refresh for integration tests + TIPG_DEBUG: "True" diff --git a/helm-chart/eoapi/test-unittest-values.yaml b/helm-chart/eoapi/test-k3s-unittest-values.yaml similarity index 100% rename from helm-chart/eoapi/test-unittest-values.yaml rename to helm-chart/eoapi/test-k3s-unittest-values.yaml