Skip to content
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
4 changes: 2 additions & 2 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
environment: test
tag: ${{ needs.semantic-version.outputs.semanticVersion }} # this is without v
release_name: pubcode-test
params: --set-string api.containers[0].tag="${{ needs.semantic-version.outputs.tag }}" --set-string frontend.containers[0].tag="${{ needs.semantic-version.outputs.tag }}"
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 }}"
tests:
name: Tests
needs: [deploys]
Expand All @@ -76,7 +76,7 @@ jobs:
environment: prod
tag: ${{ needs.semantic-version.outputs.semanticVersion }}
release_name: pubcode
params: --set-string api.containers[0].tag="${{ needs.semantic-version.outputs.tag }}" --set-string frontend.containers[0].tag="${{ needs.semantic-version.outputs.tag }}"
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 }}"
github_release:
name: Create Release
needs: [semantic-version, deploys-prod]
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/pr-close.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ jobs:
oc_token: ${{ secrets.OC_TOKEN }}
with:
cleanup: helm
packages: api frontend

packages: api frontend database
4 changes: 3 additions & 1 deletion .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
packages: write
strategy:
matrix:
package: [api, frontend]
package: [api, database, frontend]
steps:
- uses: actions/checkout@v6
- uses: bcgov/action-builder-ghcr@2b24ac7f95e6a019064151498660437cca3202c5 # v4.2.1
Expand Down Expand Up @@ -72,6 +72,8 @@ jobs:
release_name: pubcode-${{ github.event.number }}
params: |
--set-string global.repository=${{ github.repository }} \
--set-string database.containers[0].tag="${{ github.sha }}" \
--set-string database.initContainers[0].tag="${{ github.sha }}" \
--set-string api.containers[0].tag="${{ github.sha }}" \
--set-string api.containers[0].resources.requests.cpu="30m" \
--set-string api.containers[0].resources.requests.memory="50Mi" \
Expand Down
12 changes: 0 additions & 12 deletions charts/pubcode/Chart.lock

This file was deleted.

19 changes: 0 additions & 19 deletions charts/pubcode/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,3 @@ version: 0.1.0
# It is recommended to use it with quotes.
appVersion: "0.1.0"

dependencies:

- name: component
condition: api.enabled
version: 0.3.3
repository: https://bcgov.github.io/helm-service/
alias: api

- name: component
condition: frontend.enabled
version: 0.3.3
repository: https://bcgov.github.io/helm-service/
alias: frontend

