From adf3e54650af33d8b4e602107b28e18e2ab08c0e Mon Sep 17 00:00:00 2001 From: Jacob Nesbitt Date: Wed, 26 Jun 2024 12:31:44 -0400 Subject: [PATCH 1/2] Configure flux pre-deployment for webhook-handler --- .../webhook-handler/{ => deploy}/deployments.yaml | 0 .../{ => deploy}/sealed-secrets.yaml | 0 .../{ => deploy}/service-accounts.yaml | 0 .../webhook-handler/{ => deploy}/services.yaml | 0 .../custom/webhook-handler/flux/deploy.yaml | 15 +++++++++++++++ .../custom/webhook-handler/flux/pre-deploy.yaml | 14 ++++++++++++++ .../webhook-handler/pre-deploy/migration.job.yaml | 15 +++++++++++++++ 7 files changed, 44 insertions(+) rename k8s/production/custom/webhook-handler/{ => deploy}/deployments.yaml (100%) rename k8s/production/custom/webhook-handler/{ => deploy}/sealed-secrets.yaml (100%) rename k8s/production/custom/webhook-handler/{ => deploy}/service-accounts.yaml (100%) rename k8s/production/custom/webhook-handler/{ => deploy}/services.yaml (100%) create mode 100644 k8s/production/custom/webhook-handler/flux/deploy.yaml create mode 100644 k8s/production/custom/webhook-handler/flux/pre-deploy.yaml create mode 100644 k8s/production/custom/webhook-handler/pre-deploy/migration.job.yaml diff --git a/k8s/production/custom/webhook-handler/deployments.yaml b/k8s/production/custom/webhook-handler/deploy/deployments.yaml similarity index 100% rename from k8s/production/custom/webhook-handler/deployments.yaml rename to k8s/production/custom/webhook-handler/deploy/deployments.yaml diff --git a/k8s/production/custom/webhook-handler/sealed-secrets.yaml b/k8s/production/custom/webhook-handler/deploy/sealed-secrets.yaml similarity index 100% rename from k8s/production/custom/webhook-handler/sealed-secrets.yaml rename to k8s/production/custom/webhook-handler/deploy/sealed-secrets.yaml diff --git a/k8s/production/custom/webhook-handler/service-accounts.yaml b/k8s/production/custom/webhook-handler/deploy/service-accounts.yaml similarity index 100% rename from k8s/production/custom/webhook-handler/service-accounts.yaml rename to k8s/production/custom/webhook-handler/deploy/service-accounts.yaml diff --git a/k8s/production/custom/webhook-handler/services.yaml b/k8s/production/custom/webhook-handler/deploy/services.yaml similarity index 100% rename from k8s/production/custom/webhook-handler/services.yaml rename to k8s/production/custom/webhook-handler/deploy/services.yaml diff --git a/k8s/production/custom/webhook-handler/flux/deploy.yaml b/k8s/production/custom/webhook-handler/flux/deploy.yaml new file mode 100644 index 000000000..631a09a43 --- /dev/null +++ b/k8s/production/custom/webhook-handler/flux/deploy.yaml @@ -0,0 +1,15 @@ +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: webhook-handler-deploy +spec: + dependsOn: + - name: webhook-handler-pre-deploy + sourceRef: + kind: GitRepository + name: flux-system + path: "./deploy/" + interval: 5m + timeout: 5m + prune: true + wait: true diff --git a/k8s/production/custom/webhook-handler/flux/pre-deploy.yaml b/k8s/production/custom/webhook-handler/flux/pre-deploy.yaml new file mode 100644 index 000000000..d1bfe31a3 --- /dev/null +++ b/k8s/production/custom/webhook-handler/flux/pre-deploy.yaml @@ -0,0 +1,14 @@ +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: webhook-handler-pre-deploy +spec: + sourceRef: + kind: GitRepository + name: flux-system + path: "./pre-deploy/" + interval: 5m + timeout: 5m + prune: true + wait: true + force: true diff --git a/k8s/production/custom/webhook-handler/pre-deploy/migration.job.yaml b/k8s/production/custom/webhook-handler/pre-deploy/migration.job.yaml new file mode 100644 index 000000000..231880a2b --- /dev/null +++ b/k8s/production/custom/webhook-handler/pre-deploy/migration.job.yaml @@ -0,0 +1,15 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: webhook-handler-db-migration +spec: + template: + spec: + restartPolicy: Never + containers: + - name: migration + image: ghcr.io/spack/django:0.3.1 + command: + - python + - manage.py + - migrate From b43cc6471dd2c71516e4129e3d8999345298e7cb Mon Sep 17 00:00:00 2001 From: Jacob Nesbitt Date: Wed, 26 Jun 2024 12:33:40 -0400 Subject: [PATCH 2/2] Remove webhook-handler image entrypoint --- .github/workflows/custom_docker_builds.yml | 2 +- analytics/Dockerfile | 2 -- analytics/entrypoint.sh | 8 -------- .../webhook-handler/deploy/deployments.yaml | 16 +++++++++++++--- .../pre-deploy/migration.job.yaml | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) delete mode 100644 analytics/entrypoint.sh diff --git a/.github/workflows/custom_docker_builds.yml b/.github/workflows/custom_docker_builds.yml index 472a7f25b..21d8b9a06 100644 --- a/.github/workflows/custom_docker_builds.yml +++ b/.github/workflows/custom_docker_builds.yml @@ -40,7 +40,7 @@ jobs: - docker-image: ./images/cache-indexer image-tags: ghcr.io/spack/cache-indexer:0.0.3 - docker-image: ./analytics - image-tags: ghcr.io/spack/django:0.3.1 + image-tags: ghcr.io/spack/django:0.3.2 - docker-image: ./images/ci-prune-buildcache image-tags: ghcr.io/spack/ci-prune-buildcache:0.0.3 - docker-image: ./images/protected-publish diff --git a/analytics/Dockerfile b/analytics/Dockerfile index cf59e7827..673c6e335 100644 --- a/analytics/Dockerfile +++ b/analytics/Dockerfile @@ -30,6 +30,4 @@ RUN pip install -r requirements.txt COPY . . -RUN chmod +x ./entrypoint.sh -ENTRYPOINT [ "./entrypoint.sh" ] CMD ["gunicorn", "--bind", "0.0.0.0:8080", "--access-logfile", "-", "analytics.wsgi"] diff --git a/analytics/entrypoint.sh b/analytics/entrypoint.sh deleted file mode 100644 index bc38904c5..000000000 --- a/analytics/entrypoint.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -set -e - -# Always run migrate when invoking this image -python manage.py migrate - -# This will exec the CMD passed to docker, i.e. "gunicorn" or "celery" -exec "$@" diff --git a/k8s/production/custom/webhook-handler/deploy/deployments.yaml b/k8s/production/custom/webhook-handler/deploy/deployments.yaml index 295a648c9..86dafacc4 100644 --- a/k8s/production/custom/webhook-handler/deploy/deployments.yaml +++ b/k8s/production/custom/webhook-handler/deploy/deployments.yaml @@ -23,7 +23,7 @@ spec: serviceAccountName: webhook-handler containers: - name: webhook-handler - image: ghcr.io/spack/django:0.3.1 + image: ghcr.io/spack/django:0.3.2 imagePullPolicy: Always resources: requests: @@ -146,8 +146,18 @@ spec: serviceAccountName: webhook-handler containers: - name: webhook-handler-worker - image: ghcr.io/spack/django:0.3.1 - command: ["celery", "-A", "analytics.celery", "worker", "-l", "info", "-Q", "celery"] + image: ghcr.io/spack/django:0.3.2 + command: + [ + "celery", + "-A", + "analytics.celery", + "worker", + "-l", + "info", + "-Q", + "celery", + ] imagePullPolicy: Always resources: requests: diff --git a/k8s/production/custom/webhook-handler/pre-deploy/migration.job.yaml b/k8s/production/custom/webhook-handler/pre-deploy/migration.job.yaml index 231880a2b..15067d327 100644 --- a/k8s/production/custom/webhook-handler/pre-deploy/migration.job.yaml +++ b/k8s/production/custom/webhook-handler/pre-deploy/migration.job.yaml @@ -8,7 +8,7 @@ spec: restartPolicy: Never containers: - name: migration - image: ghcr.io/spack/django:0.3.1 + image: ghcr.io/spack/django:0.3.2 command: - python - manage.py