From 0a83f630679ff9fb6372c4600e01569f70fd8038 Mon Sep 17 00:00:00 2001 From: shreddedbacon Date: Mon, 6 Jan 2025 09:19:58 +1100 Subject: [PATCH] chore: remove api-data-watcher-pusher replace with seed --- .github/workflows/test-suite.yaml | 4 +- Makefile | 38 ++++++++++ charts/lagoon-test/Chart.yaml | 2 +- charts/lagoon-test/ci/linter-values.yaml.tpl | 6 -- charts/lagoon-test/templates/_helpers.tpl | 30 -------- .../local-api-data-watcher-pusher.job.yaml | 70 ------------------- charts/lagoon-test/values.yaml | 17 ----- 7 files changed, 41 insertions(+), 126 deletions(-) delete mode 100644 charts/lagoon-test/templates/local-api-data-watcher-pusher.job.yaml diff --git a/.github/workflows/test-suite.yaml b/.github/workflows/test-suite.yaml index 97ae7986..2a8128b2 100644 --- a/.github/workflows/test-suite.yaml +++ b/.github/workflows/test-suite.yaml @@ -134,7 +134,7 @@ jobs: (steps.list-changed.outputs.changed == 'true' && !contains(github.event.pull_request.labels.*.name, 'next-release')) || (contains(github.event.pull_request.labels.*.name, 'needs-testing')) run: | - make install-lagoon + make kind/seed-data make -j8 -O fill-test-ci-values TESTS=[${{ matrix.test }}] - name: Helm-install the test fixtures and fill lagoon-test/ci/linter-values.yaml (next-release) @@ -143,7 +143,7 @@ jobs: (contains(github.event.pull_request.labels.*.name, 'next-release')) run: | yq eval-all --inplace 'select(fileIndex == 0) * select(fileIndex == 1)' ./charts/lagoon-core/ci/linter-values.yaml ./charts/lagoon-core/ci/testlagoon-main-override.yaml - make install-lagoon IMAGE_REGISTRY=testlagoon IMAGE_TAG=main OVERRIDE_BUILD_DEPLOY_DIND_IMAGE=uselagoon/build-deploy-image:main OVERRIDE_ACTIVE_STANDBY_TASK_IMAGE=testlagoon/task-activestandby:main + make kind/seed-data IMAGE_REGISTRY=testlagoon IMAGE_TAG=main OVERRIDE_BUILD_DEPLOY_DIND_IMAGE=uselagoon/build-deploy-image:main OVERRIDE_ACTIVE_STANDBY_TASK_IMAGE=testlagoon/task-activestandby:main make -j8 -O fill-test-ci-values TESTS=[${{ matrix.test }}] IMAGE_REGISTRY=testlagoon IMAGE_TAG=main OVERRIDE_BUILD_DEPLOY_DIND_IMAGE=uselagoon/build-deploy-image:main OVERRIDE_ACTIVE_STANDBY_TASK_IMAGE=testlagoon/task-activestandby:main - name: Free up some disk space diff --git a/Makefile b/Makefile index bd6a862c..dddf7d7d 100644 --- a/Makefile +++ b/Makefile @@ -639,3 +639,41 @@ port-forwards: pf-keycloak pf-api pf-ssh pf-ui .PHONY: run-tests run-tests: $(HELM) test --namespace lagoon-core --timeout 30m lagoon-test + +# kind/seed-data is a way to seed a lagoon-core +# CORE_APP_VERSION_OR_TREEISH = heads/main +CORE_APP_VERSION_OR_TREEISH = heads/remove-data-watcher-pusher + +.PHONY: kind/seed-data +kind/seed-data: install-lagoon +ifeq (,$(subst ",,$(CORE_APP_VERSION_OR_TREEISH))) + $(eval CORE_APP_VERSION_OR_TREEISH = tags/$(shell $(HELM) search repo lagoon/lagoon-core -o json | $(JQ) -r '.[]|.app_version')) +endif + @echo "Loading API seed data" && \ + export LAGOON_LEGACY_ADMIN=$$(docker run \ + -e JWTSECRET="$$($(KUBECTL) get secret -n lagoon-core lagoon-core-secrets -o jsonpath="{.data.JWTSECRET}" | base64 --decode)" \ + -e JWTAUDIENCE=api.dev \ + -e JWTUSER=localadmin \ + uselagoon/tests \ + python3 /ansible/tasks/api/admin_token.py) && \ + export SSH_PORTAL_HOST="$$($(KUBECTL) -n lagoon get services lagoon-remote-ssh-portal -o jsonpath='{.status.loadBalancer.ingress[0].ip}')" && \ + export SSH_PORTAL_PORT="$$($(KUBECTL) -n lagoon get services lagoon-remote-ssh-portal -o jsonpath='{.spec.ports[0].port}')" && \ + export CONSOLE_URL="https://kubernetes.default.svc/" && \ + export KUBERNETES_TOKEN="$$($(KUBECTL) get secret -n lagoon lagoon-remote-ssh-core-token -o jsonpath="{.data.token}" | base64 --decode)" && \ + export ROUTER_PATTERN="\$${project}.\$${environment}.$$($(KUBECTL) -n ingress-nginx get services ingress-nginx-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}')" && \ + curl -sSLo /tmp/seed.gql https://raw.githubusercontent.com/uselagoon/lagoon/refs/$(CORE_APP_VERSION_OR_TREEISH)/local-dev/seed-data/00-populate-kubernetes.gql && \ + export SEED_DATA=$$(envsubst < /tmp/seed.gql | sed 's/"/\\"/g' | sed 's/\\n/\\\\n/g' | awk -F'\n' '{if(NR == 1) {printf $$0} else {printf "\\n"$$0}}') && \ + export SEED_DATA_JSON="{\"query\": \"$$SEED_DATA\"}" && \ + wget --quiet --header "Content-Type: application/json" --header "Authorization: bearer $${LAGOON_LEGACY_ADMIN}" "http://lagoon-api.$$($(KUBECTL) -n ingress-nginx get services ingress-nginx-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}').nip.io/graphql" --post-data "$$SEED_DATA_JSON" --content-on-error -O - && \ + echo "Loading API seed users" && \ + curl -sSLo /tmp/seed-users.sh https://raw.githubusercontent.com/uselagoon/lagoon/refs/$(CORE_APP_VERSION_OR_TREEISH)/local-dev/seed-data/seed-users.sh && \ + cat /tmp/seed-users.sh \ + | $(KUBECTL) -n lagoon-core exec -i $$($(KUBECTL) -n lagoon-core get pods \ + -l app.kubernetes.io/component=lagoon-core-keycloak -o json | $(JQ) -r '.items[0].metadata.name') -- sh -c "cat > /tmp/seed-users.sh" && \ + $(KUBECTL) -n lagoon-core exec -it $$($(KUBECTL) -n lagoon-core get pods -l app.kubernetes.io/component=lagoon-core-keycloak -o json | $(JQ) -r '.items[0].metadata.name') -- bash '/tmp/seed-users.sh' \ + && echo "You will be able to log in with these seed user email addresses and the passwords will be the same as the email address" \ + && echo "eg. maintainer@example.com has the password maintainer@example.com" \ + && echo "" \ + && echo "If you want to create an example SSO identity provider and example user, run make k3d/example-sso" \ + && echo "If you want to configure simple webauthn browswer flow, run make k3d/configure-webauthn" \ + && echo "" \ No newline at end of file diff --git a/charts/lagoon-test/Chart.yaml b/charts/lagoon-test/Chart.yaml index ff19bbf1..a2b5d7e1 100644 --- a/charts/lagoon-test/Chart.yaml +++ b/charts/lagoon-test/Chart.yaml @@ -29,4 +29,4 @@ appVersion: v2.23.0 annotations: artifacthub.io/changes: | - kind: changed - description: update lagoon-core appVersion to v2.23.0 + description: removed api-data-watcher-pusher diff --git a/charts/lagoon-test/ci/linter-values.yaml.tpl b/charts/lagoon-test/ci/linter-values.yaml.tpl index d2f94f44..faf42e08 100644 --- a/charts/lagoon-test/ci/linter-values.yaml.tpl +++ b/charts/lagoon-test/ci/linter-values.yaml.tpl @@ -11,12 +11,6 @@ localGit: image: repository: ${imageRegistry}/local-git -localAPIDataWatcherPusher: - image: - repository: ${imageRegistry}/local-api-data-watcher-pusher - additonalEnvs: - CLEAR_API_DATA: ${clearApiData} - tests: image: repository: ${imageRegistry}/tests diff --git a/charts/lagoon-test/templates/_helpers.tpl b/charts/lagoon-test/templates/_helpers.tpl index e7810695..94e17c91 100644 --- a/charts/lagoon-test/templates/_helpers.tpl +++ b/charts/lagoon-test/templates/_helpers.tpl @@ -88,33 +88,3 @@ app.kubernetes.io/name: {{ include "lagoon-test.name" . }} app.kubernetes.io/component: {{ include "lagoon-test.localGit.fullname" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} - - - -{{/* -Create a default fully qualified app name for local-api-data-watcher-pusher. -*/}} -{{- define "lagoon-test.localAPIDataWatcherPusher.fullname" -}} -{{- include "lagoon-test.fullname" . }}-local-api-data-watcher-pusher -{{- end }} - -{{/* -Common labels local-api-data-watcher-pusher. -*/}} -{{- define "lagoon-test.localAPIDataWatcherPusher.labels" -}} -helm.sh/chart: {{ include "lagoon-test.chart" . }} -{{ include "lagoon-test.localAPIDataWatcherPusher.selectorLabels" . }} -{{- if .Chart.AppVersion }} -app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} -{{- end }} -app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- end }} - -{{/* -Selector labels local-api-data-watcher-pusher. -*/}} -{{- define "lagoon-test.localAPIDataWatcherPusher.selectorLabels" -}} -app.kubernetes.io/name: {{ include "lagoon-test.name" . }} -app.kubernetes.io/component: {{ include "lagoon-test.localAPIDataWatcherPusher.fullname" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -{{- end }} diff --git a/charts/lagoon-test/templates/local-api-data-watcher-pusher.job.yaml b/charts/lagoon-test/templates/local-api-data-watcher-pusher.job.yaml deleted file mode 100644 index 0b35d692..00000000 --- a/charts/lagoon-test/templates/local-api-data-watcher-pusher.job.yaml +++ /dev/null @@ -1,70 +0,0 @@ -apiVersion: batch/v1 -kind: Job -metadata: - name: {{ include "lagoon-test.localAPIDataWatcherPusher.fullname" . }} - labels: - {{- include "lagoon-test.localAPIDataWatcherPusher.labels" . | nindent 4 }} - annotations: - "helm.sh/hook": test - "helm.sh/hook-weight": "10" -spec: - backoffLimit: 2 - template: - metadata: - labels: - {{- include "lagoon-test.localAPIDataWatcherPusher.selectorLabels" . | nindent 8 }} - spec: - restartPolicy: Never - securityContext: - {{- toYaml .Values.localAPIDataWatcherPusher.podSecurityContext | nindent 8 }} - terminationGracePeriodSeconds: 120 - containers: - - name: api-data-watcher-pusher - image: "{{ .Values.localAPIDataWatcherPusher.image.repository }}:{{ coalesce .Values.localAPIDataWatcherPusher.image.tag .Values.imageTag .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.localAPIDataWatcherPusher.image.pullPolicy }} - securityContext: - {{- toYaml .Values.localAPIDataWatcherPusher.securityContext | nindent 10 }} - env: - - name: API_HOST - value: {{ .Values.apiHost | quote }} - - name: API_PORT - value: {{ .Values.apiPort | quote }} - - name: CONSOLE_URL - value: {{ .Values.consoleURL | quote }} - - name: GIT_HOST - value: "{{ include "lagoon-test.localGit.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local" - - name: GIT_PORT - value: {{ .Values.localGit.service.port | quote }} - - name: INGRESS_IP - value: {{ required "A valid .Values.ingressIP required!" .Values.ingressIP | quote }} - - name: JWTSECRET - valueFrom: - secretKeyRef: - name: {{ .Values.jwtSecretSecret | quote }} - key: JWTSECRET - - name: MINIO_SERVER_URL - value: {{ .Values.minioURL | quote }} - - name: MINIO_ROOT_USER - value: {{ .Values.minioUser | quote }} - - name: MINIO_ROOT_PASSWORD - value: {{ .Values.minioPass | quote }} - - name: TOKEN - value: {{ required "A valid .Values.token required!" .Values.token | quote }} - {{- range $key, $val := .Values.localAPIDataWatcherPusher.additionalEnvs }} - - name: {{ $key }} - value: {{ $val | quote }} - {{- end }} - resources: - {{- toYaml .Values.localAPIDataWatcherPusher.resources | nindent 10 }} - {{- with .Values.localAPIDataWatcherPusher.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.localAPIDataWatcherPusher.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.localAPIDataWatcherPusher.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} diff --git a/charts/lagoon-test/values.yaml b/charts/lagoon-test/values.yaml index a4ee1a59..becb2ba8 100644 --- a/charts/lagoon-test/values.yaml +++ b/charts/lagoon-test/values.yaml @@ -111,23 +111,6 @@ localGit: affinity: {} -localAPIDataWatcherPusher: - - image: - repository: uselagoon/local-api-data-watcher-pusher - pullPolicy: Always - # Overrides the image tag whose default is the chart appVersion. - tag: "" - - additionalEnvs: - # CLEAR_API_DATA: true - - podSecurityContext: {} - - securityContext: {} - - resources: {} - tests: image: