From 369485e892c84db6880b4744c32b1e2d19f0ce3d Mon Sep 17 00:00:00 2001 From: Craig Yu Date: Thu, 25 May 2023 11:54:10 -0700 Subject: [PATCH 1/3] fix: change oracle replicas from 1 to 3 --- oracle-api/openshift.deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oracle-api/openshift.deploy.yml b/oracle-api/openshift.deploy.yml index b592288ca..18b89a842 100644 --- a/oracle-api/openshift.deploy.yml +++ b/oracle-api/openshift.deploy.yml @@ -73,7 +73,7 @@ objects: app: ${NAME}-${ZONE} name: ${NAME}-${ZONE}-${COMPONENT} spec: - replicas: 1 + replicas: 3 triggers: - type: ConfigChange - type: ImageChange From aff15696a0963b284d164ae876d0b0df7265bcda Mon Sep 17 00:00:00 2001 From: Craig Yu Date: Thu, 25 May 2023 12:28:27 -0700 Subject: [PATCH 2/3] fix: add autoscaling --- .github/workflows/pr-open.yml | 7 +++++-- oracle-api/openshift.deploy.yml | 26 +++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr-open.yml b/.github/workflows/pr-open.yml index 1b6a6a25a..418d2b914 100644 --- a/.github/workflows/pr-open.yml +++ b/.github/workflows/pr-open.yml @@ -86,7 +86,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Pushing run: docker push ${{ env.NAME }} - + builds: name: Builds runs-on: ubuntu-22.04 @@ -148,7 +148,10 @@ jobs: file: oracle-api/openshift.deploy.yml overwrite: true verification_path: "actuator/health" - parameters: -p NR_SPAR_ORACLE_API_VERSION=snapshot-${{ github.event.number }} + parameters: + -p NR_SPAR_ORACLE_API_VERSION=snapshot-${{ github.event.number }} + -p MIN_REPLICAS=1 + -p MAX_REPLICAS=1 steps: - uses: bcgov-nr/action-deployer-openshift@v1.0.4 with: diff --git a/oracle-api/openshift.deploy.yml b/oracle-api/openshift.deploy.yml index 18b89a842..d4a397819 100644 --- a/oracle-api/openshift.deploy.yml +++ b/oracle-api/openshift.deploy.yml @@ -49,6 +49,12 @@ parameters: - name: KEYCLOAK_REALM_URL description: Keycloak realm address value: https://test.loginproxy.gov.bc.ca/auth/realms/standard + - name: MIN_REPLICAS + description: The minimum amount of replicas for the horizontal pod autoscaler. + value: "3" + - name: MAX_REPLICAS + description: The maximum amount of replicas for the horizontal pod autoscaler. + value: "5" objects: - apiVersion: v1 kind: ImageStream @@ -73,7 +79,7 @@ objects: app: ${NAME}-${ZONE} name: ${NAME}-${ZONE}-${COMPONENT} spec: - replicas: 3 + replicas: 1 triggers: - type: ConfigChange - type: ImageChange @@ -180,3 +186,21 @@ objects: tls: termination: edge insecureEdgeTerminationPolicy: Redirect + - apiVersion: autoscaling/v2 + kind: HorizontalPodAutoscaler + metadata: + name: ${NAME}-${ZONE}-${COMPONENT} + spec: + scaleTargetRef: + apiVersion: apps.openshift.io/v1 + kind: DeploymentConfig + name: ${NAME}-${ZONE}-${COMPONENT} + minReplicas: ${{MIN_REPLICAS}} + maxReplicas: ${{MAX_REPLICAS}} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 100 From 438ad6bb3e4e7c034da27a8e9278b22156297a78 Mon Sep 17 00:00:00 2001 From: Craig Yu Date: Thu, 25 May 2023 12:45:06 -0700 Subject: [PATCH 3/3] fix: change averageUtilization from 100 to 80 for all services --- .github/workflows/pr-open.yml | 14 +++++++++----- backend/openshift.deploy.yml | 2 +- frontend/openshift.deploy.yml | 2 +- oracle-api/openshift.deploy.yml | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pr-open.yml b/.github/workflows/pr-open.yml index 418d2b914..106298e45 100644 --- a/.github/workflows/pr-open.yml +++ b/.github/workflows/pr-open.yml @@ -131,7 +131,10 @@ jobs: file: backend/openshift.deploy.yml overwrite: true verification_path: "actuator/health" - parameters: -p MIN_REPLICAS=1 -p MAX_REPLICAS=1 -p BUILD=snapshot-${{ github.event.number }} + parameters: + -p MIN_REPLICAS=1 + -p MAX_REPLICAS=1 + -p BUILD=snapshot-${{ github.event.number }} - name: frontend file: frontend/openshift.deploy.yml overwrite: true @@ -143,7 +146,8 @@ jobs: -p REACT_APP_KC_URL=https://test.loginproxy.gov.bc.ca/auth -p REACT_APP_KC_REALM=standard -p REACT_APP_KC_CLIENT_ID=seed-planning-test-4296 - -p MIN_REPLICAS=1 -p MAX_REPLICAS=1 + -p MIN_REPLICAS=1 + -p MAX_REPLICAS=1 - name: oracle-api file: oracle-api/openshift.deploy.yml overwrite: true @@ -163,9 +167,9 @@ jobs: penetration_test: false verification_path: ${{ matrix.verification_path}} parameters: - -p ZONE=${{ github.event.number }} -p NAME=${{ github.event.repository.name }} - -p PROMOTE=${{ github.repository }}/${{ matrix.name }}:${{ github.event.number }} - ${{ matrix.parameters }} + -p ZONE=${{ github.event.number }} + -p NAME=${{ github.event.repository.name }} + -p PROMOTE=${{ github.repository }}/${{ matrix.name }}:${{ github.event.number }}${{ matrix.parameters }} # tests-api: # name: API Tests diff --git a/backend/openshift.deploy.yml b/backend/openshift.deploy.yml index 0ddf31772..441a0b33a 100644 --- a/backend/openshift.deploy.yml +++ b/backend/openshift.deploy.yml @@ -212,4 +212,4 @@ objects: name: cpu target: type: Utilization - averageUtilization: 100 + averageUtilization: 80 diff --git a/frontend/openshift.deploy.yml b/frontend/openshift.deploy.yml index 3c9cc391f..322a8accc 100644 --- a/frontend/openshift.deploy.yml +++ b/frontend/openshift.deploy.yml @@ -200,7 +200,7 @@ objects: name: cpu target: type: Utilization - averageUtilization: 100 + averageUtilization: 80 - apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: diff --git a/oracle-api/openshift.deploy.yml b/oracle-api/openshift.deploy.yml index d4a397819..28a5290f0 100644 --- a/oracle-api/openshift.deploy.yml +++ b/oracle-api/openshift.deploy.yml @@ -203,4 +203,4 @@ objects: name: cpu target: type: Utilization - averageUtilization: 100 + averageUtilization: 80