Skip to content

Commit 6c6af74

Browse files
authored
fix: remove helm service dependency and fix mongo image reference (#560)
1 parent 382e7c8 commit 6c6af74

File tree

23 files changed

+736
-45
lines changed

23 files changed

+736
-45
lines changed

.github/workflows/merge.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
environment: test
5959
tag: ${{ needs.semantic-version.outputs.semanticVersion }} # this is without v
6060
release_name: pubcode-test
61-
params: --set-string api.containers[0].tag="${{ needs.semantic-version.outputs.tag }}" --set-string frontend.containers[0].tag="${{ needs.semantic-version.outputs.tag }}"
61+
params: --set-string database.containers[0].tag="${{ needs.semantic-version.outputs.tag }}" --set-string database.initContainers[0].tag="${{ needs.semantic-version.outputs.tag }}" --set-string api.containers[0].tag="${{ needs.semantic-version.outputs.tag }}" --set-string frontend.containers[0].tag="${{ needs.semantic-version.outputs.tag }}"
6262
tests:
6363
name: Tests
6464
needs: [deploys]
@@ -76,7 +76,7 @@ jobs:
7676
environment: prod
7777
tag: ${{ needs.semantic-version.outputs.semanticVersion }}
7878
release_name: pubcode
79-
params: --set-string api.containers[0].tag="${{ needs.semantic-version.outputs.tag }}" --set-string frontend.containers[0].tag="${{ needs.semantic-version.outputs.tag }}"
79+
params: --set-string database.containers[0].tag="${{ needs.semantic-version.outputs.tag }}" --set-string database.initContainers[0].tag="${{ needs.semantic-version.outputs.tag }}" --set-string api.containers[0].tag="${{ needs.semantic-version.outputs.tag }}" --set-string frontend.containers[0].tag="${{ needs.semantic-version.outputs.tag }}"
8080
github_release:
8181
name: Create Release
8282
needs: [semantic-version, deploys-prod]

.github/workflows/pr-close.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,4 @@ jobs:
2020
oc_token: ${{ secrets.OC_TOKEN }}
2121
with:
2222
cleanup: helm
23-
packages: api frontend
24-
23+
packages: api frontend database

.github/workflows/pr-open.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
packages: write
4545
strategy:
4646
matrix:
47-
package: [api, frontend]
47+
package: [api, database, frontend]
4848
steps:
4949
- uses: actions/checkout@v6
5050
- uses: bcgov/action-builder-ghcr@2b24ac7f95e6a019064151498660437cca3202c5 # v4.2.1
@@ -72,6 +72,8 @@ jobs:
7272
release_name: pubcode-${{ github.event.number }}
7373
params: |
7474
--set-string global.repository=${{ github.repository }} \
75+
--set-string database.containers[0].tag="${{ github.sha }}" \
76+
--set-string database.initContainers[0].tag="${{ github.sha }}" \
7577
--set-string api.containers[0].tag="${{ github.sha }}" \
7678
--set-string api.containers[0].resources.requests.cpu="30m" \
7779
--set-string api.containers[0].resources.requests.memory="50Mi" \

charts/pubcode/Chart.lock

Lines changed: 0 additions & 12 deletions
This file was deleted.

charts/pubcode/Chart.yaml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,3 @@ version: 0.1.0
2323
# It is recommended to use it with quotes.
2424
appVersion: "0.1.0"
2525

26-
dependencies:
27-
28-
- name: component
29-
condition: api.enabled
30-
version: 0.3.3
31-
repository: https://bcgov.github.io/helm-service/
32-
alias: api
33-
34-
- name: component
35-
condition: frontend.enabled
36-
version: 0.3.3
37-
repository: https://bcgov.github.io/helm-service/
38-
alias: frontend
39-
40-
- name: component
41-
condition: database.enabled
42-
version: 0.3.3
43-
repository: https://bcgov.github.io/helm-service/
44-
alias: database
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "api.name" -}}
5+
{{- printf "api" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "api.fullname" -}}
14+
{{- $componentName := include "api.name" . }}
15+
{{- if .Values.api.fullnameOverride }}
16+
{{- .Values.api.fullnameOverride | trunc 63 | trimSuffix "-" }}
17+
{{- else }}
18+
{{- printf "%s-%s" .Release.Name $componentName | trunc 63 | trimSuffix "-" }}
19+
{{- end }}
20+
{{- end }}
21+
22+
{{/*
23+
Common labels
24+
*/}}
25+
{{- define "api.labels" -}}
26+
{{ include "api.selectorLabels" . }}
27+
{{- if .Values.global.tag }}
28+
app.kubernetes.io/image-version: {{ .Values.global.tag | quote }}
29+
{{- end }}
30+
app.kubernetes.io/managed-by: {{ .Release.Service }}
31+
app.kubernetes.io/short-name: {{ include "api.name" . }}
32+
{{- end }}
33+
34+
{{/*
35+
Selector labels
36+
*/}}
37+
{{- define "api.selectorLabels" -}}
38+
app.kubernetes.io/name: {{ include "api.name" . }}
39+
app.kubernetes.io/instance: {{ .Release.Name }}
40+
{{- end }}
41+
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{{- if and .Values.api.enabled .Values.api.deployment.enabled }}
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: {{ include "api.fullname" . }}
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
{{- include "api.labels" . | nindent 4 }}
9+
spec:
10+
{{- if not .Values.api.autoscaling.enabled }}
11+
replicas: {{ default 1 .Values.api.autoscaling.minReplicas }}
12+
{{- end }}
13+
selector:
14+
matchLabels:
15+
{{- include "api.selectorLabels" . | nindent 6 }}
16+
template:
17+
metadata:
18+
annotations:
19+
rollme: {{ randAlphaNum 5 | quote }}
20+
{{- if .Values.api.podAnnotations }}
21+
{{- tpl .Values.api.podAnnotations $ | nindent 8 }}
22+
{{- end }}
23+
labels:
24+
{{- include "api.labels" . | nindent 8 }}
25+
spec:
26+
securityContext:
27+
runAsNonRoot: true
28+
seccompProfile:
29+
type: RuntimeDefault
30+
containers:
31+
{{- range $c := .Values.api.containers }}
32+
- name: {{ $c.name }}
33+
image: "{{- if and $c.registry $c.repository -}}{{ tpl $c.registry $ }}/{{ tpl $c.repository $ }}/{{ tpl $c.image $ }}{{- else if $c.registry -}}{{ tpl $c.registry $ }}/{{ tpl $c.image $ }}{{- else -}}{{ tpl $c.image $ }}{{- end -}}{{- if $c.tag -}}:{{ tpl (printf "%v" $c.tag) $ }}{{- end -}}"
34+
securityContext:
35+
allowPrivilegeEscalation: false
36+
runAsNonRoot: true
37+
capabilities:
38+
drop:
39+
- ALL
40+
{{- if and $c.envFrom $c.envFrom.secretRef $c.envFrom.secretRef.name }}
41+
envFrom:
42+
- secretRef:
43+
name: {{ tpl $c.envFrom.secretRef.name $ }}
44+
{{- end }}
45+
{{- if $c.env }}
46+
env:
47+
{{- if and (kindIs "map" $c.env) $c.env.fromValues }}
48+
{{- range $e := $c.env.fromValues }}
49+
- name: {{ $e.name }}
50+
value: {{ tpl (printf "%v" $e.value) $ | quote }}
51+
{{- end }}
52+
{{- else if kindIs "slice" $c.env }}
53+
{{- tpl (toYaml $c.env) $ | nindent 12 }}
54+
{{- end }}
55+
{{- end }}
56+
{{- if $c.ports }}
57+
ports:
58+
{{- tpl (toYaml $c.ports) $ | nindent 12 }}
59+
{{- end }}
60+
{{- if $c.resources }}
61+
resources:
62+
{{- toYaml $c.resources | nindent 12 }}
63+
{{- end }}
64+
{{- if $c.readinessProbe }}
65+
readinessProbe:
66+
{{- toYaml $c.readinessProbe | nindent 12 }}
67+
{{- end }}
68+
{{- if $c.livenessProbe }}
69+
livenessProbe:
70+
{{- toYaml $c.livenessProbe | nindent 12 }}
71+
{{- end }}
72+
{{- end }}
73+
74+
{{- with .Values.api.nodeSelector }}
75+
nodeSelector:
76+
{{- toYaml . | nindent 8 }}
77+
{{- end }}
78+
{{- with .Values.api.tolerations }}
79+
tolerations:
80+
{{- toYaml . | nindent 8 }}
81+
{{- end }}
82+
{{- with .Values.api.affinity }}
83+
affinity:
84+
{{- toYaml . | nindent 8 }}
85+
{{- end }}
86+
{{- end }}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{{- if and .Values.api.autoscaling .Values.api.autoscaling.enabled }}
2+
apiVersion: autoscaling/v2
3+
kind: HorizontalPodAutoscaler
4+
metadata:
5+
name: {{ include "api.fullname" . }}
6+
labels:
7+
{{- include "api.labels" . | nindent 4 }}
8+
spec:
9+
scaleTargetRef:
10+
apiVersion: apps/v1
11+
kind: Deployment
12+
name: {{ include "api.fullname" . }}
13+
minReplicas: {{ .Values.api.autoscaling.minReplicas }}
14+
maxReplicas: {{ .Values.api.autoscaling.maxReplicas }}
15+
behavior:
16+
scaleDown:
17+
stabilizationWindowSeconds: 300
18+
policies:
19+
- type: Percent
20+
value: 10
21+
periodSeconds: 60
22+
- type: Pods
23+
value: 2
24+
periodSeconds: 60
25+
selectPolicy: Min
26+
scaleUp:
27+
stabilizationWindowSeconds: 0
28+
policies:
29+
- type: Percent
30+
value: 100
31+
periodSeconds: 30
32+
- type: Pods
33+
value: 2
34+
periodSeconds: 30
35+
selectPolicy: Max
36+
metrics:
37+
{{- if .Values.api.autoscaling.targetCPUUtilizationPercentage }}
38+
- type: Resource
39+
resource:
40+
name: cpu
41+
target:
42+
type: Utilization
43+
averageUtilization: {{ .Values.api.autoscaling.targetCPUUtilizationPercentage }}
44+
{{- end }}
45+
{{- if .Values.api.autoscaling.targetMemoryUtilizationPercentage }}
46+
- type: Resource
47+
resource:
48+
name: memory
49+
target:
50+
type: Utilization
51+
averageUtilization: {{ .Values.api.autoscaling.targetMemoryUtilizationPercentage }}
52+
{{- end }}
53+
{{- end }}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{{- if and .Values.api.enabled .Values.api.route .Values.api.route.enabled }}
2+
{{- $svcName := include "api.fullname" . -}}
3+
{{- $defaultSvcPort := 80 -}}
4+
{{- if and .Values.api.service .Values.api.service.ports (gt (len .Values.api.service.ports) 0) -}}
5+
{{- $defaultSvcPort = (index .Values.api.service.ports 0).port | default 80 -}}
6+
{{- end -}}
7+
apiVersion: networking.k8s.io/v1
8+
kind: Ingress
9+
metadata:
10+
name: {{ $svcName }}
11+
labels:
12+
{{- include "api.labels" . | nindent 4 }}
13+
{{- if .Values.api.route.annotations }}
14+
annotations:
15+
{{- tpl (toYaml .Values.api.route.annotations) $ | nindent 4 }}
16+
{{- end }}
17+
spec:
18+
ingressClassName: {{ default "openshift-default" .Values.api.route.className }}
19+
rules:
20+
- host: {{ tpl (default (printf "%s.%s" $svcName .Values.global.domain) (printf "%v" .Values.api.route.host)) $ | quote }}
21+
http:
22+
paths:
23+
- path: "/"
24+
pathType: ImplementationSpecific
25+
backend:
26+
service:
27+
name: {{ $svcName }}
28+
port:
29+
number: {{ $defaultSvcPort }}
30+
{{- end }}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{{- if and .Values.api.pdb .Values.api.pdb.enabled }}
2+
---
3+
apiVersion: policy/v1
4+
kind: PodDisruptionBudget
5+
metadata:
6+
name: {{ include "api.fullname" . }}
7+
labels:
8+
{{- include "api.labels" . | nindent 4 }}
9+
spec:
10+
selector:
11+
matchLabels:
12+
{{- include "api.selectorLabels" . | nindent 6 }}
13+
minAvailable: {{ .Values.api.pdb.minAvailable }}
14+
{{- end }}

0 commit comments

Comments
 (0)