Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TechDebt: Replace Deprecated DeploymentConfig With Deployment. #1468

Merged
merged 12 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/cleanClosedPR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,5 @@ jobs:
env:
POD_SELECTOR: biohubbc
run: |
oc --namespace af2668-dev get all,pvc,secret,pods,ReplicationController,DeploymentConfig,HorizontalPodAutoscaler,imagestreamtag -o name | grep $POD_SELECTOR | grep $PR_NUMBER | awk '{print "oc delete --ignore-not-found " $1}' | bash
oc --namespace af2668-tools get all,pvc,secret,pods,ReplicationController,DeploymentConfig,HorizontalPodAutoscaler,imagestreamtag -o name | grep $POD_SELECTOR | grep $PR_NUMBER | awk '{print "oc delete --ignore-not-found " $1}' | bash
oc --namespace af2668-dev get all,pvc,secret,pods,ReplicationController,DeploymentConfig,Deployment,HorizontalPodAutoscaler,imagestreamtag -o name | grep $POD_SELECTOR | grep $PR_NUMBER | awk '{print "oc delete --ignore-not-found " $1}' | bash
NickPhura marked this conversation as resolved.
Show resolved Hide resolved
oc --namespace af2668-tools get all,pvc,secret,pods,ReplicationController,DeploymentConfig,Deployment,HorizontalPodAutoscaler,imagestreamtag -o name | grep $POD_SELECTOR | grep $PR_NUMBER | awk '{print "oc delete --ignore-not-found " $1}' | bash
4 changes: 2 additions & 2 deletions .github/workflows/cleanMergedPR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,5 @@ jobs:
env:
POD_SELECTOR: biohubbc
run: |
oc --namespace af2668-dev get all,pvc,secret,pods,ReplicationController,DeploymentConfig,HorizontalPodAutoscaler,imagestreamtag -o name | grep $POD_SELECTOR | grep $PR_NUMBER | awk '{print "oc delete --ignore-not-found " $1}' | bash
oc --namespace af2668-tools get all,pvc,secret,pods,ReplicationController,DeploymentConfig,HorizontalPodAutoscaler,imagestreamtag -o name | grep $POD_SELECTOR | grep $PR_NUMBER | awk '{print "oc delete --ignore-not-found " $1}' | bash
oc --namespace af2668-dev get all,pvc,secret,pods,ReplicationController,DeploymentConfig,Deployment,HorizontalPodAutoscaler,imagestreamtag -o name | grep $POD_SELECTOR | grep $PR_NUMBER | awk '{print "oc delete --ignore-not-found " $1}' | bash
oc --namespace af2668-tools get all,pvc,secret,pods,ReplicationController,DeploymentConfig,Deployment,HorizontalPodAutoscaler,imagestreamtag -o name | grep $POD_SELECTOR | grep $PR_NUMBER | awk '{print "oc delete --ignore-not-found " $1}' | bash
6 changes: 3 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ jobs:
# Why? The new pods will be deployed before the existing pods are terminated, and twice the resources will be needed
# in that moment. If not enough resources are available to spin up the new pods, then they may fail to deploy.
- name: Scale down app pods
run: oc get deploymentconfig --namespace af2668-dev --selector env-id=$PR_NUMBER,app-name=$APP_NAME -o name | awk '{print "oc scale --replicas=0 " $1}' | bash
run: oc get deployments --namespace af2668-dev --selector env-id=$PR_NUMBER,app-name=$APP_NAME -o name | awk '{print "oc scale --replicas=0 " $1}' | bash

# Install app pipeline node modules
# Note: This already caches node modules internally
Expand Down Expand Up @@ -254,7 +254,7 @@ jobs:
# Why? The new pods will be deployed before the existing pods are terminated, and twice the resources will be needed
# in that moment. If not enough resources are available to spin up the new pods, then they may fail to deploy.
- name: Scale down database pods
run: oc get deploymentconfig --namespace af2668-dev --selector env-id=$PR_NUMBER,app-name=$APP_NAME -o name | awk '{print "oc scale --replicas=0 " $1}' | bash
run: oc get deployments --namespace af2668-dev --selector env-id=$PR_NUMBER,app-name=$APP_NAME -o name | awk '{print "oc scale --replicas=0 " $1}' | bash

