Skip to content

Commit

Permalink
chore(4550): move maintenance mode helm template to app
Browse files Browse the repository at this point in the history
  • Loading branch information
Kolezhanchik committed Jan 31, 2025
1 parent 2ef4442 commit a840edb
Show file tree
Hide file tree
Showing 16 changed files with 75 additions and 384 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
uses: ./.github/actions/setup-tools

- name: Build and Push
uses: egose/actions/docker-build-push@014f4085378005014da8017ce3fdd91899d9083c
uses: egose/actions/docker-build-push@401f2efdfeb6d63914aa3b87d90c88d04dbf58f9
with:
registry-url: ${{ env.GITHUB_REGISTRY }}
registry-username: ${{ github.actor }}
Expand All @@ -60,7 +60,7 @@ jobs:
uses: ./.github/actions/setup-tools

- name: Build and Push
uses: egose/actions/docker-build-push@014f4085378005014da8017ce3fdd91899d9083c
uses: egose/actions/docker-build-push@401f2efdfeb6d63914aa3b87d90c88d04dbf58f9
with:
registry-url: ${{ env.GITHUB_REGISTRY }}
registry-username: ${{ github.actor }}
Expand All @@ -83,7 +83,7 @@ jobs:
uses: ./.github/actions/setup-tools

- name: Build and Push
uses: egose/actions/docker-build-push@014f4085378005014da8017ce3fdd91899d9083c
uses: egose/actions/docker-build-push@401f2efdfeb6d63914aa3b87d90c88d04dbf58f9
with:
registry-url: ${{ env.GITHUB_REGISTRY }}
registry-username: ${{ github.actor }}
Expand All @@ -106,7 +106,7 @@ jobs:
uses: ./.github/actions/setup-tools

- name: Build and Push
uses: egose/actions/docker-build-push@014f4085378005014da8017ce3fdd91899d9083c
uses: egose/actions/docker-build-push@401f2efdfeb6d63914aa3b87d90c88d04dbf58f9
with:
registry-url: ${{ env.GITHUB_REGISTRY }}
registry-username: ${{ github.actor }}
Expand All @@ -126,7 +126,7 @@ jobs:
- uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2

- name: Build and Push
uses: egose/actions/docker-build-push@014f4085378005014da8017ce3fdd91899d9083c
uses: egose/actions/docker-build-push@401f2efdfeb6d63914aa3b87d90c88d04dbf58f9
with:
registry-url: ${{ env.GITHUB_REGISTRY }}
registry-username: ${{ github.actor }}
Expand All @@ -149,7 +149,7 @@ jobs:
uses: ./.github/actions/setup-tools

- name: Build and Push
uses: egose/actions/docker-build-push@014f4085378005014da8017ce3fdd91899d9083c
uses: egose/actions/docker-build-push@401f2efdfeb6d63914aa3b87d90c88d04dbf58f9
with:
registry-url: ${{ env.GITHUB_REGISTRY }}
registry-username: ${{ github.actor }}
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/deploy-dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ on:
description: Image Tag Version (ghcr.io/bcgov/pltsvc:<imageTag>)
type: string
required: true
maintenanceMode:
description: Toggle Maintenance Mode
type: boolean
required: false
default: false

jobs:
deploy:
Expand All @@ -35,7 +40,19 @@ jobs:
namespace: ${{ vars.OPENSHIFT_NAMESPACE }}
insecure_skip_tls_verify: true

- name: Toggle Maintenance Mode
if: ${{ inputs.maintenanceMode }}
run: |
helm upgrade \
pltsvc-maintenance-mode \
./helm/main \
-n ${{ vars.OPENSHIFT_NAMESPACE }} \
--set maintenanceMode.enabled=true \
--set app.replicaCount=0 \
--set maintenanceMode.image.tag=${{ inputs.imageTag }}
- name: Deploy apps with Helm chart
if: ${{ !inputs.maintenanceMode }}
run: |
make upgrade \
NAMESPACE=${{ vars.OPENSHIFT_NAMESPACE }} \
Expand Down
42 changes: 0 additions & 42 deletions .github/workflows/toggle-maintenance-mode.yml

This file was deleted.

