Skip to content
This repository was archived by the owner on Mar 9, 2026. It is now read-only.

Commit 25ffbb1

Browse files
authored
chore: naming and label format deployments (env and PR number) (#6)
1 parent 0fa3a6f commit 25ffbb1

6 files changed

Lines changed: 119 additions & 73 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ on:
1919
description: Deployment target; usually PR number, test or prod
2020
default: ${{ github.event.number }}
2121
type: string
22+
zone:
23+
description: Deployment zone; usually PR number, test or prod
24+
default: ${{ github.event.number }}
25+
type: string
2226
triggers:
2327
description: List of directories to trigger the deployment
2428
default: 'frontend backend'
@@ -39,9 +43,12 @@ jobs:
3943
oc_namespace: ${{ vars.OC_NAMESPACE }}
4044
oc_server: ${{ vars.OC_SERVER }}
4145
oc_token: ${{ secrets.OC_TOKEN }}
42-
file: common/openshift.init.yml
46+
file: common/openshift.database.yml
4347
overwrite: true
4448
parameters: |
49+
-p NAME=nrpti
50+
-p ZONE=${{ inputs.zone || inputs.target || 'dev' }}
51+
-p COMPONENT=mongodb
4552
-p TAG=${{ inputs.tag }}
4653
-p TARGET=${{ inputs.target }}
4754
triggers: ${{ inputs.triggers }}

.github/workflows/pr-open.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,7 @@ jobs:
5353
oc_token: ${{ secrets.oc_token }}
5454
file: ./common/openshift.database.yml
5555
overwrite: true
56-
parameters:
57-
-p MONGODB_ADMIN_PASSWORD=${{ secrets.MONGODB_ADMIN_PASSWORD }}
58-
-p MONGODB_DATABASE_NAME=${{ secrets.MONGODB_DATABASE_NAME }}
59-
-p MONGODB_USER=${{ secrets.MONGODB_USER }}
60-
-p MONGODB_PASSWORD=${{ secrets.MONGODB_PASSWORD }}
56+
parameters: -p NAME=nrpti -p ZONE=${{ github.event.number }} -p COMPONENT=mongodb -p MONGODB_ADMIN_PASSWORD=${{ secrets.MONGODB_ADMIN_PASSWORD }} -p MONGODB_DATABASE_NAME=${{ secrets.MONGODB_DATABASE_NAME }} -p MONGODB_USER=${{ secrets.MONGODB_USER }} -p MONGODB_PASSWORD=${{ secrets.MONGODB_PASSWORD }}
6157

6258
deploy:
6359
name: Deploy
@@ -69,10 +65,12 @@ jobs:
6965
include:
7066
- package: api
7167
file: ./tools/api/api.dc.yaml
68+
component: api
7269
# - component: admin-nrpti
7370
# file: ./tools/angular-on-nginx/admin-nrced.dc.yaml
7471
- package: public-nrpti
7572
file: ./tools/angular-on-nginx/public-nrced.dc.yaml
73+
component: nrced
7674
steps:
7775
- name: Deploy ${{ matrix.package }}
7876
uses: bcgov/action-deployer-openshift@v4.0.0
@@ -82,6 +80,7 @@ jobs:
8280
oc_token: ${{ secrets.oc_token }}
8381
file: ${{ matrix.file }}
8482
overwrite: true
83+
parameters: -p NAME=nrpti -p ZONE=${{ github.event.number }} -p COMPONENT=${{ matrix.component }} -p GROUP_NAME=nrpti
8584

8685
# # https://github.com/bcgov/action-deploy-ghcr
8786
# deploys:

.github/workflows/pr-validate.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ jobs:
1919
uses: bcgov/quickstart-openshift-helpers/.github/workflows/.pr-validate.yml@0b8121a528aaa05ef8def2f79be9081691dfe98a # v0.9.0
2020
with:
2121
markdown_links: |
22-
- [Frontend](https://${{ github.event.repository.name }}-${{ github.event.number }}-frontend.apps.silver.devops.gov.bc.ca)
23-
- [Backend](https://${{ github.event.repository.name }}-${{ github.event.number }}-frontend.apps.silver.devops.gov.bc.ca/api)
22+
- [Frontend](https://nrpti-${{ github.event.number }}-nrced-${{ vars.OC_ENV || 'f00029-dev' }}.apps.silver.devops.gov.bc.ca)
23+
- [Backend](https://nrpti-${{ github.event.number }}-api-${{ vars.OC_ENV || 'f00029-dev' }}.apps.silver.devops.gov.bc.ca)
2424
2525
results:
2626
name: Validate Results

common/openshift.database.yml

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
kind: Template
22
apiVersion: template.openshift.io/v1
33
metadata:
4-
name: ${NAME}-mongodb
4+
name: ${NAME}-${ZONE}-mongodb
55
labels:
6-
template: ${NAME}-mongodb
7-
app: ${GROUP_NAME}
6+
template: ${NAME}-${ZONE}-mongodb
7+
app: ${NAME}-${ZONE}
88
parameters:
99
- name: NAME
1010
displayName: Name
1111
description: The name assigned to all of the frontend objects defined in this template.
1212
value: nrpti
13+
- name: ZONE
14+
displayName: Deployment Zone
15+
description: The zone or environment (dev, test, prod, PR number)
16+
required: true
17+
- name: COMPONENT
18+
displayName: Component Name
19+
description: The component part of the name (mongodb, api, etc)
20+
value: mongodb
1321
- name: GROUP_NAME
1422
displayName: Group Name
1523
description: The name assigned to a group of objects deployed together
@@ -73,7 +81,7 @@ objects:
7381
- kind: Secret
7482
apiVersion: v1
7583
metadata:
76-
name: ${NAME}-mongodb
84+
name: ${NAME}-${ZONE}-${COMPONENT}
7785
stringData:
7886
MONGODB_ADMIN_PASSWORD: ${MONGODB_ADMIN_PASSWORD}
7987
MONGODB_DATABASE: ${MONGODB_DATABASE_NAME}
@@ -83,9 +91,10 @@ objects:
8391
- kind: PersistentVolumeClaim
8492
apiVersion: v1
8593
metadata:
86-
name: ${NAME}-mongodb-data
94+
name: ${NAME}-${ZONE}-${COMPONENT}-data
8795
labels:
88-
app: ${GROUP_NAME}
96+
app: ${NAME}-${ZONE}
97+
component: ${COMPONENT}
8998
spec:
9099
accessModes:
91100
- ReadWriteOnce
@@ -95,22 +104,24 @@ objects:
95104
- kind: Service
96105
apiVersion: v1
97106
metadata:
98-
name: mongodb
107+
name: ${NAME}-${ZONE}-${COMPONENT}
99108
labels:
100-
app: ${GROUP_NAME}
109+
app: ${NAME}-${ZONE}
110+
component: ${COMPONENT}
101111
spec:
102112
ports:
103-
- name: mongodb-${NAME}
113+
- name: ${COMPONENT}-${NAME}
104114
port: 27017
105115
targetPort: 27017
106116
selector:
107-
name: ${NAME}-mongodb
117+
name: ${NAME}-${ZONE}-${COMPONENT}
108118
- kind: Deployment
109119
apiVersion: apps/v1
110120
metadata:
111-
name: ${NAME}-mongodb
121+
name: ${NAME}-${ZONE}-${COMPONENT}
112122
labels:
113-
app: ${GROUP_NAME}
123+
app: ${NAME}-${ZONE}
124+
component: ${COMPONENT}
114125
role: database
115126
spec:
116127
strategy:
@@ -120,48 +131,49 @@ objects:
120131
imageChangeParams:
121132
automatic: true
122133
containerNames:
123-
- ${NAME}-mongodb
134+
- ${NAME}-${ZONE}-${COMPONENT}
124135
from:
125136
kind: ImageStreamTag
126137
namespace: ${APP_IMAGE_NAMESPACE}
127138
name: mongodb:${MONGO_VER}
128139
replicas: 1
129140
selector:
130141
matchLabels:
131-
name: ${NAME}-mongodb
142+
name: ${NAME}-${ZONE}-${COMPONENT}
132143
template:
133144
metadata:
134-
name: ${NAME}-mongodb
145+
name: ${NAME}-${ZONE}-${COMPONENT}
135146
labels:
136-
name: ${NAME}-mongodb
137-
app: ${GROUP_NAME}
147+
name: ${NAME}-${ZONE}-${COMPONENT}
148+
app: ${NAME}-${ZONE}
149+
component: ${COMPONENT}
138150
role: database
139151
spec:
140152
containers:
141-
- name: ${NAME}-mongodb
153+
- name: ${NAME}-${ZONE}-${COMPONENT}
142154
image: image-registry.openshift-image-registry.svc:5000/${APP_IMAGE_NAMESPACE}/mongodb:${MONGO_VER}
143155
ports:
144156
- containerPort: 27017
145157
env:
146158
- name: MONGODB_USER
147159
valueFrom:
148160
secretKeyRef:
149-
name: ${NAME}-mongodb
161+
name: ${NAME}-${ZONE}-${COMPONENT}
150162
key: MONGODB_USERNAME
151163
- name: MONGODB_PASSWORD
152164
valueFrom:
153165
secretKeyRef:
154-
name: ${NAME}-mongodb
166+
name: ${NAME}-${ZONE}-${COMPONENT}
155167
key: MONGODB_PASSWORD
156168
- name: MONGODB_DATABASE
157169
valueFrom:
158170
secretKeyRef:
159-
name: ${NAME}-mongodb
171+
name: ${NAME}-${ZONE}-${COMPONENT}
160172
key: MONGODB_DATABASE
161173
- name: MONGODB_ADMIN_PASSWORD
162174
valueFrom:
163175
secretKeyRef:
164-
name: ${NAME}-mongodb
176+
name: ${NAME}-${ZONE}-${COMPONENT}
165177
key: MONGODB_ADMIN_PASSWORD
166178
readinessProbe:
167179
timeoutSeconds: 5
@@ -186,9 +198,9 @@ objects:
186198
cpu: ${DATABASE_CPU_REQUESTS}
187199
memory: ${DATABASE_MEMORY_REQUESTS}
188200
volumeMounts:
189-
- name: ${NAME}-mongodb-data
201+
- name: ${NAME}-${ZONE}-${COMPONENT}-data
190202
mountPath: /var/lib/mongodb/data
191203
volumes:
192-
- name: ${NAME}-mongodb-data
204+
- name: ${NAME}-${ZONE}-${COMPONENT}-data
193205
persistentVolumeClaim:
194-
claimName: ${NAME}-mongodb-data
206+
claimName: ${NAME}-${ZONE}-${COMPONENT}-data

tools/angular-on-nginx/public-nrced.dc.yaml

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,38 @@
11
apiVersion: template.openshift.io/v1
22
kind: Template
33
metadata:
4-
name: ${NAME}
4+
name: ${NAME}-${ZONE}-${COMPONENT}
55
objects:
66
- kind: Service
77
apiVersion: v1
88
metadata:
9-
name: ${NAME}
9+
name: ${NAME}-${ZONE}-${COMPONENT}
1010
labels:
11-
app: ${GROUP_NAME}
11+
app: ${NAME}-${ZONE}
12+
component: ${COMPONENT}
1213
spec:
1314
ports:
1415
- name: 8080-tcp
1516
protocol: TCP
1617
port: 8080
1718
targetPort: 8080
1819
selector:
19-
app: ${GROUP_NAME}
20-
deployment: ${NAME}
20+
app: ${NAME}-${ZONE}
21+
component: ${COMPONENT}
22+
deployment: ${NAME}-${ZONE}-${COMPONENT}
2123
type: ClusterIP
2224
- kind: Route
2325
apiVersion: route.openshift.io/v1
2426
metadata:
25-
name: ${NAME}
27+
name: ${NAME}-${ZONE}-${COMPONENT}
2628
labels:
27-
app: ${GROUP_NAME}
29+
app: ${NAME}-${ZONE}
30+
component: ${COMPONENT}
2831
spec:
29-
host: ${NAME}-${Host}
32+
host: ${NAME}-${ZONE}-${COMPONENT}-${Host}
3033
to:
3134
kind: Service
32-
name: ${NAME}
35+
name: ${NAME}-${ZONE}-${COMPONENT}
3336
weight: 100
3437
port:
3538
targetPort: 8080-tcp
@@ -40,9 +43,10 @@ objects:
4043
- kind: Deployment
4144
apiVersion: apps/v1
4245
metadata:
43-
name: ${NAME}
46+
name: ${NAME}-${ZONE}-${COMPONENT}
4447
labels:
45-
app: ${GROUP_NAME}
48+
app: ${NAME}-${ZONE}
49+
component: ${COMPONENT}
4650
role: frontend
4751
spec:
4852
strategy:
@@ -51,17 +55,19 @@ objects:
5155
revisionHistoryLimit: 5
5256
selector:
5357
matchLabels:
54-
app: ${GROUP_NAME}
55-
deployment: ${NAME}
58+
app: ${NAME}-${ZONE}
59+
component: ${COMPONENT}
60+
deployment: ${NAME}-${ZONE}-${COMPONENT}
5661
template:
5762
metadata:
5863
labels:
59-
app: ${GROUP_NAME}
60-
deployment: ${NAME}
64+
app: ${NAME}-${ZONE}
65+
component: ${COMPONENT}
66+
deployment: ${NAME}-${ZONE}-${COMPONENT}
6167
role: frontend
6268
spec:
6369
containers:
64-
- name: ${NAME}
70+
- name: ${NAME}-${ZONE}-${COMPONENT}
6571
image: image-registry.openshift-image-registry.svc:5000/${RUNTIME_IMAGE_NAMESPACE}/${RUNTIME_IMAGE_NAME}:${RUNTIME_IMAGE_TAG}
6672
ports:
6773
- containerPort: 8080
@@ -112,9 +118,18 @@ objects:
112118
securityContext: {}
113119
schedulerName: default-scheduler
114120
parameters:
115-
- description: A name used for all objects
121+
- name: NAME
122+
description: The name assigned to all of the frontend objects defined in this template.
116123
displayName: Name
117-
name: NAME
124+
required: true
125+
value: nrpti
126+
- name: ZONE
127+
description: Deployment zone (dev, test, prod or PR number)
128+
displayName: Deployment Zone
129+
required: true
130+
- name: COMPONENT
131+
description: Component name
132+
displayName: Component
118133
required: true
119134
value: nrced
120135
- description: A name used for all objects in the build or deploy group

0 commit comments

Comments
 (0)