diff --git a/.github/workflows/helm-tests.yml b/.github/workflows/helm-tests.yml index e47df4d7..f04595c7 100644 --- a/.github/workflows/helm-tests.yml +++ b/.github/workflows/helm-tests.yml @@ -116,7 +116,7 @@ jobs: sleep 1 done echo "all services have started, moving on..." - + - name: cleanup if services fail to boot if: steps.watchservices.outcome == 'failure' run: | @@ -163,164 +163,3 @@ jobs: - name: helm uninstall eoapi templates run: | helm uninstall $RELEASE_NAME - - gcp-integration-tests: - # run on: - # - a PR was just labeled 'test-integration-gcp' - # - a PR was just labeled 'test-integration' - # - a PR with 'test-integration' label was opened, reopened, or synchronized - if: | - github.event.label.name == 'test-integration-gcp' || - contains( github.event.pull_request.labels.*.name, 'test-integration-gcp') - permissions: - contents: 'read' - id-token: 'write' - needs: helm-tests - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - uses: azure/setup-helm@v4 - with: - version: ${{ env.HELM_VERSION }} - #token: ${{ secrets.GITHUB_TOKEN }} - - - name: last commit sha if PR - if: ${{ github.event_name == 'pull_request' }} - shell: bash - run: | - echo "LAST_COMMIT_SHA=${{ github.event.pull_request.head.sha }}" >> ${GITHUB_ENV} - - - name: last commit sha if push - if: ${{ github.event_name == 'push' }} - shell: bash - run: | - echo "LAST_COMMIT_SHA=${GITHUB_SHA}" >> ${GITHUB_ENV} - - - name: set k8s .release.name suffix - run: | - # salt for randomness per test run - COMMITSHA=$(echo $LAST_COMMIT_SHA | cut -c 1-6) - SALT=$(echo "${RANDOM}${RANDOM}${RANDOM}" | cut -c1-3) - echo "RELEASE_NAME=eoapi$COMMITSHA$SALT" >> $GITHUB_ENV - - - id: 'auth' - uses: 'google-github-actions/auth@v2' - with: - service_account: 'k8seed-deploy@devseed-labs.iam.gserviceaccount.com' - credentials_json: ${{ secrets.GH_ACTIONS_SA_JSON }} - - - name: setup gcloud sdk - uses: google-github-actions/setup-gcloud@v2 - with: - version: '>= 363.0.0' - project_id: 'devseed-labs' - - - name: configure kubectl context - run: | - 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 \ - --version ${{ env.PGO_VERSION }} - - - name: helm render/install eoapi templates - run: | - HOST='${{ env.RELEASE_NAME }}.k8s.labs.ds.io' - echo $HOST - - cd helm-chart - - helm dependency build eoapi - - helm install $RELEASE_NAME \ - --namespace $RELEASE_NAME \ - --create-namespace \ - --set ingress.host=$HOST \ - -f ./eoapi/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 - continue-on-error: true - run: | - kubectl config set-context --current --namespace=$RELEASE_NAME - 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 - done - echo "raster service has started, moving on..." - while [[ -z "$(kubectl get pod | grep "^vector-$RELEASE_NAME-.*$" | cut -d' ' -f1 | xargs -I{} kubectl logs pod/{} | grep "GET /healthz" | head -n 1)" ]]; do - echo "still waiting for vector service to start..." - sleep 1 - done - echo "vector service has started, moving on..." - while [[ -z "$(kubectl get pod | grep "^stac-$RELEASE_NAME-.*$" | cut -d' ' -f1 | xargs -I{} kubectl logs pod/{} | grep "GET /_mgmt/ping" | head -n 1)" ]]; do - echo "still waiting for stac service to start..." - sleep 1 - done - echo "all services have started, moving on..." - - - name: cleanup if services fail to boot - if: steps.watchservices.outcome == 'failure' - run: | - echo "The previous step failed or timed out. Running cleanup logic..." - helm uninstall $RELEASE_NAME - - kubectl delete ns/$RELEASE_NAME - - # force GH action to show failed result - exit 128 - - - name: install python unit-test dependencies - run: | - python -m pip install pytest httpx - - - name: run the tests - id: testrunner - continue-on-error: true - run: | - kubectl config set-context --current --namespace=$RELEASE_NAME - PUBLICIP='https://${{ env.RELEASE_NAME }}.k8s.labs.ds.io' - export VECTOR_ENDPOINT=$PUBLICIP/vector$RELEASE_NAME - export STAC_ENDPOINT=$PUBLICIP/stac$RELEASE_NAME - export RASTER_ENDPOINT=$PUBLICIP/raster$RELEASE_NAME - - echo '#################################' - echo $VECTOR_ENDPOINT - echo $STAC_ENDPOINT - echo $RASTER_ENDPOINT - echo '#################################' - - pytest .github/workflows/tests/test_vector.py - pytest .github/workflows/tests/test_stac.py - # TODO: fix raster tests - #pytest .github/workflows/tests/test_raster.py - - - name: cleanup if tests fail - if: steps.testrunner.outcome == 'failure' - run: | - echo "The previous step failed or timed out. Running cleanup logic..." - helm uninstall $RELEASE_NAME - kubectl delete ns/$RELEASE_NAME - # force GH action to show failed result - exit 128 - - - name: helm uninstall eoapi templates - run: | - helm uninstall $RELEASE_NAME - kubectl delete ns/$RELEASE_NAME diff --git a/helm-chart/eoapi/templates/_helpers.tpl b/helm-chart/eoapi/templates/_helpers.tpl index a17a8589..d419ec61 100644 --- a/helm-chart/eoapi/templates/_helpers.tpl +++ b/helm-chart/eoapi/templates/_helpers.tpl @@ -61,30 +61,6 @@ Create the name of the service account to use {{- end }} {{- end }} -{{/* -Create pgstac host string depending if .Values.testing -*/}} -{{- define "eoapi.pgstacTempDbHostName" -}} -{{- if .Values.testing }} -{{- printf "%s-%s" "pgstac" .Release.Name }} -{{- else }} -{{/* need to match what is default in values.yamls */}} -{{- printf "%s" "pgstac" }} -{{- end }} -{{- end }} - -{{/* -Create pgstac host string depending if .Values.testing -*/}} -{{- define "eoapi.pgstacHostName" -}} -{{- if .Values.testing }} -{{- printf "%s-%s" "pgstacbootstrap" .Release.Name }} -{{- else }} -{{/* need to match what is default in values.yamls */}} -{{- printf "%s" "pgstacbootstrap" }} -{{- end }} -{{- end }} - {{/* Secrets for postgres/postgis access have to be derived from what the crunchydata operator creates diff --git a/helm-chart/eoapi/templates/db/deployment.yaml b/helm-chart/eoapi/templates/db/deployment.yaml index 788e0922..12f3e708 100644 --- a/helm-chart/eoapi/templates/db/deployment.yaml +++ b/helm-chart/eoapi/templates/db/deployment.yaml @@ -3,19 +3,19 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: {{ include "eoapi.pgstacTempDbHostName" . | nindent 8 }} + name: pgstac labels: - app: {{ include "eoapi.pgstacTempDbHostName" . | nindent 10 }} + app: pgstac spec: selector: matchLabels: - app: {{ include "eoapi.pgstacTempDbHostName" . | nindent 12 }} + app: pgstac strategy: type: Recreate template: metadata: labels: - app: {{ include "eoapi.pgstacTempDbHostName" . | nindent 14 }} + app: pgstac spec: restartPolicy: Always containers: @@ -73,4 +73,4 @@ spec: - name: initdb-sh-volume-{{ $.Release.Name }} configMap: name: initdb-sh-config-{{ $.Release.Name }} -{{- end }} \ No newline at end of file +{{- end }} diff --git a/helm-chart/eoapi/templates/db/service.yaml b/helm-chart/eoapi/templates/db/service.yaml index 0ff5dfe6..af8bcb42 100644 --- a/helm-chart/eoapi/templates/db/service.yaml +++ b/helm-chart/eoapi/templates/db/service.yaml @@ -4,13 +4,13 @@ apiVersion: v1 kind: Service metadata: labels: - app: {{ include "eoapi.pgstacTempDbHostName" . | nindent 10 }} - name: {{ include "eoapi.pgstacTempDbHostName" . | nindent 8 }} + app: pgstac + name: pgstac spec: ports: - name: "5432" port: 5432 targetPort: 5432 selector: - app: {{ include "eoapi.pgstacTempDbHostName" . | nindent 10 }} -{{- end }} \ No newline at end of file + app: pgstac +{{- end }} diff --git a/helm-chart/eoapi/templates/pgstacboostrap/job.yaml b/helm-chart/eoapi/templates/pgstacboostrap/job.yaml index f70927ce..ddc096e2 100644 --- a/helm-chart/eoapi/templates/pgstacboostrap/job.yaml +++ b/helm-chart/eoapi/templates/pgstacboostrap/job.yaml @@ -3,14 +3,14 @@ apiVersion: batch/v1 kind: Job metadata: - name: {{ include "eoapi.pgstacHostName" . | nindent 8 }} + name: pgstacbootstrap labels: - app: {{ include "eoapi.pgstacHostName" . | nindent 10 }} + app: pgstacbootstrap spec: template: metadata: labels: - app: {{ include "eoapi.pgstacHostName" . | nindent 14 }} + app: pgstacbootstrap spec: restartPolicy: Never containers: diff --git a/helm-chart/eoapi/templates/services/ingress-nginx.yaml b/helm-chart/eoapi/templates/services/ingress-nginx.yaml index b4243552..a3e8e3e0 100644 --- a/helm-chart/eoapi/templates/services/ingress-nginx.yaml +++ b/helm-chart/eoapi/templates/services/ingress-nginx.yaml @@ -32,7 +32,7 @@ spec: paths: {{- range $serviceName, $v := .Values }} {{- if has $serviceName $.Values.apiServices }} - {{- if (and (index $v "enabled") (not $.Values.testing)) }} + {{- if (index $v "enabled") }} - pathType: Prefix path: "/{{ $serviceName }}(/|$)(.*)" backend: @@ -40,14 +40,6 @@ spec: name: {{ $serviceName }} port: number: {{ $.Values.service.port }} - {{- else if (and (index $v "enabled") ($.Values.testing)) }} - - pathType: Prefix - path: "/{{ $serviceName }}{{ $.Release.Name }}(/|$)(.*)" - backend: - service: - name: {{ $serviceName }}-{{ $.Release.Name }} - port: - number: {{ $.Values.service.port }} {{- end }}{{/* END: if index $v "enabled" */}} {{- end }}{{/* END: if has $serviceName $.Values.apiServices */}} {{- end }}{{/* END: range $serviceName, $v := .Values*/}} diff --git a/helm-chart/eoapi/templates/services/ingress-traefik.yaml b/helm-chart/eoapi/templates/services/ingress-traefik.yaml index f144f7a5..26de5b8e 100644 --- a/helm-chart/eoapi/templates/services/ingress-traefik.yaml +++ b/helm-chart/eoapi/templates/services/ingress-traefik.yaml @@ -42,7 +42,7 @@ spec: paths: {{- range $serviceName, $v := .Values }} {{- if has $serviceName $.Values.apiServices }} - {{- if (and (index $v "enabled") (not $.Values.testing)) }} + {{- if (index $v "enabled") }} - pathType: Prefix path: "/{{ $serviceName }}" backend: @@ -50,14 +50,6 @@ spec: name: {{ $serviceName }} port: number: {{ $.Values.service.port }} - {{- else if (and (index $v "enabled") ($.Values.testing)) }} - - pathType: Prefix - path: "/{{ $serviceName }}{{ $.Release.Name }}" - backend: - service: - name: {{ $serviceName }}-{{ $.Release.Name }} - port: - number: {{ $.Values.service.port }} {{- end }}{{/* END: if index $v "enabled" */}} {{- end }}{{/* END: if has $serviceName $.Values.apiServices */}} {{- end }}{{/* END: range $serviceName, $v := .Values*/}} diff --git a/helm-chart/eoapi/templates/services/service.yaml b/helm-chart/eoapi/templates/services/service.yaml index aa070ab1..cd8ea3e6 100644 --- a/helm-chart/eoapi/templates/services/service.yaml +++ b/helm-chart/eoapi/templates/services/service.yaml @@ -4,15 +4,9 @@ apiVersion: v1 kind: Service metadata: - {{- if $.Values.testing }} - labels: - app: {{ $serviceName }}-{{ $.Release.Name }} - name: {{ $serviceName }}-{{ $.Release.Name }} - {{- else }} labels: app: {{ $serviceName }} name: {{ $serviceName }} - {{- end }} spec: {{- if (and ($.Values.ingress.className) (eq $.Values.ingress.className "nginx")) }} type: "ClusterIP"