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

chore(ci): Add OpenShift deploy template. #47

Merged
merged 5 commits into from
Sep 4, 2024
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
37 changes: 37 additions & 0 deletions .github/workflows/.deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: .Deploys

on:
workflow_call:
inputs:
environment:
description: GitHub environment; e.g. PR number (omit), TEST or PROD
required: false
type: string
tag:
description: Image tag; e.g. PR number or latest
default: ${{ github.event.number }}
required: false
type: string
target:
description: Deployment target; e.g. PR number (omit), test or prod
default: ${{ github.event.number }}
required: false
type: string

jobs:
frontend:
name: Frontend
# needs: [backend]
environment: ${{ inputs.environment }}
runs-on: ubuntu-22.04
steps:
- name: Deploy Frontend
uses: bcgov-nr/action-deployer-openshift@v3.0.0
with:
oc_namespace: ${{ vars.OC_NAMESPACE }}
oc_server: ${{ vars.OC_SERVER }}
oc_token: ${{ secrets.OC_TOKEN }}
file: frontend/openshift.deploy.yml
overwrite: true
parameters:
-p TAG=${{ inputs.tag }} -p TARGET=${{ inputs.target }}
8 changes: 7 additions & 1 deletion .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,16 @@ jobs:
# oc_namespace: ${{ secrets.OC_NAMESPACE }}
# oc_token: ${{ secrets.OC_TOKEN }}
# with:
# triggers: ('backend/' 'frontend/' 'migrations/')
# triggers: ('frontend/')
# params:
# --set global.secrets.persist=false

deploy:
name: Deploy
needs: [builds]
secrets: inherit
uses: ./.github/workflows/.deploy.yml

# tests:
# name: Tests
# if: needs.deploys.outputs.triggered == 'true'
Expand Down
113 changes: 113 additions & 0 deletions frontend/openshift.deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
apiVersion: template.openshift.io/v1
kind: Template
parameters:
- name: APP
description: Application name
value: nr-gwells
- name: COMPONENT
description: Component name
value: frontend
- name: ORG
description: Organization name; e.g. bcgov or bcdevops
value: bcgov
- name: TAG
description: Image tag; e.g. PR number or latest
required: true
- name: TARGET
description: Deployment target; e.g. PR number, test or prod
required: true
objects:
- kind: Service
apiVersion: v1
metadata:
labels:
app: ${APP}-${TARGET}
name: ${APP}-${TARGET}-${COMPONENT}
spec:
type: ClusterIP
ports:
- port: 80
targetPort: 5173
protocol: TCP
name: http-5173
selector:
service: ${APP}-${TARGET}-${COMPONENT}
- kind: Deployment
apiVersion: apps/v1
metadata:
labels:
app: ${APP}-${TARGET}
deployment: ${APP}-${TARGET}-${COMPONENT}
name: ${APP}-${TARGET}-${COMPONENT}
spec:
strategy:
type: Recreate
selector:
matchLabels:
deployment: ${APP}-${TARGET}-${COMPONENT}
template:
metadata:
labels:
app: ${APP}-${TARGET}
deployment: ${APP}-${TARGET}-${COMPONENT}
service: ${APP}-${TARGET}-${COMPONENT}
spec:
containers:
- name: ${APP}-${TARGET}-${COMPONENT}
image: ghcr.io/${ORG}/${APP}/${COMPONENT}:${TAG}
# securityContext:
# runAsUser: 1011540000
imagePullPolicy: Always
env:
- name: LOG_LEVEL
value: info
- name: VUE_APP_AXIOS_BASE_URL
value: http://${APP}-${TARGET}/gwells/api/v2/
ports:
- name: http
containerPort: 5173
protocol: TCP
readinessProbe:
httpGet:
path: /
port: http
scheme: HTTP
initialDelaySeconds: 90
periodSeconds: 10
timeoutSeconds: 10
successThreshold: 3
failureThreshold: 30
livenessProbe:
successThreshold: 1
failureThreshold: 3
httpGet:
path: /
port: http
scheme: HTTP
initialDelaySeconds: 15
periodSeconds: 30
timeoutSeconds: 5
resources: # this is optional
limits:
cpu: 150m
memory: 250Mi
requests:
cpu: 50m
memory: 175Mi
- kind: Route
apiVersion: route.openshift.io/v1
metadata:
labels:
app: ${APP}-${TARGET}
name: ${APP}-${TARGET}-${COMPONENT}
spec:
host: nr-gwells-${TARGET}.apps.silver.devops.gov.bc.ca
port:
targetPort: http-5173
to:
kind: Service
name: ${APP}-${TARGET}-${COMPONENT}
weight: 100
tls:
termination: edge
insecureEdgeTerminationPolicy: Redirect
Loading