27 changes: 21 additions & 6 deletions helm/_app/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,22 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "app.fullname" . }}
name: {{ include "app.fullname" . }}{{- if .Values.maintenanceMode.enabled }}-maintenance-mode
{{- end }}
labels:
{{- include "app.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
replicas: {{ if .Values.maintenanceMode.enabled }}1
{{ else }}{{ .Values.replicaCount }}{{- end }}
{{- end }}
selector:
matchLabels:
{{- if .Values.maintenanceMode.enabled }}
app: maintenance-mode
{{- else }}
{{- include "app.selectorLabels" . | nindent 6 }}
{{- end }}
template:
metadata:
annotations:
Expand All @@ -21,6 +27,7 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
vault.hashicorp.com/role: {{ .Values.global.vault.role }}
{{- if not .Values.maintenanceMode.enabled }}
vault.hashicorp.com/agent-inject-secret-secrets.env: {{ .Values.global.vault.role }}/{{ .Values.global.vault.subPath }}
vault.hashicorp.com/agent-inject-template-secrets.env: |
{{`{{ with secret "`}}{{ .Values.global.vault.role }}/{{ .Values.global.vault.subPath }}{{`" -}}
Expand Down Expand Up @@ -54,11 +61,15 @@ spec:
export GOLD_METRICS_READER_TOKEN='{{.Data.data.GOLD_METRICS_READER_TOKEN}}'
export EMERALD_METRICS_READER_TOKEN='{{.Data.data.EMERALD_METRICS_READER_TOKEN}}'
{{- end }}`}}
{{- end }}
labels:
{{- include "app.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.maintenanceMode.enabled }}
app: maintenance-mode
{{- end }}
spec:
{{- $imagePullSecrets := concat (.Values.imagePullSecrets | default list) (.Values.global.imagePullSecrets | default list) -}}
{{- with $imagePullSecrets }}
Expand All @@ -69,14 +80,18 @@ spec:
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
- name: {{ if .Values.maintenanceMode.enabled }}maintenance-mode
{{ else }}{{ .Chart.Name }}
{{- end }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ $deploymentTag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
image: "{{ if .Values.maintenanceMode.enabled }}{{ .Values.maintenanceMode.image.repository }}:{{ .Values.maintenanceMode.image.tag }}{{ else }}{{ .Values.image.repository }}:{{ $deploymentTag }}{{- end }}"
imagePullPolicy: {{ if .Values.maintenanceMode.enabled }}{{ .Values.maintenanceMode.image.pullPolicy }}{{ else }}{{ .Values.image.pullPolicy }}{{ end }}
{{- if not .Values.maintenanceMode.enabled }}
command: ["/bin/sh", "-c"]
args:
['. /vault/secrets/secrets.env && /app/node_modules/.bin/next start']
{{- end }}
env:
- name: DEPLOYMENT_TAG
value: {{ $deploymentTag | quote }}
Expand All @@ -92,7 +107,7 @@ spec:
{{- end }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
containerPort: {{ if .Values.maintenanceMode.enabled }}{{ .Values.service.maintenancePort }}{{ else }}{{ .Values.service.port }}{{ end }}
protocol: TCP
livenessProbe:
httpGet:
Expand Down
6 changes: 5 additions & 1 deletion helm/_app/templates/route.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@ spec:
termination: edge
to:
kind: Service
name: {{ include "app.fullname" . }}
name: {{ if .Values.maintenanceMode.enabled }}
{{ include "app.fullname" . }}-maintenance-mode
{{ else }}
{{ include "app.fullname" . }}
{{ end }}
{{- end }}
11 changes: 9 additions & 2 deletions helm/_app/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "app.fullname" . }}
name: {{ include "app.fullname" . }}{{ if .Values.maintenanceMode.enabled }}-maintenance-mode{{ end }}
labels:
{{- include "app.labels" . | nindent 4 }}
{{- if .Values.maintenanceMode.enabled }}
app: maintenance-mode
{{- end }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
- port: {{ if .Values.maintenanceMode.enabled }}{{ .Values.service.maintenancePort }}{{ else }}{{ .Values.service.port }}{{ end }}
targetPort: http
protocol: TCP
name: http
selector:
{{- if .Values.maintenanceMode.enabled }}
app: maintenance-mode
{{- else }}
{{- include "app.selectorLabels" . | nindent 4 }}
{{- end }}
8 changes: 8 additions & 0 deletions helm/_app/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,17 @@ securityContext: {}
# runAsNonRoot: true
# runAsUser: 1000

maintenanceMode:
enabled: false
image:
repository: ghcr.io/bcgov/pltsvc-maintenance-mode
tag: main
pullPolicy: Always

service:
type: ClusterIP
port: 3000
maintenancePort: 7070

route:
enabled: false
Expand Down
23 changes: 0 additions & 23 deletions helm/_maintenance-mode/.helmignore

This file was deleted.

6 changes: 0 additions & 6 deletions helm/_maintenance-mode/Chart.yaml

This file was deleted.

62 changes: 0 additions & 62 deletions helm/_maintenance-mode/templates/_helpers.tpl

This file was deleted.

Loading

0 comments on commit a840edb

Please sign in to comment.