From 3ee985f645f725ee6d675efcbce4e10572bdd912 Mon Sep 17 00:00:00 2001 From: Derek Roberts Date: Wed, 6 Nov 2024 08:42:10 -0800 Subject: [PATCH] ci!: deprecate deployment config, remove image stream - db only (#1302) * Deprecate deployment config, remove image stream - db --- .github/workflows/merge.yml | 8 ++--- .github/workflows/pr-open.yml | 4 +-- database/openshift.backup.yml | 21 +++++++----- database/openshift.deploy.yml | 62 +++++++++++++---------------------- database/openshift.dev.yml | 4 +-- 5 files changed, 43 insertions(+), 56 deletions(-) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index 216e09d53a..169aa9cdd1 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -124,7 +124,7 @@ jobs: overwrite: true parameters: -p ZONE=${{ env.ZONE }} -p NAME=${{ github.event.repository.name }} - -p PROMOTE=${{ github.repository }}/database:${{ env.ZONE }} + -p TAG=${{ env.ZONE }} - name: Backup database before update continue-on-error: true @@ -145,7 +145,7 @@ jobs: overwrite: false parameters: -p ZONE=${{ env.ZONE }} -p NAME=${{ github.event.repository.name }} - -p PROMOTE=${{ github.repository }}/database:${{ env.ZONE }} + -p TAG=${{ env.ZONE }} - name: Deploy Legacy uses: bcgov-nr/action-deployer-openshift@v3.0.1 @@ -335,7 +335,7 @@ jobs: overwrite: true parameters: -p ZONE=${{ env.ZONE }} -p NAME=${{ github.event.repository.name }} - -p PROMOTE=${{ github.repository }}/database:${{ env.PREV }} + -p TAG=${{ env.PREV }} - name: Install CLI tools from OpenShift Mirror uses: redhat-actions/openshift-tools-installer@v1 @@ -362,7 +362,7 @@ jobs: overwrite: false parameters: -p ZONE=${{ env.ZONE }} -p NAME=${{ github.event.repository.name }} - -p PROMOTE=${{ github.repository }}/database:${{ env.PREV }} + -p TAG=${{ env.PREV }} - name: Deploy Legacy uses: bcgov-nr/action-deployer-openshift@v3.0.1 diff --git a/.github/workflows/pr-open.yml b/.github/workflows/pr-open.yml index 91efbf53eb..0d43223044 100644 --- a/.github/workflows/pr-open.yml +++ b/.github/workflows/pr-open.yml @@ -269,7 +269,7 @@ jobs: overwrite: true parameters: -p ZONE=${{ github.event.number }} - -p PROMOTE=${{ github.repository }}/database:${{ github.event.number }} + -p TAG=${{ github.event.number }} - name: Install CLI tools from OpenShift Mirror uses: redhat-actions/openshift-tools-installer@v1 with: @@ -295,7 +295,7 @@ jobs: overwrite: false parameters: -p ZONE=${{ github.event.number }} - -p PROMOTE=${{ github.repository }}/database:${{ github.event.number }} + -p TAG=${{ github.event.number }} - name: Deploy Legacy uses: bcgov-nr/action-deployer-openshift@v3.0.1 diff --git a/database/openshift.backup.yml b/database/openshift.backup.yml index 0dd57c5d58..1513bab2b0 100644 --- a/database/openshift.backup.yml +++ b/database/openshift.backup.yml @@ -13,9 +13,15 @@ parameters: - name: ZONE description: Deployment zone, e.g. pr-### or prod required: true - - name: IMAGE_TAG - description: Image tag to use - value: latest + - name: TAG + description: Image tag; e.g. PR number, latest or prod + required: true + - name: REGISTRY + description: Container registry to import from (internal is image-registry.openshift-image-registry.svc:5000) + value: ghcr.io + - name: ORG + description: Organization name + value: bcgov - name: RESTORE_DIR description: Folder that contains initialization scripts value: /tmp/restore @@ -47,10 +53,7 @@ parameters: value: "0" - name: PVC_SIZE description: Volume space available for data, e.g. 512Mi, 2Gi. - value: 256Mi - - name: PROMOTE - description: Image (namespace/name:tag) to promote/import - required: true + value: 256Mi objects: - kind: PersistentVolumeClaim apiVersion: v1 @@ -92,7 +95,7 @@ objects: spec: containers: - name: ${NAME}-${ZONE}-${COMPONENT} - image: ${REGISTRY}/${PROMOTE} + image: ${REGISTRY}/${ORG}/${NAME}/${COMPONENT}:${TAG} command: ["/bin/sh", "-c"] args: - | @@ -187,7 +190,7 @@ objects: spec: containers: - name: ${NAME}-${ZONE}-${COMPONENT}-restore - image: ${REGISTRY}/${PROMOTE} + image: ${REGISTRY}/${ORG}/${NAME}/${COMPONENT}:${TAG} command: ["/bin/sh", "-c"] args: - | diff --git a/database/openshift.deploy.yml b/database/openshift.deploy.yml index 2683234cdc..9bb38f79e9 100644 --- a/database/openshift.deploy.yml +++ b/database/openshift.deploy.yml @@ -13,9 +13,15 @@ parameters: - name: ZONE description: Deployment zone, e.g. pr-### or prod required: true - - name: IMAGE_TAG - description: Image tag to use - value: latest + - name: TAG + description: Image tag; e.g. PR number, latest or prod + required: true + - name: REGISTRY + description: Container registry to import from (internal is image-registry.openshift-image-registry.svc:5000) + value: ghcr.io + - name: ORG + description: Organization name + value: bcgov - name: PVC_MOUNT_PATH description: Where to mount the PVC, subpath (e.g. data/) value: /var/lib/postgresql @@ -76,14 +82,15 @@ parameters: value: "0" - description: Volume space available for data, e.g. 512Mi, 2Gi. name: PVC_SIZE - value: 256Mi + value: 256Mi - name: CRON_MINUTES description: Random number, 0-60, for scheduling cronjobs from: "[0-5]{1}[0-9]{1}" + generate: expression + - name: RANDOM_EXPRESSION + description: Random expression to make sure deployments update + from: "[a-zA-Z0-9]{32}" generate: expression - - name: PROMOTE - description: Image (namespace/name:tag) to promote/import - required: true objects: - kind: PersistentVolumeClaim apiVersion: v1 @@ -98,42 +105,17 @@ objects: requests: storage: ${DB_PVC_SIZE} storageClassName: netapp-file-standard - - kind: ImageStream - apiVersion: v1 - metadata: - name: ${NAME}-${ZONE}-${COMPONENT} - labels: - app: ${NAME}-${ZONE} - spec: - lookupPolicy: - local: false - tags: - - name: ${IMAGE_TAG} - from: - kind: DockerImage - name: ${REGISTRY}/${PROMOTE} - referencePolicy: - type: Local - - kind: DeploymentConfig - apiVersion: v1 + - kind: Deployment + apiVersion: apps/v1 metadata: name: ${NAME}-${ZONE}-${COMPONENT} labels: app: ${NAME}-${ZONE} spec: replicas: 1 - triggers: - - type: ConfigChange - - type: ImageChange - imageChangeParams: - automatic: true - containerNames: - - ${NAME} - from: - kind: ImageStreamTag - name: ${NAME}-${ZONE}-${COMPONENT}:${IMAGE_TAG} selector: - deploymentconfig: ${NAME}-${ZONE}-${COMPONENT} + matchLabels: + deployment: ${NAME}-${ZONE}-${COMPONENT} strategy: type: Recreate recreateParams: @@ -144,7 +126,7 @@ objects: name: ${NAME}-${ZONE}-${COMPONENT} labels: app: ${NAME}-${ZONE} - deploymentconfig: ${NAME}-${ZONE}-${COMPONENT} + deployment: ${NAME}-${ZONE}-${COMPONENT} spec: volumes: - name: ${NAME}-${ZONE}-${COMPONENT} @@ -152,7 +134,7 @@ objects: claimName: ${NAME}-${ZONE}-${COMPONENT} containers: - name: ${NAME} - image: ${NAME}-${ZONE}-${COMPONENT}:${IMAGE_TAG} + image: ${REGISTRY}/${ORG}/${NAME}/${COMPONENT}:${TAG} ports: - containerPort: 5432 protocol: TCP @@ -194,6 +176,8 @@ objects: secretKeyRef: name: ${NAME}-${ZONE} key: database-user + - name: RANDOM_EXPRESSION + value: ${RANDOM_EXPRESSION} volumeMounts: - name: ${NAME}-${ZONE}-${COMPONENT} mountPath: ${PVC_MOUNT_PATH} @@ -218,6 +202,6 @@ objects: protocol: TCP targetPort: 5432 selector: - deploymentconfig: ${NAME}-${ZONE}-${COMPONENT} + deployment: ${NAME}-${ZONE}-${COMPONENT} sessionAffinity: None type: ClusterIP diff --git a/database/openshift.dev.yml b/database/openshift.dev.yml index 6334f124c5..6964689cb7 100644 --- a/database/openshift.dev.yml +++ b/database/openshift.dev.yml @@ -26,7 +26,7 @@ objects: name: ${NAME}-${ZONE}-${COMPONENT} labels: app: ${NAME}-${ZONE} - deploymentconfig: ${NAME}-${ZONE}-${COMPONENT} + deployment: ${NAME}-${ZONE}-${COMPONENT} spec: containers: - name: ${NAME} @@ -61,4 +61,4 @@ objects: name: ${NAME}-${ZONE} key: "database-password" imagePullPolicy: Always - restartPolicy: Never \ No newline at end of file + restartPolicy: Never