From 4e06394b57d513a4ebeacb9816ecc41352dcdff1 Mon Sep 17 00:00:00 2001 From: Oscar Wieman Date: Mon, 7 Aug 2023 01:27:45 +0200 Subject: [PATCH] Prepare preview environments --- .github/workflows/main.yml | 14 ++++++-------- charts/drinkn/Chart.yaml | 19 ------------------- charts/drinkn/templates/auth-api.yaml | 4 +++- charts/drinkn/templates/beer-import.yaml | 4 +++- charts/drinkn/templates/cocktail-api.yaml | 4 +++- charts/drinkn/templates/drinkn-frontend.yaml | 4 +++- charts/drinkn/templates/ingressroute.yaml | 6 ++++-- charts/drinkn/templates/namespace.yaml | 8 ++++++++ charts/drinkn/templates/pils-api.yaml | 4 ++-- charts/drinkn/templates/pils-frontend.yaml | 4 ++-- charts/drinkn/templates/secrets.yaml | 4 ++++ charts/drinkn/values.yaml | 13 +++++++++++-- 12 files changed, 49 insertions(+), 39 deletions(-) create mode 100644 charts/drinkn/templates/namespace.yaml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 99427275e..dff31095e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -98,8 +98,6 @@ jobs: tags: | type=ref,event=branch type=sha - flavor: | - latest=auto - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -115,10 +113,10 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v4 with: context: ${{ matrix.folder }} - push: ${{ github.event_name != 'pull_request' }} + push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} platforms: linux/amd64,linux/arm64 @@ -146,12 +144,12 @@ jobs: # Trim the first few characters to match the desired format (e.g., sha-c27d339) SHORT_SHA="sha-${COMMIT_SHA:0:7}" - # Change appVersion in charts/drinkn/Chart.yaml - sed -i "s|appVersion:.*|appVersion: \"$SHORT_SHA\"|" charts/drinkn/Chart.yaml + # Change image.tag in charts/drinkn/values.yaml + sed -i "s|tag:.*|tag: \"$SHORT_SHA\"|" charts/drinkn/values.yaml # Commit and push the changes to the deploy branch git config --global user.name "github-actions[bot]" git config --global user.email "github-actions[bot]@users.noreply.github.com" - git add charts/drinkn/Chart.yaml - git commit -m "Update appVersion to $SHORT_SHA" + git add charts/drinkn/values.yaml + git commit -m "Update image.tag to $SHORT_SHA" git push origin main diff --git a/charts/drinkn/Chart.yaml b/charts/drinkn/Chart.yaml index 0d66df588..d5841b4ff 100644 --- a/charts/drinkn/Chart.yaml +++ b/charts/drinkn/Chart.yaml @@ -1,24 +1,5 @@ apiVersion: v2 name: drinkn description: A Helm chart for Kubernetes - -# A chart can be either an 'application' or a 'library' chart. -# -# Application charts are a collection of templates that can be packaged into versioned archives -# to be deployed. -# -# Library charts provide useful utilities or functions for the chart developer. They're included as -# a dependency of application charts to inject those utilities and functions into the rendering -# pipeline. Library charts do not define any templates and therefore cannot be deployed. type: application - -# This is the chart version. This version number should be incremented each time you make changes -# to the chart and its templates, including the app version. -# Versions are expected to follow Semantic Versioning (https://semver.org/) version: 1.0.0 - -# This is the version number of the application being deployed. This version number should be -# 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: "sha-e65db8c" diff --git a/charts/drinkn/templates/auth-api.yaml b/charts/drinkn/templates/auth-api.yaml index 7a89a4a7d..a02e2d11f 100644 --- a/charts/drinkn/templates/auth-api.yaml +++ b/charts/drinkn/templates/auth-api.yaml @@ -1,3 +1,4 @@ +{{- if not .Values.pr.enabled }} --- apiVersion: apps/v1 kind: Deployment @@ -6,7 +7,7 @@ metadata: app: drinkn-auth name: drinkn-auth spec: - replicas: 2 + replicas: {{ .Values.replicas }} revisionHistoryLimit: 0 selector: matchLabels: @@ -39,3 +40,4 @@ spec: name: default protocol: TCP targetPort: 3000 +{{- end }} diff --git a/charts/drinkn/templates/beer-import.yaml b/charts/drinkn/templates/beer-import.yaml index 61863eb5f..0af001cfb 100644 --- a/charts/drinkn/templates/beer-import.yaml +++ b/charts/drinkn/templates/beer-import.yaml @@ -1,3 +1,4 @@ +{{- if not .Values.pr.enabled }} # maybe mock a fake api to run against? --- apiVersion: batch/v1 kind: CronJob @@ -11,7 +12,7 @@ spec: restartPolicy: Never terminationGracePeriodSeconds: 30 containers: - - image: "ghcr.io/bierteam/drinkn/beer-import:{{ .Chart.AppVersion }}" + - image: "ghcr.io/bierteam/drinkn/beer-import:{{ .Values.image.tag }}" imagePullPolicy: Always name: beer-import envFrom: @@ -21,3 +22,4 @@ spec: schedule: 0 9,22 * * * failedJobsHistoryLimit: 3 successfulJobsHistoryLimit: 3 +{{- end }} diff --git a/charts/drinkn/templates/cocktail-api.yaml b/charts/drinkn/templates/cocktail-api.yaml index 45e67027d..7879a6831 100644 --- a/charts/drinkn/templates/cocktail-api.yaml +++ b/charts/drinkn/templates/cocktail-api.yaml @@ -1,3 +1,4 @@ +{{- if not .Values.pr.enabled }} --- apiVersion: apps/v1 kind: Deployment @@ -6,7 +7,7 @@ metadata: app: drinkn-cocktail-api name: drinkn-cocktail-api spec: - replicas: 2 + replicas: {{ .Values.replicas }} revisionHistoryLimit: 0 selector: matchLabels: @@ -39,3 +40,4 @@ spec: name: default protocol: TCP targetPort: 3000 +{{- end }} diff --git a/charts/drinkn/templates/drinkn-frontend.yaml b/charts/drinkn/templates/drinkn-frontend.yaml index d4b125bb1..4c7cb4a94 100644 --- a/charts/drinkn/templates/drinkn-frontend.yaml +++ b/charts/drinkn/templates/drinkn-frontend.yaml @@ -1,3 +1,4 @@ +{{- if not .Values.pr.enabled }} --- apiVersion: apps/v1 kind: Deployment @@ -6,7 +7,7 @@ metadata: app: drinkn-frontend name: drinkn-frontend spec: - replicas: 2 + replicas: {{ .Values.replicas }} revisionHistoryLimit: 0 selector: matchLabels: @@ -55,3 +56,4 @@ spec: name: default protocol: TCP targetPort: 80 +{{- end }} diff --git a/charts/drinkn/templates/ingressroute.yaml b/charts/drinkn/templates/ingressroute.yaml index a74443393..195c69b43 100644 --- a/charts/drinkn/templates/ingressroute.yaml +++ b/charts/drinkn/templates/ingressroute.yaml @@ -7,6 +7,7 @@ spec: entryPoints: - websecure routes: + {{- if not .Values.pr.enabled }} - match: Host(`drinkn.oscarr.nl`, `xn--xj8haa.tk`) kind: Rule services: @@ -32,12 +33,13 @@ spec: services: - name: drinkn-auth port: 80 - - match: Host(`pils.oscarr.nl`) + {{- end }} + - match: Host(`{{ .Values.fqdn }}`) kind: Rule services: - name: pils-frontend port: 80 - - match: Host(`pils.oscarr.nl`) && PathPrefix(`/api`) + - match: Host(`{{ .Values.fqdn }}`) && PathPrefix(`/api`) kind: Rule services: - name: pils diff --git a/charts/drinkn/templates/namespace.yaml b/charts/drinkn/templates/namespace.yaml new file mode 100644 index 000000000..9ca653731 --- /dev/null +++ b/charts/drinkn/templates/namespace.yaml @@ -0,0 +1,8 @@ +{{- if .Values.pr.enabled }} +# https://github.com/argoproj/argo-cd/issues/7875#issuecomment-1178931205 +--- +apiVersion: v1 +kind: Namespace +metadata: + name: drinkn-pr-{{.Values.pr.number}} +{{- end }} diff --git a/charts/drinkn/templates/pils-api.yaml b/charts/drinkn/templates/pils-api.yaml index df78a8142..71dbd914f 100644 --- a/charts/drinkn/templates/pils-api.yaml +++ b/charts/drinkn/templates/pils-api.yaml @@ -6,7 +6,7 @@ metadata: app: pils name: pils spec: - replicas: 2 + replicas: {{ .Values.replicas }} revisionHistoryLimit: 0 selector: matchLabels: @@ -19,7 +19,7 @@ spec: app: pils spec: containers: - - image: "ghcr.io/bierteam/drinkn/pils:{{ .Chart.AppVersion }}" + - image: ghcr.io/bierteam/drinkn/pils:{{ .Values.image.tag }} envFrom: - secretRef: name: drinkn-env diff --git a/charts/drinkn/templates/pils-frontend.yaml b/charts/drinkn/templates/pils-frontend.yaml index e6a886e76..325bf4878 100644 --- a/charts/drinkn/templates/pils-frontend.yaml +++ b/charts/drinkn/templates/pils-frontend.yaml @@ -6,7 +6,7 @@ metadata: app: pils-frontend name: pils-frontend spec: - replicas: 2 + replicas: {{ .Values.replicas }} revisionHistoryLimit: 0 selector: matchLabels: @@ -19,7 +19,7 @@ spec: app: pils-frontend spec: containers: - - image: "ghcr.io/bierteam/drinkn/pils-frontend:{{ .Chart.AppVersion }}" + - image: ghcr.io/bierteam/drinkn/pils-frontend:{{ .Values.image.tag }} imagePullPolicy: Always name: pils-frontend --- diff --git a/charts/drinkn/templates/secrets.yaml b/charts/drinkn/templates/secrets.yaml index b14e04c16..3b0b02205 100644 --- a/charts/drinkn/templates/secrets.yaml +++ b/charts/drinkn/templates/secrets.yaml @@ -1,3 +1,4 @@ +{{- if not .Values.pr.enabled }} --- apiVersion: bitnami.com/v1alpha1 kind: SealedSecret @@ -17,3 +18,6 @@ spec: HIIPERUSER: AgAbuIWvk/Ymr2/Qafzzts885R+IiWrqBKPjgWM9PUY93SkxdCtJw4kYAgpaa13hAN0P/hePkFhD1Fh+bnnXAcz10cWlqUqEsBQAVyZdlZ4IhXAfnbb1FqDVAtHMPCf6LawjCFpWI0JryRpUAEtHfmoOzUXn2a0E74vcZ98UmecRdnNe/FH3cLV1vA0MayjtHL4ImfejGFz3nQiYMFNHgnjnwr1ulK0VLJlSNLwbkNwIX5rBGkorUFtvQ7s+rKJEwfJRscIFqoFpVQMHHMS6BDDIRWxk/ifPRXzjPXGydSh2LS5+xf5LB5d5t1xsfbiAAKVQL7Dch5M5RnTrZ8LH+O2W8b0u8vTImJfob6if7Uwb5Z+82hvMgHxI9lkf2dLJ3egEECOhPvknkHvAx38aaYZ97nP/6LVG2+aW/aSv+7OG4HjaMiWv+g5RZVKMoY2FvGtRjmLcURddJ+Ps8zCQqqP8D1PAlV0i3RynRpITmUmSIhBXb/X0QNZnFLp+NcK2077hVNDKO0LBNDUyoHcyyCcHxnQ/ShhqzqRkI3ADUQ3sJHm2iTNgtOwnbi4kn7g6qHArd+DlqZs5darVSGiMH7yew9CMj+IgKWaYGKPAoEz4jyZWTjNjnlRvVvk6ICCB57VOhk4l+WaKk+Ww5RWCkF0F7Amir8ZC2flEdT146s228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SzlcLmEYxjdusuPLnzfGJV53T7RyS84zn+9MyLSqTajKBZ4YkhOLTaAOP/t7FUNPyMwiBoC4b6Ofh3Ittr/0Q7CLUK/GIKQADGJ3SbKD5OjIRyU+to50AAU548OOET16ETwetxLF0RDgCo2woTuLvS9cDnIYy/7/Y4W6JlmqvtSc2fv5SWZziSfgi5ZMtaKnQRSXe3nfO7Cl6gdUyQH8oet3L7V+xo3E2ymCVuZUKqeay6qpUJ01ALJtsr+YXPHgI7xSNzS5u9vw0cjUoqcoUEWewFL89EjBLr4T1psS7t1nCRn56aH9a07Jm9dPETL4Cll7/AE4woRbeNjI4wxRemu1K8B5bW1s3jBKfUFq/caTo8fWCvvtBCzlUYCGMkwaHMz1mlPMejAK3cDd8YKgF43fzhef+k86fPp460r55AOK7mqIFtqOWXymbFrRqcG+zqkHFSJRr6tCrYrTNicDve91WL64hIQ7zrmppDrT507+qJPpbxDUYGTrZedo1R05GR5vfx7Eiax2yTB5Yo6vNutaoG3QI/V+ZBA++BIFcGw0Cfiunto/Q0A== +{{- else }} +# TODO dev secret +{{- end }} diff --git a/charts/drinkn/values.yaml b/charts/drinkn/values.yaml index cd3a63832..a8c0f8f5a 100644 --- a/charts/drinkn/values.yaml +++ b/charts/drinkn/values.yaml @@ -1,3 +1,12 @@ # Default values for drinkn. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. +image: + tag: "sha-f2bcc8e" + +replicas: "2" + +fqdn: pils.oscarr.nl + +pr: + enabled: false + number: 9999 +