Skip to content

Commit

Permalink
chore(ci): deploymentconfig deprecation (#701)
Browse files Browse the repository at this point in the history
* chore(ci): deploymentconfig deprecation

* Drop imagestreams

* Random envar to ensure rollouts

* Remove promote param

* Temporarily comment out workflow jobs

* Remove param

* Remove param

* Fix ZONE var reset

* Template fix

* Use one init job

* Adjust image paths

* Restore workflows

* Restore workflows

* Promote PROD images before deployment
  • Loading branch information
DerekRoberts authored Oct 22, 2024
1 parent 520e6a3 commit 0e3ea4b
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 204 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/merge-demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ jobs:
file: api/openshift.deploy.yml
overwrite: true
parameters:
-p OC_NAMESPACE=${{ vars.OC_NAMESPACE }}
-p URL=fom-demo.apps.silver.devops.gov.bc.ca
-p [email protected]
-p DB_TESTDATA=true
Expand All @@ -69,7 +68,6 @@ jobs:
- name: db
file: db/openshift.deploy.yml
overwrite: false
parameters: -p OC_NAMESPACE=${{ vars.OC_NAMESPACE }}
- name: init
file: libs/openshift.init.yml
overwrite: false
Expand All @@ -87,5 +85,4 @@ jobs:
overwrite: ${{ matrix.overwrite }}
penetration_test: false
parameters:
-p PROMOTE=ghcr.io/${{ github.repository }}/${{ matrix.name }}:${{ env.ZONE }}
-p ZONE=${{ env.ZONE }} ${{ matrix.parameters }}
38 changes: 16 additions & 22 deletions .github/workflows/merge-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jobs:
oc_version: "4.13"
overwrite: true
parameters:
-p OC_NAMESPACE=${{ vars.OC_NAMESPACE }}
-p URL=fom-test.nrs.gov.bc.ca
-p [email protected]
-p DB_TESTDATA=true
Expand All @@ -45,7 +44,6 @@ jobs:
- name: db
file: db/openshift.deploy.yml
overwrite: false
parameters: -p OC_NAMESPACE=${{ vars.OC_NAMESPACE }}
- name: init
file: libs/openshift.init.yml
overwrite: false
Expand All @@ -64,13 +62,27 @@ jobs:
overwrite: ${{ matrix.overwrite }}
penetration_test: false
parameters:
-p PROMOTE=${{ github.repository }}/${{ matrix.name }}:${{ env.ZONE }}
-p ZONE=${{ env.ZONE }} ${{ matrix.parameters }}
post_rollout: ${{ matrix.post_rollout }}

prod-promotions:
name: Promote images to PROD
needs: [deploy-test]
runs-on: ubuntu-22.04
strategy:
matrix:
component: [api, admin, db, public]
steps:
- uses: shrink/actions-docker-registry-tag@v4
with:
registry: ghcr.io
repository: ${{ github.repository }}/${{ matrix.component }}
target: test
tags: prod

deploy-prod:
name: PROD Deploys
needs: [deploy-test]
needs: [prod-promotions]
environment: prod
env:
ZONE: prod
Expand All @@ -85,7 +97,6 @@ jobs:
oc_version: "4.13"
overwrite: true
parameters:
-p OC_NAMESPACE=${{ vars.OC_NAMESPACE }}
-p URL=fom.nrs.gov.bc.ca
-p AWS_USER_POOLS_WEB_CLIENT_ID="4bu2n8at3m32a2fqnvd4t06la1"
-p LOGOUT_CHAIN_URL="https://logon7.gov.bc.ca/clp-cgi/logoff.cgi?retnow=1&returl=https://loginproxy.gov.bc.ca/auth/realms/standard/protocol/openid-connect/logout?redirect_uri="
Expand All @@ -98,7 +109,6 @@ jobs:
- name: db
file: db/openshift.deploy.yml
overwrite: false
parameters: -p OC_NAMESPACE=${{ vars.OC_NAMESPACE }}
- name: init
file: libs/openshift.init.yml
overwrite: false
Expand All @@ -117,21 +127,5 @@ jobs:
overwrite: ${{ matrix.overwrite }}
penetration_test: false
parameters:
-p PROMOTE=${{ github.repository }}/${{ matrix.name }}:test
-p ZONE=${{ env.ZONE }} ${{ matrix.parameters }}
post_rollout: ${{ matrix.post_rollout }}

image-promotions:
name: Promote images to PROD
needs: [deploy-prod]
runs-on: ubuntu-22.04
strategy:
matrix:
component: [api, admin, db, public]
steps:
- uses: shrink/actions-docker-registry-tag@v4
with:
registry: ghcr.io
repository: ${{ github.repository }}/${{ matrix.component }}
target: test
tags: prod
35 changes: 11 additions & 24 deletions .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,19 @@ concurrency:
cancel-in-progress: true

jobs:
setup:
name: Reset the deployment number
init:
name: Init
permissions:
pull-requests: write
runs-on: ubuntu-22.04
outputs:
zone: ${{ steps.calculate.outputs.zone }}
route_number: ${{ steps.calculate.outputs.route_number }}
steps:
- name: Calculate the deployment number
id: calculate
run: |
echo "zone=$((${{ github.event.number }} % 50))" >> $GITHUB_OUTPUT
echo "route_number=$((${{ github.event.number }} % 50))" >> $GITHUB_OUTPUT
prep:
name: Prep
permissions:
pull-requests: write
runs-on: ubuntu-22.04
needs: setup
steps:
- name: OpenShift Init
uses: bcgov-nr/[email protected]
with:
Expand All @@ -35,17 +30,14 @@ jobs:
oc_token: ${{ secrets.OC_TOKEN }}
file: libs/openshift.init.yml
overwrite: false
parameters: -p ZONE=${{ needs.setup.outputs.zone }}
parameters: -p ZONE=${{ github.event.number }}
triggers: ('db/' 'libs/' 'api/' 'admin/' 'public/')

builds:
name: Builds
runs-on: ubuntu-22.04
permissions:
packages: write
needs: setup
env:
ZONE: ${{ needs.setup.outputs.zone }}
strategy:
matrix:
package: [admin, api, db, public]
Expand All @@ -72,17 +64,15 @@ jobs:
build_context: ${{ matrix.build_context }}
build_file: ${{ matrix.build_file }}
keep_versions: 100
tag: ${{ env.ZONE }}
tag: ${{ github.event.number }}
tag_fallback: test
token: ${{ secrets.GITHUB_TOKEN }}
triggers: ${{ matrix.triggers }}

deploys:
name: Deploys
needs: [prep, builds, setup]
needs: [builds, init]
runs-on: ubuntu-22.04
env:
ZONE: ${{ needs.setup.outputs.zone }}
timeout-minutes: 10
strategy:
matrix:
Expand All @@ -92,7 +82,6 @@ jobs:
file: api/openshift.deploy.yml
overwrite: true
parameters:
-p OC_NAMESPACE=${{ vars.OC_NAMESPACE }}
-p REPLICA_COUNT=1
-p [email protected]
-p DB_TESTDATA=true
Expand All @@ -107,7 +96,6 @@ jobs:
- name: db
file: db/openshift.deploy.yml
overwrite: false
parameters: -p OC_NAMESPACE=${{ vars.OC_NAMESPACE }}
triggers: ('db/' 'libs/' 'api/' 'admin/' 'public/')
- name: public
file: public/openshift.deploy.yml
Expand All @@ -124,7 +112,6 @@ jobs:
overwrite: ${{ matrix.overwrite }}
penetration_test: false
parameters:
-p PROMOTE=${{ github.repository }}/${{ matrix.name }}:${{ env.ZONE }}
-p URL=fom-${{ env.ZONE }}.apps.silver.devops.gov.bc.ca
-p ZONE=${{ env.ZONE }} ${{ matrix.parameters }}
-p URL=fom-${{ needs.init.outputs.route_number }}.apps.silver.devops.gov.bc.ca
-p ZONE=${{ github.event.number }} ${{ matrix.parameters }}
triggers: ${{ matrix.triggers }}
56 changes: 20 additions & 36 deletions admin/openshift.deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ parameters:
- name: REGISTRY
description: Container registry to import from (internal is image-registry.openshift-image-registry.svc:5000)
value: ghcr.io
- name: PROMOTE
description: Image (namespace/name:tag) to promote/import
required: true
- name: ORG
description: Organization name
value: bcgov
- name: ORG
description: Organization name
value: bcgov
- description: Number of replicas
displayName: Replica Count
name: REPLICA_COUNT
Expand All @@ -42,23 +45,11 @@ parameters:
name: CADDY_DATA_PVC_SIZE
required: true
value: 22Mi
- name: RANDOM_EXPRESSION
description: Random expression to make sure deployments update
from: "[a-zA-Z0-9]{32}"
generate: expression
objects:
- apiVersion: v1
kind: ImageStream
metadata:
labels:
app: ${NAME}-${ZONE}
name: ${NAME}-${ZONE}-${COMPONENT}
spec:
lookupPolicy:
local: false
tags:
- name: ${ZONE}-${COMPONENT}
from:
kind: DockerImage
name: ${REGISTRY}/${PROMOTE}
referencePolicy:
type: Local
- kind: ConfigMap
apiVersion: v1
data:
Expand All @@ -67,8 +58,8 @@ objects:
window.localStorage.setItem('fom_api_base_url', 'https://${URL}');
metadata:
name: ${NAME}-${ZONE}-${COMPONENT}
- apiVersion: v1
kind: DeploymentConfig
- apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: ${NAME}-${ZONE}
Expand All @@ -78,34 +69,25 @@ objects:
revisionHistoryLimit: 10
test: false
strategy:
type: Rolling
type: RollingUpdate
rollingParams:
updatePeriodSeconds: 1
intervalSeconds: 1
timeoutSeconds: 600
maxUnavailable: 25%
maxSurge: 25%
activeDeadlineSeconds: 21600
triggers:
- type: ConfigChange
- type: ImageChange
imageChangeParams:
automatic: true
containerNames:
- ${NAME}
from:
kind: ImageStreamTag
name: ${NAME}-${ZONE}-${COMPONENT}:${ZONE}-${COMPONENT}
selector:
deploymentconfig: ${NAME}-${ZONE}-${COMPONENT}
matchLabels:
deployment: ${NAME}-${ZONE}-${COMPONENT}
template:
metadata:
labels:
app: ${NAME}-${ZONE}
deploymentconfig: ${NAME}-${ZONE}-${COMPONENT}
deployment: ${NAME}-${ZONE}-${COMPONENT}
spec:
containers:
- image: ${NAME}-${ZONE}-${COMPONENT}:${ZONE}-${COMPONENT}
- image: ${REGISTRY}/${ORG}/nr-fom/${COMPONENT}:${ZONE}
securityContext:
capabilities:
add: ["NET_BIND_SERVICE"]
Expand All @@ -116,6 +98,8 @@ objects:
value: fom-${ZONE}-api
- name: fom_api_base_url
value: fom-${ZONE}-api
- name: RANDOM_EXPRESSION
value: ${RANDOM_EXPRESSION}
ports:
- containerPort: 4200
protocol: TCP
Expand Down Expand Up @@ -170,7 +154,7 @@ objects:
port: 80
targetPort: 4200
selector:
deploymentconfig: ${NAME}-${ZONE}-${COMPONENT}
deployment: ${NAME}-${ZONE}-${COMPONENT}
- apiVersion: route.openshift.io/v1
kind: Route
metadata:
Expand Down
Loading

0 comments on commit 0e3ea4b

Please sign in to comment.