generated from bcgov/quickstart-openshift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b7407bd
commit 7532dc1
Showing
2 changed files
with
80 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,117 +1,87 @@ | ||
apiVersion: template.openshift.io/v1 | ||
kind: Template | ||
parameters: | ||
- name: NAME | ||
description: Module name | ||
value: nr-spar-data | ||
- name: COMPONENT | ||
description: Component name | ||
value: sync | ||
### Required - do not hard code | ||
- name: TAG | ||
description: Docker tag; e.g. PR-### or prod | ||
required: true | ||
- name: ZONE | ||
description: Deployment zone, e.g. pr-### or prod | ||
description: Deployment zone, e.g. pr-###, test or prod | ||
required: true | ||
- name: IMAGE_TAG | ||
description: Image tag to use | ||
value: latest | ||
- name: CPU_REQUEST | ||
value: "25m" | ||
- name: MEMORY_REQUEST | ||
value: "50Mi" | ||
- name: CPU_LIMIT | ||
value: "75m" | ||
- name: MEMORY_LIMIT | ||
value: "150Mi" | ||
- name: MIN_REPLICAS | ||
description: The minimum amount of replicas for the horizontal pod autoscaler. | ||
value: "1" | ||
- name: MAX_REPLICAS | ||
description: The maximum amount of replicas for the horizontal pod autoscaler. | ||
value: "1" | ||
|
||
### Recommended - suggest hard coding | ||
- name: APP | ||
description: Application/component name | ||
value: sync | ||
- name: ORG | ||
description: GitHub organization name | ||
value: bcgov | ||
- name: REPO | ||
description: Repository name | ||
value: nr-spar-data | ||
|
||
### Usually a bad idea - not recommended | ||
- name: CRON_MINUTES | ||
description: Random number, 0-60, for scheduling cronjobs | ||
from: "[0-5]{1}[0-9]{1}" | ||
generate: expression | ||
- name: JOB_BACKOFF_LIMIT | ||
description: "The number of attempts to try for a successful job outcome" | ||
value: "3" | ||
- name: JOB_HISTORY_FAIL | ||
description: "The number of failed jobs that will be retained" | ||
value: "2" | ||
- name: JOB_HISTORY_SUCCESS | ||
description: "The number of successful jobs that will be retained" | ||
value: "5" | ||
- name: REGISTRY | ||
description: Container registry to import from (internal is image-registry.openshift-image-registry.svc:5000) | ||
description: Source container registry | ||
value: ghcr.io | ||
- name: PROMOTE | ||
description: Image (namespace/name:tag) to promote/import | ||
value: bcgov/nr-spar-data/sync:test | ||
objects: | ||
- apiVersion: v1 | ||
kind: ImageStream | ||
- kind: CronJob | ||
apiVersion: "batch/v1" | ||
metadata: | ||
name: ${REPO}-${ZONE}-${APP} | ||
labels: | ||
app: "${NAME}-${ZONE}" | ||
name: "${NAME}-${ZONE}-${COMPONENT}" | ||
app: ${REPO}-${ZONE} | ||
cronjob: ${REPO}-${ZONE} | ||
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: | ||
schedule: "${CRON_MINUTES} 8 * * *" # Run daily at 8:xx AM UTC | ||
startingDeadlineSeconds: 60 | ||
concurrencyPolicy: "Replace" | ||
successfulJobsHistoryLimit: "${{JOB_HISTORY_SUCCESS}}" | ||
failedJobsHistoryLimit: "${{JOB_HISTORY_FAIL}}" | ||
jobTemplate: | ||
metadata: | ||
labels: | ||
app: "${NAME}-${ZONE}" | ||
deploymentconfig: "${NAME}-${ZONE}-${COMPONENT}" | ||
app: ${REPO}-${ZONE} | ||
cronjob: ${REPO}-${ZONE} | ||
spec: | ||
containers: | ||
- image: "${NAME}-${ZONE}-${COMPONENT}:${IMAGE_TAG}" | ||
imagePullPolicy: Always | ||
name: "${NAME}" | ||
env: | ||
- name: PYTHONPATH | ||
value: /app/src | ||
ports: | ||
- containerPort: 3000 | ||
protocol: TCP | ||
resources: | ||
requests: | ||
cpu: "${CPU_REQUEST}" | ||
memory: "${MEMORY_REQUEST}" | ||
limits: | ||
cpu: "${CPU_LIMIT}" | ||
memory: "${MEMORY_LIMIT}" | ||
- apiVersion: autoscaling/v2 | ||
kind: HorizontalPodAutoscaler | ||
metadata: | ||
labels: | ||
app: "${NAME}-${ZONE}" | ||
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: 100 | ||
backoffLimit: ${{JOB_BACKOFF_LIMIT}} | ||
template: | ||
metadata: | ||
labels: | ||
app: ${REPO}-${ZONE} | ||
cronjob: ${REPO}-${ZONE} | ||
spec: | ||
containers: | ||
- name: ${REPO}-${ZONE} | ||
image: "${REGISTRY}/${ORG}/${REPO}/${APP}:${TAG}" | ||
# env: | ||
# - name: POSTGRES_SERVICE | ||
# value: "${REPO}-${ZONE}-database" | ||
resources: | ||
limits: | ||
cpu: 250m | ||
requests: | ||
cpu: 50m | ||
terminationMessagePath: /dev/termination-log | ||
terminationMessagePolicy: File | ||
imagePullPolicy: Always | ||
restartPolicy: Never | ||
terminationGracePeriodSeconds: 30 | ||
activeDeadlineSeconds: 1600 | ||
dnsPolicy: ClusterFirst | ||
serviceAccountName: pipeline | ||
schedulerName: default-scheduler | ||
|