- name: component
condition: database.enabled
version: 0.3.3
repository: https://bcgov.github.io/helm-service/
alias: database
41 changes: 41 additions & 0 deletions charts/pubcode/templates/api/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "api.name" -}}
{{- printf "api" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "api.fullname" -}}
{{- $componentName := include "api.name" . }}
{{- if .Values.api.fullnameOverride }}
{{- .Values.api.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $componentName | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "api.labels" -}}
{{ include "api.selectorLabels" . }}
{{- if .Values.global.tag }}
app.kubernetes.io/image-version: {{ .Values.global.tag | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/short-name: {{ include "api.name" . }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "api.selectorLabels" -}}
app.kubernetes.io/name: {{ include "api.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

86 changes: 86 additions & 0 deletions charts/pubcode/templates/api/templates/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{{- if and .Values.api.enabled .Values.api.deployment.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "api.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "api.labels" . | nindent 4 }}
spec:
{{- if not .Values.api.autoscaling.enabled }}
replicas: {{ default 1 .Values.api.autoscaling.minReplicas }}
{{- end }}
selector:
matchLabels:
{{- include "api.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
rollme: {{ randAlphaNum 5 | quote }}
{{- if .Values.api.podAnnotations }}
{{- tpl .Values.api.podAnnotations $ | nindent 8 }}
{{- end }}
labels:
{{- include "api.labels" . | nindent 8 }}
spec:
securityContext:
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
containers:
{{- range $c := .Values.api.containers }}
- name: {{ $c.name }}
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 -}}"
securityContext:
allowPrivilegeEscalation: false
runAsNonRoot: true
capabilities:
drop:
- ALL
{{- if and $c.envFrom $c.envFrom.secretRef $c.envFrom.secretRef.name }}
envFrom:
- secretRef:
name: {{ tpl $c.envFrom.secretRef.name $ }}
{{- end }}
{{- if $c.env }}
env:
{{- if and (kindIs "map" $c.env) $c.env.fromValues }}
{{- range $e := $c.env.fromValues }}
- name: {{ $e.name }}
value: {{ tpl (printf "%v" $e.value) $ | quote }}
{{- end }}
{{- else if kindIs "slice" $c.env }}
{{- tpl (toYaml $c.env) $ | nindent 12 }}
{{- end }}
{{- end }}
{{- if $c.ports }}
ports:
{{- tpl (toYaml $c.ports) $ | nindent 12 }}
{{- end }}
{{- if $c.resources }}
resources:
{{- toYaml $c.resources | nindent 12 }}
{{- end }}
{{- if $c.readinessProbe }}
readinessProbe:
{{- toYaml $c.readinessProbe | nindent 12 }}
{{- end }}
{{- if $c.livenessProbe }}
livenessProbe:
{{- toYaml $c.livenessProbe | nindent 12 }}
{{- end }}
{{- end }}

{{- with .Values.api.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.api.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.api.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
53 changes: 53 additions & 0 deletions charts/pubcode/templates/api/templates/hpa.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{{- if and .Values.api.autoscaling .Values.api.autoscaling.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "api.fullname" . }}
labels:
{{- include "api.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "api.fullname" . }}
minReplicas: {{ .Values.api.autoscaling.minReplicas }}
maxReplicas: {{ .Values.api.autoscaling.maxReplicas }}
behavior:
scaleDown:
stabilizationWindowSeconds: 300
policies:
- type: Percent
value: 10
periodSeconds: 60
- type: Pods
value: 2
periodSeconds: 60
selectPolicy: Min
scaleUp:
stabilizationWindowSeconds: 0
policies:
- type: Percent
value: 100
periodSeconds: 30
- type: Pods
value: 2
periodSeconds: 30
selectPolicy: Max
metrics:
{{- if .Values.api.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.api.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.api.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .Values.api.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
30 changes: 30 additions & 0 deletions charts/pubcode/templates/api/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{- if and .Values.api.enabled .Values.api.route .Values.api.route.enabled }}
{{- $svcName := include "api.fullname" . -}}
{{- $defaultSvcPort := 80 -}}
{{- if and .Values.api.service .Values.api.service.ports (gt (len .Values.api.service.ports) 0) -}}
{{- $defaultSvcPort = (index .Values.api.service.ports 0).port | default 80 -}}
{{- end -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $svcName }}
labels:
{{- include "api.labels" . | nindent 4 }}
{{- if .Values.api.route.annotations }}
annotations:
{{- tpl (toYaml .Values.api.route.annotations) $ | nindent 4 }}
{{- end }}
spec:
ingressClassName: {{ default "openshift-default" .Values.api.route.className }}
rules:
- host: {{ tpl (default (printf "%s.%s" $svcName .Values.global.domain) (printf "%v" .Values.api.route.host)) $ | quote }}
http:
paths:
- path: "/"
pathType: ImplementationSpecific
backend:
service:
name: {{ $svcName }}
port:
number: {{ $defaultSvcPort }}
{{- end }}
14 changes: 14 additions & 0 deletions charts/pubcode/templates/api/templates/pdb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if and .Values.api.pdb .Values.api.pdb.enabled }}
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: {{ include "api.fullname" . }}
labels:
{{- include "api.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "api.selectorLabels" . | nindent 6 }}
minAvailable: {{ .Values.api.pdb.minAvailable }}
{{- end }}
20 changes: 20 additions & 0 deletions charts/pubcode/templates/api/templates/service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{- if .Values.api.enabled }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ include "api.fullname" . }}
labels:
{{- include "api.labels" . | nindent 4 }}
spec:
type: {{ default "ClusterIP" .Values.api.service.type }}
ports:
{{- range $p := .Values.api.service.ports }}
- name: {{ default "http" $p.name }}
port: {{ $p.port }}
targetPort: {{ $p.targetPort }}
protocol: {{ default "TCP" $p.protocol }}
{{- end }}
selector:
{{- include "api.selectorLabels" . | nindent 4 }}
{{- end }}
55 changes: 55 additions & 0 deletions charts/pubcode/templates/database/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "database.name" -}}
{{- printf "database" }}
{{- end }}

{{/*
Compatibility helpers.

values.yaml references "component.*" helpers for the database component.
Define them here so tpl() evaluation works without requiring values changes.
*/}}
{{- define "component.name" -}}
{{- include "database.name" . -}}
{{- end }}

{{- define "component.fullname" -}}
{{- include "database.fullname" . -}}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "database.fullname" -}}
{{- $componentName := include "database.name" . }}
{{- if .Values.database.fullnameOverride }}
{{- .Values.database.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $componentName | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "database.labels" -}}
{{ include "database.selectorLabels" . }}
{{- if .Values.global.tag }}
app.kubernetes.io/image-version: {{ .Values.global.tag | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/short-name: {{ include "database.name" . }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "database.selectorLabels" -}}
app.kubernetes.io/name: {{ include "database.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

Loading
Loading