# Install database pipeline node modules
# Note: This already caches node modules internally
Expand Down Expand Up @@ -383,7 +383,7 @@ jobs:
# Why? The new pods will be deployed before the existing pods are terminated, and twice the resources will be needed
# in that moment. If not enough resources are available to spin up the new pods, then they may fail to deploy.
- name: Scale down api pods
run: oc get deploymentconfig --namespace af2668-dev --selector env-id=$PR_NUMBER,app-name=$APP_NAME -o name | awk '{print "oc scale --replicas=0 " $1}' | bash
run: oc get deployments --namespace af2668-dev --selector env-id=$PR_NUMBER,app-name=$APP_NAME -o name | awk '{print "oc scale --replicas=0 " $1}' | bash

# Install api pipeline node modules
# Note: This already caches node modules internally
Expand Down
120 changes: 60 additions & 60 deletions .github/workflows/deployStatic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
run: oc login --token=${{ secrets.TOOLS_SA_TOKEN }} --server=https://api.silver.devops.gov.bc.ca:6443

- name: Scale down
run: oc get deploymentconfig --namespace af2668-dev --selector env-id=$PR_NUMBER -o name | awk '{print "oc scale --replicas=0 " $1}' | bash
run: oc get deployments --namespace af2668-dev --selector env-id=$PR_NUMBER -o name | awk '{print "oc scale --replicas=0 " $1}' | bash

# Checkout the repo once and cache it for use in subsequent jobs
checkoutRepo:
Expand Down Expand Up @@ -431,62 +431,62 @@ jobs:
DEBUG=* npm run db:deploy -- --pr=$PR_NUMBER --env=$BRANCH --branch=$BRANCH --type=static

# Deploy Database setup image
# deployDatabaseSetup:
# name: Deploy Database Setup Image
# runs-on: ubuntu-latest
# timeout-minutes: 30
# if: ${{ github.event.pull_request.merged == true }}
# env:
# PR_NUMBER: ${{ github.event.number }}
# BRANCH: ${{ github.base_ref }}
# needs:
# - scaleDownPods
# - buildDatabaseSetup
# - deployDatabase
# steps:
# # Install Node - for `node` and `npm` commands
# - name: Setup Node.js
# uses: actions/setup-node@v4
# with:
# node-version: 20

# # Load repo from cache
# - name: Cache repo
# uses: actions/cache@v4
# id: cache-repo
# env:
# cache-name: cache-repo
# with:
# path: ${{ github.workspace }}/*
# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.event.pull_request.head.sha }}

# # Checkout the branch if not restored via cache
# - name: Checkout Target Branch
# if: steps.cache-repo.outputs.cache-hit != 'true'
# uses: actions/checkout@v4

# # Install oc, which was removed from the ubuntu-latest image in v24.04
# - name: Install OpenShift CLI tools
# uses: redhat-actions/openshift-tools-installer@v1
# with:
# oc: "4.14"

# # Log in to OpenShift.
# # Note: The secrets needed to log in are NOT available if the PR comes from a FORK.
# # PR's must originate from a branch off the original repo or else all openshift `oc` commands will fail.
# - name: Log in to OpenShift
# run: oc login --token=${{ secrets.TOOLS_SA_TOKEN }} --server=https://api.silver.devops.gov.bc.ca:6443

# # Install database pipeline node modules
# - name: Install database pipeline node modules
# working-directory: "database/.pipeline/"
# run: npm ci

# # Deploy the database setup image
# - name: Deploy Database Setup Image
# working-directory: "database/.pipeline/"
# run: |
# DEBUG=* npm run db-setup:deploy -- --pr=$PR_NUMBER --env=$BRANCH --branch=$BRANCH --type=static
deployDatabaseSetup:
name: Deploy Database Setup Image
runs-on: ubuntu-latest
timeout-minutes: 30
if: ${{ github.event.pull_request.merged == true }}
env:
PR_NUMBER: ${{ github.event.number }}
BRANCH: ${{ github.base_ref }}
needs:
- scaleDownPods
- buildDatabaseSetup
- deployDatabase
steps:
# Install Node - for `node` and `npm` commands
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20

