Skip to content

Commit

Permalink
feat: add deployment updates to qa, uat, prod
Browse files Browse the repository at this point in the history
  • Loading branch information
trev-dev committed Nov 7, 2024
1 parent 53a69d0 commit 1546eac
Show file tree
Hide file tree
Showing 7 changed files with 214 additions and 24 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/deploy-to-openshift-backend-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:
oc login --token=${{ env.OPENSHIFT_TOKEN }} --server=${{ env.OPENSHIFT_SERVER }}
oc project ${{ env.OPENSHIFT_NAMESPACE }}
# Cancel any rollouts in progress
oc rollout cancel dc/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \
oc rollout cancel deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \
|| true && echo "No rollout in progress"
# Create tag for PROD env from DEV env image
Expand All @@ -121,7 +121,7 @@ jobs:
# Process and apply deployment template
oc process \
-f tools/openshift/backend.dc.yaml \
-f tools/openshift/backend.deployment.yaml \
-p APP_NAME=${{ env.APP_NAME }} \
-p REPO_NAME=${{ env.REPO_NAME }} \
-p BRANCH=${{ env.BRANCH }} \
Expand Down Expand Up @@ -153,8 +153,8 @@ jobs:
${{ secrets.D365_API_PREFIX }}
# Start rollout (if necessary) and follow it
oc rollout latest dc/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \
oc rollout latest deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \
|| true && echo "Rollout in progress"
# Get status, returns 0 if rollout is successful
oc rollout status dc/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }}
oc rollout status deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }}
8 changes: 4 additions & 4 deletions .github/workflows/deploy-to-openshift-backend-qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ jobs:
oc login --token=${{ env.OPENSHIFT_TOKEN }} --server=${{ env.OPENSHIFT_SERVER }}
oc project ${{ env.OPENSHIFT_NAMESPACE }}
# Cancel any rollouts in progress
oc rollout cancel dc/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \
oc rollout cancel deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \
|| true && echo "No rollout in progress"
# Process and apply deployment template
oc process \
-f tools/openshift/backend-no-fb.dc.yaml \
-f tools/openshift/backend-no-fb.deployment.yaml \
-p APP_NAME=${{ env.APP_NAME }} \
-p REPO_NAME=${{ env.REPO_NAME }} \
-p BRANCH=${{ env.BRANCH }} \
Expand Down Expand Up @@ -148,11 +148,11 @@ jobs:
${{ secrets.D365_API_PREFIX }}
# Start rollout (if necessary) and follow it
oc rollout latest dc/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \
oc rollout latest deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \
|| true && echo "Rollout in progress"
# Get status, returns 0 if rollout is successful
oc rollout status dc/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }}
oc rollout status deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }}
- name: ZAP Scan
uses: zaproxy/[email protected]
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy-to-openshift-backend-uat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:
oc login --token=${{ env.OPENSHIFT_TOKEN }} --server=${{ env.OPENSHIFT_SERVER }}
oc project ${{ env.OPENSHIFT_NAMESPACE }}
# Cancel any rollouts in progress
oc rollout cancel dc/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \
oc rollout cancel deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \
|| true && echo "No rollout in progress"
# Create tag for TEST env from DEV env image
Expand All @@ -121,7 +121,7 @@ jobs:
# Process and apply deployment template
oc process \
-f tools/openshift/backend.dc.yaml \
-f tools/openshift/backend.deployment.yaml \
-p APP_NAME=${{ env.APP_NAME }} \
-p REPO_NAME=${{ env.REPO_NAME }} \
-p BRANCH=${{ env.BRANCH }} \
Expand Down Expand Up @@ -153,11 +153,11 @@ jobs:
${{ secrets.D365_API_PREFIX }}
# Start rollout (if necessary) and follow it
oc rollout latest dc/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }}} 2> /dev/null \
oc rollout latest deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }}} 2> /dev/null \
|| true && echo "Rollout in progress"
# Get status, returns 0 if rollout is successful
oc rollout status dc/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }}
oc rollout status deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }}
- name: ZAP Scan
uses: zaproxy/[email protected]
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy-to-openshift-frontend-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ jobs:
oc login --token=${{ env.OPENSHIFT_TOKEN }} --server=${{ env.OPENSHIFT_SERVER }}
oc project ${{ env.OPENSHIFT_NAMESPACE }}
# Cancel any rollouts in progress
oc rollout cancel dc/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \
oc rollout cancel deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \
|| true && echo "No rollout in progress"
# Create tag for PROD env from DEV env image
Expand All @@ -126,7 +126,7 @@ jobs:
# Process and apply deployment template
oc process \
-f tools/openshift/frontend.dc.yaml \
-f tools/openshift/frontend.deployment.yaml \
-p APP_NAME=${{ env.APP_NAME }} \
-p REPO_NAME=${{ env.REPO_NAME }} \
-p BRANCH=${{ env.BRANCH }} \
Expand All @@ -149,8 +149,8 @@ jobs:
| oc apply -f -
# Start rollout (if necessary) and follow it
oc rollout latest dc/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \
oc rollout latest deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \
|| true && echo "Rollout in progress"
# Get status, returns 0 if rollout is successful
oc rollout status dc/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }}
oc rollout status deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }}
8 changes: 4 additions & 4 deletions .github/workflows/deploy-to-openshift-frontend-qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ jobs:
oc login --token=${{ env.OPENSHIFT_TOKEN }} --server=${{ env.OPENSHIFT_SERVER }}
oc project ${{ env.OPENSHIFT_NAMESPACE }}
# Cancel any rollouts in progress
oc rollout cancel dc/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \
oc rollout cancel deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \
|| true && echo "No rollout in progress"
# Process and apply deployment template
oc process \
-f tools/openshift/frontend.dc.yaml \
-f tools/openshift/frontend.deployment.yaml \
-p APP_NAME=${{ env.APP_NAME }} \
-p REPO_NAME=${{ env.REPO_NAME }} \
-p BRANCH=${{ env.BRANCH }} \
Expand All @@ -142,11 +142,11 @@ jobs:
| oc apply -f -
# Start rollout (if necessary) and follow it
oc rollout latest dc/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \
oc rollout latest deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \
|| true && echo "Rollout in progress"
# Get status, returns 0 if rollout is successful
oc rollout status dc/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }}
oc rollout status deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }}
- name: ZAP Scan
uses: zaproxy/[email protected]
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy-to-openshift-frontend-uat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ jobs:
oc login --token=${{ env.OPENSHIFT_TOKEN }} --server=${{ env.OPENSHIFT_SERVER }}
oc project ${{ env.OPENSHIFT_NAMESPACE }}
# Cancel any rollouts in progress
oc rollout cancel dc/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \
oc rollout cancel deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \
|| true && echo "No rollout in progress"
# Create tag for TEST env from DEV env image
Expand All @@ -126,7 +126,7 @@ jobs:
# Process and apply deployment template
oc process \
-f tools/openshift/frontend.dc.yaml \
-f tools/openshift/frontend.deployment.yaml \
-p APP_NAME=${{ env.APP_NAME }} \
-p REPO_NAME=${{ env.REPO_NAME }} \
-p BRANCH=${{ env.BRANCH }} \
Expand All @@ -149,11 +149,11 @@ jobs:
| oc apply -f -
# Start rollout (if necessary) and follow it
oc rollout latest dc/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \
oc rollout latest deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \
|| true && echo "Rollout in progress"
# Get status, returns 0 if rollout is successful
oc rollout status dc/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }}
oc rollout status deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }}
- name: ZAP Scan
uses: zaproxy/[email protected]
Expand Down
190 changes: 190 additions & 0 deletions tools/openshift/backend.no-fb.deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
---
apiVersion: template.openshift.io/v1
kind: Template
metadata:
name: "${REPO_NAME}-backend-deployment"
labels:
template: "${REPO_NAME}-template"
objects:
- apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
openshift.io/generated-by: OpenShiftNewApp
labels:
app: "${APP_NAME}-${BRANCH}"
branch: "${BRANCH}"
name: "${APP_NAME}-backend-${APP_ENVIRONMENT}"
spec:
replicas: ${{MIN_REPLICAS}}
selector:
matchLabels:
app: "${APP_NAME}-${BRANCH}"
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 25%
maxSurge: 25%
template:
metadata:
annotations:
openshift.io/generated-by: OpenShiftNewApp
labels:
app: "${APP_NAME}-${BRANCH}"
spec:
containers:
- image: image-registry.openshift-image-registry.svc:5000/${NAMESPACE}/${REPO_NAME}-backend-${BRANCH}:${TAG}
imagePullPolicy: Always
volumeMounts:
- name: tls-certs
mountPath: "/etc/tls-certs"
readOnly: true
- name: log-storage
mountPath: /logs
livenessProbe:
initialDelaySeconds: 20
failureThreshold: 5
httpGet:
path: "/api/health"
port: 8080
scheme: HTTP
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 5
name: "${APP_NAME}-backend-${APP_ENVIRONMENT}"
ports:
- containerPort: 8080
protocol: TCP
- containerPort: 443
protocol: TCP
envFrom:
- configMapRef:
name: ccof-backend-${APP_ENVIRONMENT}-config-map
readinessProbe:
initialDelaySeconds: 10
failureThreshold: 5
httpGet:
path: "/api/health"
port: 8080
scheme: HTTP
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 5
resources:
requests:
cpu: "${MIN_CPU}"
memory: "${MIN_MEM}"
limits:
cpu: "${MAX_CPU}"
memory: "${MAX_MEM}"
volumes:
- name: log-storage
emptyDir: {}
- name: tls-certs
secret:
secretName: ccof-backend-cert
test: false
- apiVersion: v1
kind: Service
metadata:
annotations:
service.alpha.openshift.io/serving-cert-secret-name: "ccof-backend-cert"
openshift.io/generated-by: OpenShiftNewApp
labels:
app: "${APP_NAME}-${BRANCH}"
name: "${APP_NAME}-backend-${APP_ENVIRONMENT}"
spec:
ports:
- name: 8080-tcp
port: 8080
protocol: TCP
targetPort: 8080
- name: 443-https
port: 443
protocol: TCP
targetPort: 443
selector:
app: "${APP_NAME}-${BRANCH}"
- apiVersion: v1
kind: Route
metadata:
annotations:
haproxy.router.openshift.io/rate-limit-connections: 'true'
haproxy.router.openshift.io/rate-limit-connections.concurrent-tcp: '10'
haproxy.router.openshift.io/rate-limit-connections.rate-http: '50'
haproxy.router.openshift.io/timeout: 120s
openshift.io/host.generated: 'true'
labels:
app: "${APP_NAME}-${BRANCH}"
name: "${APP_NAME}-backend-${APP_ENVIRONMENT}"
spec:
host: "${HOST_ROUTE}"
path: /api
port:
targetPort: 8080-tcp
tls:
insecureEdgeTerminationPolicy: Redirect
termination: edge
to:
kind: Service
name: "${APP_NAME}-backend-${APP_ENVIRONMENT}"
weight: 100
wildcardPolicy: None
- apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: "${APP_NAME}-backend-${APP_ENVIRONMENT}-cpu-autoscaler"
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: "${APP_NAME}-backend-${APP_ENVIRONMENT}"
minReplicas: ${{MIN_REPLICAS}}
maxReplicas: ${{MAX_REPLICAS}}
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 90
parameters:
- name: REPO_NAME
description: Application repository name
required: true
- name: BRANCH
description: Job identifier (i.e. 'pr-5' OR 'master')
required: true
- name: NAMESPACE
description: Target namespace reference (i.e. 'k8vopl-dev')
required: true
- name: APP_NAME
description: Application name
required: true
- name: HOST_ROUTE
description: The host the route will use to expose service outside cluster
required: true
- name: TAG
description: The identifying tag for this specific deployment
required: true
- name: MIN_REPLICAS
description: The minimum amount of replicas
required: true
- name: MAX_REPLICAS
description: The maximum amount of replicas
required: true
- name: MIN_CPU
description: The minimum amount of cpu
required: true
- name: MAX_CPU
description: The maximum amount of cpu
required: true
- name: MIN_MEM
description: The minimum amount of memory
required: true
- name: MAX_MEM
description: The maximum amount of memory
required: true
- name: APP_ENVIRONMENT
description: The environment being created ('dev', 'qa', 'uat', 'prod')
required: true

0 comments on commit 1546eac

Please sign in to comment.