Skip to content

Commit

Permalink
feat: add openshift deploy file for the back end
Browse files Browse the repository at this point in the history
Issue #106

Base file for getting the back end service deployed into open shift.
  • Loading branch information
Ricardo Campos committed Sep 26, 2023
1 parent 3aaca0f commit 4801805
Showing 1 changed file with 173 additions and 0 deletions.
173 changes: 173 additions & 0 deletions backend/openshift.deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
apiVersion: template.openshift.io/v1
kind: Template
labels:
app: ${NAME}-${ZONE}
parameters:
- name: NAME
description: Module name
value: nr-silva
- name: COMPONENT
description: Component name
value: backend
- name: ZONE
description: Deployment zone, e.g. pr-### or prod
required: true
- name: IMAGE_TAG
description: Image tag to use
value: latest
- name: DOMAIN
value: apps.silver.devops.gov.bc.ca
- name: CPU_REQUEST
value: 50m
- name: CPU_LIMIT
value: 75m
- name: MEMORY_REQUEST
value: 100Mi
- name: MEMORY_LIMIT
value: 250Mi
- name: MIN_REPLICAS
description: The minimum amount of replicas for the horizontal pod autoscaler.
value: "3"
- name: MAX_REPLICAS
description: The maximum amount of replicas for the horizontal pod autoscaler.
value: "5"
- name: REGISTRY
description: Container registry to import from (internal is image-registry.openshift-image-registry.svc:5000)
value: ghcr.io
- name: PROMOTE
description: Image (namespace/name:tag) to promote/import
value: bcgov/nr-silva/backend:prod
- name: LOGGING_LEVEL
description: Back end application loggin level. One of ERROR, WARN, INFO, DEBUG or TRACE.
value: INFO
objects:
- apiVersion: v1
kind: ImageStream
metadata:
labels:
app: ${NAME}-${ZONE}
name: ${NAME}-${ZONE}-${COMPONENT}
spec:
lookupPolicy:
local: false
tags:
- name: ${IMAGE_TAG}
from:
kind: DockerImage
name: ${REGISTRY}/${PROMOTE}
referencePolicy:
type: Local
- apiVersion: v1
kind: DeploymentConfig
metadata:
labels:
app: ${NAME}-${ZONE}
name: ${NAME}-${ZONE}-${COMPONENT}
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}
strategy:
type: Rolling
template:
metadata:
labels:
app: ${NAME}-${ZONE}
deploymentconfig: ${NAME}-${ZONE}-${COMPONENT}
spec:
containers:
- image: ${NAME}-${ZONE}-${COMPONENT}:${IMAGE_TAG}
imagePullPolicy: Always
name: ${NAME}
env:
- name: LOGGING_LEVEL
value: ${LOGGING_LEVEL}
ports:
- containerPort: 8080
protocol: TCP
resources:
requests:
cpu: ${CPU_REQUEST}
memory: ${MEMORY_REQUEST}
limits:
cpu: ${CPU_LIMIT}
memory: ${MEMORY_LIMIT}
readinessProbe:
successThreshold: 1
failureThreshold: 5
httpGet:
path: /actuator/health
port: 8080
scheme: HTTP
initialDelaySeconds: 20
periodSeconds: 15
timeoutSeconds: 10
livenessProbe:
successThreshold: 1
failureThreshold: 5
httpGet:
path: /actuator/health
port: 8080
scheme: HTTP
initialDelaySeconds: 20
periodSeconds: 30
timeoutSeconds: 10
- apiVersion: v1
kind: Service
metadata:
labels:
app: ${NAME}-${ZONE}
name: ${NAME}-${ZONE}-${COMPONENT}
spec:
ports:
- name: 8080-tcp
protocol: TCP
port: 80
targetPort: 8080
selector:
deploymentconfig: ${NAME}-${ZONE}-${COMPONENT}
- apiVersion: route.openshift.io/v1
kind: Route
metadata:
labels:
app: ${NAME}-${ZONE}
name: ${NAME}-${ZONE}-${COMPONENT}
spec:
host: ${NAME}-${ZONE}-${COMPONENT}.${DOMAIN}
port:
targetPort: 8080-tcp
to:
kind: Service
name: ${NAME}-${ZONE}-${COMPONENT}
weight: 100
tls:
termination: edge
insecureEdgeTerminationPolicy: Redirect
- apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: ${NAME}-${ZONE}-${COMPONENT}
spec:
scaleTargetRef:
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
name: ${NAME}-${ZONE}-${COMPONENT}
minReplicas: ${{MIN_REPLICAS}}
maxReplicas: ${{MAX_REPLICAS}}
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 80

0 comments on commit 4801805

Please sign in to comment.