Skip to content

Commit

Permalink
Merge pull request #301 from bcgov/new-tag
Browse files Browse the repository at this point in the history
adding prod route and service templates, changing application health …
  • Loading branch information
akroon3r authored Jul 7, 2022
2 parents fb108b2 + ecbe47f commit 192aacf
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 41 deletions.
7 changes: 6 additions & 1 deletion .github/helpers/application-health.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@

# script to watch deployment of deployment config in a given namespace to ensure it is healthy and works

oc rollout status -n $NAMESPACE dc/$APPLICATION_NAME-${IMAGE_TAG} --watch
if [-z "$IMAGE_TAG"]
then
oc rollout status -n $NAMESPACE dc/$APPLICATION_NAME --watch
else
oc rollout status -n $NAMESPACE dc/$APPLICATION_NAME-$IMAGE_TAG --watch
fi
63 changes: 23 additions & 40 deletions .github/workflows/build-deploy-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -426,28 +426,11 @@ jobs:
runs-on: ubuntu-latest
needs: [TEST-cleanup]
steps:
#diff
- name: Checkout Repository
uses: actions/checkout@v2
with:
fetch-depth: 0

# - name: Find Tag
# id: tagger
# uses: jimschubert/query-tag-action@v1
# with:
# include: 'v*'
# # if you unshallow in a separate step, use the following option:
# # skip-unshallow: 'true'

# - name: Show Tag
# id: display
# run: |
# echo 'Output from Find Tag: ${{steps.tagger.outputs.tag}}'

# tag=$(echo ${{steps.tagger.outputs.tag}})
# echo "previous_tag=$tag" >> $GITHUB_ENV

- name: Find Tag
id: tagger
run: |
Expand Down Expand Up @@ -594,34 +577,34 @@ jobs:
LICENSE_PLATE: "${{ secrets.LICENSE_PLATE }}"
ENVIRONMENT: "${{ secrets.ENVIRONMENT }}"
DC_TEMPLATE: api-dc-template-prod.yaml
SERVICE_TEMPLATE: api-service-template.yaml
ROUTE_TEMPLATE: api-route-template.yaml
SERVICE_TEMPLATE: api-service-template-prod.yaml
ROUTE_TEMPLATE: api-route-template-prod.yaml
IMAGE_TAG: ${{ env.image_tag }}
DIR: "api"
run: |
./.github/helpers/deploy.sh
# PROD-health-check:
# runs-on: ubuntu-latest
# environment: Prod
# needs: [DPIA-API-Build-Tag-Push, DEV-deploy, DEV-health-check, TEST-tag-dpia-api-image, TEST-deploy, TEST-health-check, PROD-tag-dpia-api-image, PROD-deploy]
# steps:
PROD-health-check:
runs-on: ubuntu-latest
environment: Prod
needs: [PROD-deploy]
steps:

# - uses: actions/checkout@v2
- uses: actions/checkout@v2

# - name: Cluster Login
# uses: redhat-developer/openshift-actions@v1.1
# with:
# openshift_server_url: ${{ secrets.OPENSHIFT4_SERVER_URL }}
# parameters: '{"apitoken": "${{ secrets.OPENSHIFT4_SA_PASSWORD }}"}'
# cmd: |
# 'version'
- name: Cluster Login
uses: redhat-developer/openshift-actions@v1.1
with:
openshift_server_url: ${{ secrets.OPENSHIFT4_SERVER_URL }}
parameters: '{"apitoken": "${{ secrets.OPENSHIFT4_SA_PASSWORD }}"}'
cmd: |
'version'
# - name: Health Check PROD deployment
# env:
# NAMESPACE: "${{ secrets.OPENSHIFT_PROD_NAMESPACE }}"
# APPLICATION_NAME: "${{ secrets.API_APPLICATION_NAME }}"
# LICENSE_PLATE: "${{ secrets.LICENSE_PLATE }}"
# ENVIRONMENT: "${{ secrets.ENVIRONMENT }}"
# run: |
# ./.github/helpers/application-health.sh
- name: Health Check PROD deployment
env:
NAMESPACE: "${{ secrets.OPENSHIFT_PROD_NAMESPACE }}"
APPLICATION_NAME: "${{ secrets.API_APPLICATION_NAME }}"
LICENSE_PLATE: "${{ secrets.LICENSE_PLATE }}"
ENVIRONMENT: "${{ secrets.ENVIRONMENT }}"
run: |
./.github/helpers/application-health.sh
57 changes: 57 additions & 0 deletions openshift/templates/api/api-route-template-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
apiVersion: template.openshift.io/v1
kind: Template
metadata:
name: ${APPLICATION_NAME}-template
labels:
template: ${APPLICATION_NAME}-template
objects:
- kind: Route
apiVersion: route.openshift.io/v1
metadata:
name: ${APPLICATION_NAME}-${IMAGE_TAG}
namespace: ${LICENSE_PLATE}-${ENVIRONMENT}
spec:
host: ${APPLICATION_NAME}-${IMAGE_TAG}-${ENVIRONMENT}.apps.silver.devops.gov.bc.ca
path: /api/v1/api-docs
to:
kind: Service
name: ${APPLICATION_NAME}
weight: 100
port:
targetPort: 3000-tcp
tls:
termination: edge
insecureEdgeTerminationPolicy: None
wildcardPolicy: None
status:
ingress:
- host: ${APPLICATION_NAME}-${IMAGE_TAG}-${ENVIRONMENT}.apps.silver.devops.gov.bc.ca
routerName: default
conditions:
- type: Admitted
status: 'True'
lastTransitionTime: '2022-06-28T18:13:10Z'
wildcardPolicy: None
routerCanonicalHostname: router-default.apps.silver.devops.gov.bc.ca

parameters:
- description: Application Name
displayName: AppName
name: APPLICATION_NAME
required: true
value: dpia-api
- description: Environment
displayName: Environment
name: ENVIRONMENT
required: true
value: dev
- description: License Plate
displayName: License Plate
name: LICENSE_PLATE
required: true
value: b996e6
- description: Image Tag
displayName: Image Tag
required: true
name: IMAGE_TAG
value: latest
41 changes: 41 additions & 0 deletions openshift/templates/api/api-service-template-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
apiVersion: template.openshift.io/v1
kind: Template
metadata:
name: ${APPLICATION_NAME}-template
labels:
template: ${APPLICATION_NAME}-template
objects:
- apiVersion: v1
kind: Service
metadata:
name: ${APPLICATION_NAME}-${IMAGE_TAG}
namespace: ${LICENSE_PLATE}-${ENVIRONMENT}
spec:
selector:
app: ${APPLICATION_NAME}
- name: 3000-tcp
protocol: TCP
port: 3000
targetPort: 3000

parameters:
- description: Application Name
displayName: AppName
name: APPLICATION_NAME
required: true
value: dpia-api
- description: Environment
displayName: Environment
name: ENVIRONMENT
required: true
value: dev
- description: License Plate
displayName: License Plate
name: LICENSE_PLATE
required: true
value: b996e6
- description: Image Tag
displayName: Image Tag
required: true
name: IMAGE_TAG
value: latest

0 comments on commit 192aacf

Please sign in to comment.