From f59a088903b73ef5287665dc2fe50b4208216ea5 Mon Sep 17 00:00:00 2001 From: "Fergus MacConnell WLRS:EX" Date: Wed, 4 Sep 2024 11:14:26 -0700 Subject: [PATCH 1/5] Add OpenShift deploy template. --- .github/workflows/.deploy.yml | 37 +++++++++++ .github/workflows/pr-open.yml | 8 ++- frontend/openshift.deploy.yml | 113 ++++++++++++++++++++++++++++++++++ 3 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/.deploy.yml create mode 100644 frontend/openshift.deploy.yml diff --git a/.github/workflows/.deploy.yml b/.github/workflows/.deploy.yml new file mode 100644 index 000000000..4d713259f --- /dev/null +++ b/.github/workflows/.deploy.yml @@ -0,0 +1,37 @@ +name: .Deploys + +on: + workflow_call: + inputs: + environment: + description: GitHub environment; e.g. PR number (omit), TEST or PROD + required: false + type: string + tag: + description: Image tag; e.g. PR number or latest + default: ${{ github.event.number }} + required: false + type: string + target: + description: Deployment target; e.g. PR number (omit), test or prod + default: ${{ github.event.number }} + required: false + type: string + +jobs: + frontend: + name: Frontend + # needs: [backend] + environment: ${{ inputs.environment }} + runs-on: ubuntu-22.04 + steps: + - name: Deploy Frontend + uses: bcgov-nr/action-deployer-openshift@v3.0.0 + with: + oc_namespace: ${{ vars.OC_NAMESPACE }} + oc_server: ${{ vars.OC_SERVER }} + oc_token: ${{ secrets.OC_TOKEN }} + file: frontend/openshift.deploy.yml + overwrite: true + parameters: + -p TAG=${{ inputs.tag }} -p TARGET=${{ inputs.target }} \ No newline at end of file diff --git a/.github/workflows/pr-open.yml b/.github/workflows/pr-open.yml index 2ee248dc1..6f745f632 100644 --- a/.github/workflows/pr-open.yml +++ b/.github/workflows/pr-open.yml @@ -35,10 +35,16 @@ jobs: # oc_namespace: ${{ secrets.OC_NAMESPACE }} # oc_token: ${{ secrets.OC_TOKEN }} # with: - # triggers: ('backend/' 'frontend/' 'migrations/') + # triggers: ('frontend/') # params: # --set global.secrets.persist=false + deploy: + name: Deploy + needs: [builds] + secrets: inherit + uses: ./.github/workflows/.deploy.yml + # tests: # name: Tests # if: needs.deploys.outputs.triggered == 'true' diff --git a/frontend/openshift.deploy.yml b/frontend/openshift.deploy.yml new file mode 100644 index 000000000..6128ae3d4 --- /dev/null +++ b/frontend/openshift.deploy.yml @@ -0,0 +1,113 @@ +apiVersion: template.openshift.io/v1 +kind: Template +parameters: + - name: APP + description: Application name + value: nr-gwells + - name: COMPONENT + description: Component name + value: frontend + - name: ORG + description: Organization name; e.g. bcgov or bcdevops + value: bcgov + - name: TAG + description: Image tag; e.g. PR number or latest + required: true + - name: TARGET + description: Deployment target; e.g. PR number, test or prod + required: true +objects: + - kind: Service + apiVersion: v1 + metadata: + labels: + app: ${APP}-${TARGET} + name: ${APP}-${TARGET}-${COMPONENT} + spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 5173 + protocol: TCP + name: http-5173 + selector: + service: ${APP}-${TARGET}-${COMPONENT} + - kind: Deployment + apiVersion: apps/v1 + metadata: + labels: + app: ${APP}-${TARGET} + deployment: ${APP}-${TARGET}-${COMPONENT} + name: ${APP}-${TARGET}-${COMPONENT} + spec: + strategy: + type: Recreate + selector: + matchLabels: + deployment: ${APP}-${TARGET}-${COMPONENT} + template: + metadata: + labels: + app: ${APP}-${TARGET} + deployment: ${APP}-${TARGET}-${COMPONENT} + service: ${APP}-${TARGET}-${COMPONENT} + spec: + containers: + - name: ${APP}-${TARGET}-${COMPONENT} + image: ghcr.io/${ORG}/${APP}/${COMPONENT}:${TAG} + # securityContext: + # runAsUser: 1011540000 + imagePullPolicy: Always + env: + - name: LOG_LEVEL + value: info + - name: VUE_APP_AXIOS_BASE_URL + value: http://${APP}-${TARGET}/gwells/api/v2/ + ports: + - name: http + containerPort: 5173 + protocol: TCP + readinessProbe: + httpGet: + path: / + port: http + scheme: HTTP + initialDelaySeconds: 90 + periodSeconds: 10 + timeoutSeconds: 10 + successThreshold: 3 + failureThreshold: 30 + livenessProbe: + successThreshold: 1 + failureThreshold: 3 + httpGet: + path: / + port: http + scheme: HTTP + initialDelaySeconds: 15 + periodSeconds: 30 + timeoutSeconds: 5 + resources: # this is optional + limits: + cpu: 150m + memory: 250Mi + requests: + cpu: 50m + memory: 175Mi + - kind: Route + apiVersion: route.openshift.io/v1 + metadata: + labels: + app: ${APP}-${TARGET} + name: ${APP}-${TARGET}-${COMPONENT} + spec: + host: nr-gwells-${TARGET}.apps.silver.devops.gov.bc.ca + port: + targetPort: http-5173 + to: + kind: Service + name: ${APP}-${TARGET}-${COMPONENT} + weight: 100 + tls: + termination: edge + insecureEdgeTerminationPolicy: Redirectss \ No newline at end of file From 625fa316eea07e0f6cdbac9e8eaa15af543919de Mon Sep 17 00:00:00 2001 From: "Fergus MacConnell WLRS:EX" Date: Wed, 4 Sep 2024 11:33:22 -0700 Subject: [PATCH 2/5] Comment out api url in deploy template. --- frontend/openshift.deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/openshift.deploy.yml b/frontend/openshift.deploy.yml index 6128ae3d4..0635978c7 100644 --- a/frontend/openshift.deploy.yml +++ b/frontend/openshift.deploy.yml @@ -61,8 +61,8 @@ objects: env: - name: LOG_LEVEL value: info - - name: VUE_APP_AXIOS_BASE_URL - value: http://${APP}-${TARGET}/gwells/api/v2/ + # - name: VUE_APP_AXIOS_BASE_URL + # value: http://${APP}-${TARGET}/gwells/api/v2/ ports: - name: http containerPort: 5173 From 05da689c94174d5596515d6a9ef5a320b3ba67fa Mon Sep 17 00:00:00 2001 From: "Fergus MacConnell WLRS:EX" Date: Wed, 4 Sep 2024 11:46:59 -0700 Subject: [PATCH 3/5] =?UTF-8?q?=F0=9F=99=83=20typo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/openshift.deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/openshift.deploy.yml b/frontend/openshift.deploy.yml index 0635978c7..38d4106ee 100644 --- a/frontend/openshift.deploy.yml +++ b/frontend/openshift.deploy.yml @@ -110,4 +110,4 @@ objects: weight: 100 tls: termination: edge - insecureEdgeTerminationPolicy: Redirectss \ No newline at end of file + insecureEdgeTerminationPolicy: Redirects \ No newline at end of file From d5711bf29b1c9fd900bc3f32540c326f7f30146b Mon Sep 17 00:00:00 2001 From: "Fergus MacConnell WLRS:EX" Date: Wed, 4 Sep 2024 11:55:32 -0700 Subject: [PATCH 4/5] =?UTF-8?q?=F0=9F=99=83=20=F0=9F=99=83=20typo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/openshift.deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/openshift.deploy.yml b/frontend/openshift.deploy.yml index 38d4106ee..3ea89d5db 100644 --- a/frontend/openshift.deploy.yml +++ b/frontend/openshift.deploy.yml @@ -110,4 +110,4 @@ objects: weight: 100 tls: termination: edge - insecureEdgeTerminationPolicy: Redirects \ No newline at end of file + insecureEdgeTerminationPolicy: Redirect \ No newline at end of file From b59560f8262d4e3a31ecc3d49e4e2979f292aaae Mon Sep 17 00:00:00 2001 From: "Fergus MacConnell WLRS:EX" Date: Wed, 4 Sep 2024 13:13:45 -0700 Subject: [PATCH 5/5] Uncomment api url. --- frontend/openshift.deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/openshift.deploy.yml b/frontend/openshift.deploy.yml index 3ea89d5db..200f70da3 100644 --- a/frontend/openshift.deploy.yml +++ b/frontend/openshift.deploy.yml @@ -61,8 +61,8 @@ objects: env: - name: LOG_LEVEL value: info - # - name: VUE_APP_AXIOS_BASE_URL - # value: http://${APP}-${TARGET}/gwells/api/v2/ + - name: VUE_APP_AXIOS_BASE_URL + value: http://${APP}-${TARGET}/gwells/api/v2/ ports: - name: http containerPort: 5173