From 67ff70201e722a887bd5649202e3f0f3f6efa79d Mon Sep 17 00:00:00 2001 From: dandds Date: Wed, 18 Sep 2019 16:24:14 -0400 Subject: [PATCH] Add beat worker to the deployment. We will run a separate pod for the beat worker. There should only ever be a single beat worker (to avoid redundant work) so the number of replicas needs to be managed independently. This adds both the Kubernetes config for the new pod and additional CircleCI config to swap a new image into the pod during CD. --- .circleci/config.yml | 28 +++++++++++++++++++++ deploy/aws/aws.yml | 57 +++++++++++++++++++++++++++++++++++++----- deploy/azure/azure.yml | 57 +++++++++++++++++++++++++++++++++++++----- 3 files changed, 130 insertions(+), 12 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3fddae2e..2851bce1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -185,6 +185,20 @@ workflows: branches: only: - master + - azure-aks/update-container-image: + cluster-name: atat-cluster + container-image-updates: "atst-beat=${AZURE_SERVER_NAME}/atat:atat-${CIRCLE_SHA1}" + namespace: atat + resource-name: deployment.apps/atst-beat + resource-group: atat + # uncomment below for debugging + # show-kubectl-command: true + requires: + - azure-migration + filters: + branches: + only: + - master - aws-ecr/build-and-push-image: extra-build-args: "--build-arg CSP=aws" repo: atat @@ -230,3 +244,17 @@ workflows: branches: only: - master + - aws-eks/update-container-image: + cluster-name: atat + container-image-updates: "atst-beat=${AWS_ECR_ACCOUNT_URL}/atat:atat-${CIRCLE_SHA1}" + namespace: atat + resource-name: deployment.apps/atst-beat + aws-region: "${AWS_REGION}" + # uncomment below for debugging + # show-kubectl-command: true + requires: + - aws-migration + filters: + branches: + only: + - master diff --git a/deploy/aws/aws.yml b/deploy/aws/aws.yml index b30f7fb4..8f73a761 100644 --- a/deploy/aws/aws.yml +++ b/deploy/aws/aws.yml @@ -29,9 +29,6 @@ spec: containers: - name: atst image: 904153757533.dkr.ecr.us-east-2.amazonaws.com/atat:latest - resources: - requests: - memory: "500Mi" envFrom: - configMapRef: name: atst-envvars @@ -148,9 +145,57 @@ spec: "worker", "--loglevel=info" ] - resources: - requests: - memory: "500Mi" + envFrom: + - configMapRef: + name: atst-envvars + - configMapRef: + name: atst-worker-envvars + volumeMounts: + - name: atst-config + mountPath: "/opt/atat/atst/atst-overrides.ini" + subPath: atst-overrides.ini + volumes: + - name: atst-config + secret: + secretName: atst-config-ini + items: + - key: override.ini + path: atst-overrides.ini + mode: 0644 +--- +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + labels: + app: atst + name: atst-beat + namespace: atat +spec: + selector: + matchLabels: + role: beat + replicas: 1 + strategy: + type: RollingUpdate + template: + metadata: + labels: + app: atst + role: beat + spec: + securityContext: + fsGroup: 101 + containers: + - name: atst-beat + image: 904153757533.dkr.ecr.us-east-2.amazonaws.com/atat:latest + args: [ + "/opt/atat/atst/.venv/bin/python", + "/opt/atat/atst/.venv/bin/celery", + "-A", + "celery_worker.celery", + "beat", + "--loglevel=info" + ] envFrom: - configMapRef: name: atst-envvars diff --git a/deploy/azure/azure.yml b/deploy/azure/azure.yml index e599b9f5..31274b01 100644 --- a/deploy/azure/azure.yml +++ b/deploy/azure/azure.yml @@ -29,9 +29,6 @@ spec: containers: - name: atst image: pwatat.azurecr.io/atat:latest - resources: - requests: - memory: "500Mi" envFrom: - configMapRef: name: atst-envvars @@ -149,9 +146,57 @@ spec: "worker", "--loglevel=info" ] - resources: - requests: - memory: "500Mi" + envFrom: + - configMapRef: + name: atst-envvars + - configMapRef: + name: atst-worker-envvars + volumeMounts: + - name: atst-config + mountPath: "/opt/atat/atst/atst-overrides.ini" + subPath: atst-overrides.ini + volumes: + - name: atst-config + secret: + secretName: atst-config-ini + items: + - key: override.ini + path: atst-overrides.ini + mode: 0644 +--- +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + labels: + app: atst + name: atst-beat + namespace: atat +spec: + selector: + matchLabels: + role: beat + replicas: 1 + strategy: + type: RollingUpdate + template: + metadata: + labels: + app: atst + role: beat + spec: + securityContext: + fsGroup: 101 + containers: + - name: atst-beat + image: pwatat.azurecr.io/atat:latest + args: [ + "/opt/atat/atst/.venv/bin/python", + "/opt/atat/atst/.venv/bin/celery", + "-A", + "celery_worker.celery", + "beat", + "--loglevel=info" + ] envFrom: - configMapRef: name: atst-envvars