# Load repo from cache
- name: Cache repo
uses: actions/cache@v4
id: cache-repo
env:
cache-name: cache-repo
with:
path: ${{ github.workspace }}/*
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.event.pull_request.head.sha }}

# Checkout the branch if not restored via cache
- name: Checkout Target Branch
if: steps.cache-repo.outputs.cache-hit != 'true'
uses: actions/checkout@v4

# Install oc, which was removed from the ubuntu-latest image in v24.04
- name: Install OpenShift CLI tools
uses: redhat-actions/openshift-tools-installer@v1
with:
oc: "4.14"

# Log in to OpenShift.
# Note: The secrets needed to log in are NOT available if the PR comes from a FORK.
# PR's must originate from a branch off the original repo or else all openshift `oc` commands will fail.
- name: Log in to OpenShift
run: oc login --token=${{ secrets.TOOLS_SA_TOKEN }} --server=https://api.silver.devops.gov.bc.ca:6443

# Install database pipeline node modules
- name: Install database pipeline node modules
working-directory: "database/.pipeline/"
run: npm ci

# Deploy the database setup image
- name: Deploy Database Setup Image
working-directory: "database/.pipeline/"
run: |
DEBUG=* npm run db-setup:deploy -- --pr=$PR_NUMBER --env=$BRANCH --branch=$BRANCH --type=static

# Deploy API image
deployAPI:
Expand Down Expand Up @@ -554,7 +554,7 @@ jobs:
if: ${{ github.event.pull_request.merged == true }}
needs:
- deployDatabase
# - deployDatabaseSetup
- deployDatabaseSetup
- deployAPI
- deployAPP
env:
Expand Down Expand Up @@ -623,5 +623,5 @@ jobs:
env:
POD_SELECTOR: biohubbc
run: |
oc --namespace af2668-dev get all,pvc,secret,pods,ReplicationController,DeploymentConfig,HorizontalPodAutoscaler,imagestreamtag -o name | grep $POD_SELECTOR | grep $PR_NUMBER | awk '{print "oc delete --ignore-not-found " $1}' | bash
oc --namespace af2668-tools get all,pvc,secret,pods,ReplicationController,DeploymentConfig,HorizontalPodAutoscaler,imagestreamtag -o name | grep $POD_SELECTOR | grep $PR_NUMBER | awk '{print "oc delete --ignore-not-found " $1}' | bash
oc --namespace af2668-dev get all,pvc,secret,pods,ReplicationController,DeploymentConfig,Deployment,HorizontalPodAutoscaler,imagestreamtag -o name | grep $POD_SELECTOR | grep $PR_NUMBER | awk '{print "oc delete --ignore-not-found " $1}' | bash
oc --namespace af2668-tools get all,pvc,secret,pods,ReplicationController,DeploymentConfig,Deployment,HorizontalPodAutoscaler,imagestreamtag -o name | grep $POD_SELECTOR | grep $PR_NUMBER | awk '{print "oc delete --ignore-not-found " $1}' | bash
2 changes: 1 addition & 1 deletion .github/workflows/toDraft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ jobs:
run: oc login --token=${{ secrets.TOOLS_SA_TOKEN }} --server=https://api.silver.devops.gov.bc.ca:6443

- name: Scale down
run: oc get deploymentconfig --namespace af2668-dev --selector env-id=$PR_NUMBER -o name | awk '{print "oc scale --replicas=0 " $1}' | bash
run: oc get deployments --namespace af2668-dev --selector env-id=$PR_NUMBER -o name | awk '{print "oc scale --replicas=0 " $1}' | bash
12 changes: 6 additions & 6 deletions api/.pipeline/lib/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const { OpenShiftClientX } = require('pipeline-cli');

/**
* Run OC commands to clean all build and deployment artifacts (pods, imagestreams, builds/deployment configs, etc).
* Run OC commands to clean all build and deployment artifacts (pods, imagestreams, builds/deployments, etc).
*
* @param {*} settings
*/
Expand Down Expand Up @@ -42,15 +42,15 @@ const clean = (settings) => {
}
});

