Skip to content

Commit

Permalink
Merge pull request #65 from ministryofjustice/NIT-1229-auto-scaling-pods
Browse files Browse the repository at this point in the history
Nit 1229 auto scaling pods
  • Loading branch information
pbasumatary authored May 17, 2024
2 parents dd45453 + 204b365 commit 498d91d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 23 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/scale-down.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: Scale down Lower Environments

on:
workflow_dispatch:
# schedule:
# - cron: '00 19 * * *'
schedule:
- cron: '00 19 * * 1-5'

jobs:
scale-down:
Expand All @@ -29,7 +28,7 @@ jobs:
version: 'v3.9.0'
id: helm_install

- name: Scale Down Deployments in ${{ matrix.environment }}
- name: Scaling Down Deployments in ${{ matrix.environment }} namespace
env:
KUBE_NAMESPACE: ${{ secrets.KUBE_NAMESPACE }}
KUBE_CLUSTER: ${{ secrets.KUBE_CLUSTER }}
Expand Down
36 changes: 17 additions & 19 deletions .github/workflows/scale-up.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: Scale Up Lower Environments

on:
# schedule:
# - cron: '0 6 * * *'
workflow_dispatch:
schedule:
- cron: '0 6 * * 1-5'

jobs:
scale-up:
Expand Down Expand Up @@ -36,12 +35,11 @@ jobs:
version: "v4.35.1"
force: true

- name: Scale up Deployments in ${{ matrix.environment }}
- name: Scaling up Deployments in ${{ matrix.environment }} namespace
env:
KUBE_NAMESPACE: ${{ secrets.KUBE_NAMESPACE }}
KUBE_CLUSTER: ${{ secrets.KUBE_CLUSTER }}
run: |
run: |
echo "${{ secrets.KUBE_CERT }}" > ca.crt
kubectl config set-cluster ${KUBE_CLUSTER} --certificate-authority=./ca.crt --server=https://${KUBE_CLUSTER}
kubectl config set-credentials deploy-user --token=${{ secrets.KUBE_TOKEN }}
Expand All @@ -51,17 +49,17 @@ jobs:
kubectl config set-context --current --namespace=${KUBE_NAMESPACE}
RELEASE_NAME="alfresco-content-services"
LATEST_REVISION=$(helm history "$RELEASE_NAME" --max 1 -o json | jq '.[0].revision')
LATEST_VALUES=$(helm get values "$RELEASE_NAME" --revision "$LATEST_REVISION")
LATEST_REVISION=$(helm history "$RELEASE_NAME" --max 1 -o yaml | yq -r '.[0].revision')
LATEST_VALUES=$(helm get values "$RELEASE_NAME" --revision "$LATEST_REVISION" -o yaml)
kubectl scale deployment alfresco-content-services-alfresco-cs-repository --replicas=$(echo $LATEST_VALUES | yq '.repository.replicaCount // 1')
kubectl scale deployment alfresco-content-services-alfresco-cs-share --replicas=$(echo $LATEST_VALUES | yq '.share.replicaCount // 1')
kubectl scale deployment alfresco-content-services-activemq --replicas=$(echo $LATEST_VALUES | yq '.activemq.replicaCount // 1')
kubectl scale deployment alfresco-content-services-alfresco-cs-imagemagick --replicas=$(echo $LATEST_VALUES | yq '.imagemagick.replicaCount // 1')
kubectl scale deployment alfresco-content-services-alfresco-cs-libreoffice --replicas=$(echo $LATEST_VALUES | yq '.libreoffice.replicaCount // 1')
kubectl scale deployment alfresco-content-services-alfresco-cs-pdfrenderer --replicas=$(echo $LATEST_VALUES | yq '.pdfrenderer.replicaCount // 1')
kubectl scale deployment alfresco-content-services-alfresco-cs-tika --replicas=$(echo $LATEST_VALUES | yq '.tika.replicaCount // 1')
kubectl scale deployment alfresco-content-services-alfresco-cs-transform-misc --replicas=$(echo $LATEST_VALUES | yq '.transformmisc.replicaCount // 1')
kubectl scale deployment alfresco-content-services-alfresco-filestore --replicas=$(echo $LATEST_VALUES | yq '.filestore.replicaCount // 0')
kubectl scale deployment alfresco-content-services-alfresco-router --replicas=$(echo $LATEST_VALUES | yq '.transformrouter.replicaCount // 1')
kubectl scale deployment alfresco-content-services-alfresco-search-solr --replicas=$(echo $LATEST_VALUES | yq '.share.replicaCount // 1')
kubectl scale deployment alfresco-content-services-alfresco-cs-repository --replicas=$(yq -r '.repository.replicaCount // 1' <<< "$LATEST_VALUES")
kubectl scale deployment alfresco-content-services-alfresco-cs-share --replicas=$(yq -r '.share.replicaCount // 1' <<< "$LATEST_VALUES")
kubectl scale deployment alfresco-content-services-activemq --replicas=$(yq -r '.activemq.replicaCount // 1' <<< "$LATEST_VALUES")
kubectl scale deployment alfresco-content-services-alfresco-cs-imagemagick --replicas=$(yq -r '.imagemagick.replicaCount // 1' <<< "$LATEST_VALUES")
kubectl scale deployment alfresco-content-services-alfresco-cs-libreoffice --replicas=$(yq -r '.libreoffice.replicaCount // 1' <<< "$LATEST_VALUES")
kubectl scale deployment alfresco-content-services-alfresco-cs-pdfrenderer --replicas=$(yq -r '.pdfrenderer.replicaCount // 1' <<< "$LATEST_VALUES")
kubectl scale deployment alfresco-content-services-alfresco-cs-tika --replicas=$(yq -r '.tika.replicaCount // 1' <<< "$LATEST_VALUES")
kubectl scale deployment alfresco-content-services-alfresco-cs-transform-misc --replicas=$(yq -r '.transformmisc.replicaCount // 1' <<< "$LATEST_VALUES")
kubectl scale deployment alfresco-content-services-alfresco-filestore --replicas=$(yq -r '.filestore.replicaCount // 0' <<< "$LATEST_VALUES")
kubectl scale deployment alfresco-content-services-alfresco-router --replicas=$(yq -r '.transformrouter.replicaCount // 1' <<< "$LATEST_VALUES")
kubectl scale deployment alfresco-content-services-alfresco-search-solr --replicas=$(yq -r '.share.replicaCount // 1' <<< "$LATEST_VALUES")

0 comments on commit 498d91d

Please sign in to comment.