// get deployment configs
let deploymentConfigs = oc.get('dc', {
// get deployments
let deployments = oc.get('deployments', {
selector: `app=${phaseObj.instance},env-id=${phaseObj.changeId},env-name=${phaseKey},!shared,github-repo=${oc.git.repository},github-owner=${oc.git.owner}`,
namespace: phaseObj.namespace
});

// Clean deployment configs
deploymentConfigs.forEach((deploymentConfig) => {
deploymentConfig.spec.triggers.forEach((trigger) => {
// Clean deployments
deployments.forEach((deployment) => {
deployment.spec.triggers.forEach((trigger) => {
if (trigger.type == 'ImageChange' && trigger.imageChangeParams.from.kind == 'ImageStreamTag') {
oc.delete([`ImageStreamTag/${trigger.imageChangeParams.from.name}`], {
'ignore-not-found': 'true',
Expand Down
42 changes: 13 additions & 29 deletions api/.pipeline/templates/api.dc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ objects:
requests:
storage: '${VOLUME_CAPACITY}'

- kind: DeploymentConfig
apiVersion: apps.openshift.io/v1
- kind: Deployment
apiVersion: apps/v1
metadata:
annotations:
openshift.io/generated-by: OpenShiftWebConsole
Expand All @@ -258,24 +258,18 @@ objects:
replicas: ${{REPLICAS}}
revisionHistoryLimit: 10
selector:
deploymentConfig: ${NAME}${SUFFIX}
matchLabels:
deployment: ${NAME}${SUFFIX}
strategy:
activeDeadlineSeconds: 21600
recreateParams:
timeoutSeconds: 600
resources:
requests:
cpu: ${CPU_REQUEST}
memory: ${MEMORY_REQUEST}
limits:
cpu: ${CPU_LIMIT}
memory: ${MEMORY_LIMIT}
type: Rolling
type: RollingUpdate
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
template:
metadata:
annotations: null
labels:
deploymentConfig: ${NAME}${SUFFIX}
deployment: ${NAME}${SUFFIX}
role: api
spec:
containers:
Expand Down Expand Up @@ -452,7 +446,7 @@ objects:
value: ${GCNOTIFY_SMS_URL}
- name: FEATURE_FLAGS
value: ${FEATURE_FLAGS}
image: ' '
image: ${BASE_IMAGE_REGISTRY_URL}/${NAMESPACE}/${NAME}:${VERSION}
imagePullPolicy: Always
ports:
- containerPort: ${{API_PORT_DEFAULT}}
Expand Down Expand Up @@ -499,16 +493,6 @@ objects:
persistentVolumeClaim:
claimName: ${NAME}${SUFFIX}
test: false
triggers:
- imageChangeParams:
automatic: true
containerNames:
- api
from:
kind: ImageStreamTag
name: ${NAME}:${VERSION}
type: ImageChange
- type: ConfigChange
status:
availableReplicas: 0
latestVersion: 0
Expand Down Expand Up @@ -542,7 +526,7 @@ objects:
protocol: TCP
targetPort: ${{API_PORT_DEFAULT}}
selector:
deploymentconfig: ${NAME}${SUFFIX}
deployment: ${NAME}${SUFFIX}
sessionAffinity: None
type: ClusterIP
status:
Expand Down Expand Up @@ -672,8 +656,8 @@ objects:
# minReplicas: ${{REPLICAS}}
# maxReplicas: ${{REPLICAS_MAX}}
# scaleTargetRef:
# apiVersion: apps.openshift.io/v1
# kind: DeploymentConfig
# kind: Deployment
# apiVersion: apps/v1
# name: ${NAME}${SUFFIX}
# metrics:
# - type: Resource
Expand Down
28 changes: 18 additions & 10 deletions api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"swagger-ui-express": "^4.3.0",
"typescript": "^4.7.4",
"utm": "^1.1.1",
"uuid": "^8.3.2",
"uuid": "^11.0.5",
"winston": "^3.3.3",
"winston-daily-rotate-file": "^5.0.0",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
Expand All @@ -90,7 +90,6 @@
"@types/sinon-chai": "^3.2.12",
"@types/swagger-ui-express": "^4.1.6",
"@types/utm": "^1.1.1",
"@types/uuid": "^8.3.1",
"@types/yamljs": "^0.2.31",
"@typescript-eslint/eslint-plugin": "~7.6.0",
"@typescript-eslint/parser": "~7.6.0",
Expand Down
Loading
Loading