Skip to content

Commit

Permalink
add migration job backend helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
devops-mher committed Aug 26, 2023
1 parent 89210ec commit fb5c77e
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 2 deletions.
2 changes: 1 addition & 1 deletion charts/backend/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: backend
description: Helm chart scaffolding for Backend applications.
type: application
version: 3.6.3
version: 3.6.4
appVersion: 1.3.0
70 changes: 70 additions & 0 deletions charts/backend/templates/migrate-job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{{- if .Values.migration.enabled }}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "ucraft-base-helm.fullname" . }}-migrate
labels:
{{- include "ucraft-base-helm.labels" . | nindent 4 }}
{{- with $annotations := merge .Values.migration.annotations .Values.podAnnotations }}
annotations:
{{- $annotations | toYaml | nindent 4 }}
{{- end }}
spec:
template:
metadata:
labels:
{{- include "ucraft-base-helm.selectorLabels" . | nindent 8 }}
app.kubernetes.io/component: migration
{{- if .Values.migration.podAnnotations }}
annotations: {{- include "ucraft-base-helm.fullname" (dict "value" .Values.migration.podAnnotations "context" $) | nindent 8 }}
{{- end }}
spec:
{{- with .Values.migration.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 6 }}
{{- end }}
restartPolicy: "{{ .Values.migration.restartPolicy }}"
containers:
- name: "{{ include "ucraft-base-helm.fullname" . }}"
image: "{{ .Values.migration.image.repository }}:{{ .Values.migration.image.tag }}"
imagePullPolicy: {{ default "IfNotPresent" .Values.migration.image.pullPolicy }}

{{- if .Values.migration.config.command }}
command:
{{- toYaml .Values.migration.config.command | nindent 14 }}
{{- end }}

{{- if .Values.migration.config.args }}
args:
{{- range $v := .Values.migration.config.args }}
- "{{ $v }}"
{{- end }}
{{- end }}

{{- if .Values.migration.config.env }}
env:
{{- range $k, $v := .Values.migration.config.env }}
- name: "{{ $k }}"
value: "{{ $v }}"
{{- end }}
{{- end }}

{{- if .Values.migration.config.secrets }}
envFrom:
- secretRef:
name: {{ .Release.Name }}-migration-secret
{{- end }}


{{- if .Values.migration.extraVolumeMounts }}
volumeMounts:
{{- toYaml .Values.migration.extraVolumeMounts| nindent 12 }}
{{- end }}
{{- if .Values.migration.resources }}
resources: {{- toYaml .Values.migration.resources | nindent 12 }}
{{- end }}
{{- if .Values.migration.extraVolumes }}
volumes:
{{- toYaml .Values.migration.extraVolumes | nindent 6 }}
{{- end }}
{{- end }}
69 changes: 69 additions & 0 deletions charts/backend/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -356,3 +356,72 @@ cronjob:
gcp:
# -- Service Account email to bind to the k8s service account
serviceAccount: ""

migration:
enabled: false
## In case you want to use a custom image for migration, set this value
## image:
## registry:
## repository:
## tag:
## digest: ""
##
config:
command: []
# - "/bin/sh"
args: []
# - "-c"
# - "echo 'Environment $(hello_env)! Secret $(username).'"

# -- Map of environment variables to use within the job
env: {}
# hello_env: "world"

# -- Map of secrets that will be exposed as environment variables within the job
secrets: {}
# username: "password"

# -- List of config maps to mount to the deployment
configMaps: []
# - name: "volume-1"
# mountPath: "/etc/config" # Must be unique
# mountPropagation: None # If unset will default to 'None'
# files: []
# - key: "file.cfg" # Key must be unique for each file
# contentsB64: "" # The file contents which have already been base-64 encoded
# contentsFile: "" # The path to a local file (note: contentsB64 will take precedence if not-empty)

## @param migration.args Override default container args (useful when using custom images)
##
image:
repository: "busybox"
tag: "latest"
# -- Whether the repository is public
isRepositoryPublic: true
# -- The image pullPolicy to use
pullPolicy: "IfNotPresent"
extraVolumeMounts: []
extraVolumes: []
## Container resource requests and limits
## ref: https://kubernetes.io/docs/user-guide/compute-resources/
## @param migration.resources.limits The resources limits for the container
## @param migration.resources.requests The requested resources for the container
##
resources:
limits: {}
requests: {}
## @param migration.hostAliases Add deployment host aliases
## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/
##
annotations:
helm.sh/hook: post-install, pre-upgrade, pre-rollback
helm.sh/hook-delete-policy: before-hook-creation, hook-succeeded
## @param migration.podLabels Additional pod labels
## Ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
##
restartPolicy: "OnFailure"
podLabels: {}
## @param migration.podAnnotations Additional pod annotations
## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/
##
podAnnotations: {}
2 changes: 1 addition & 1 deletion charts/frontend/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: frontend
description: A frontend Helm chart for Kubernetes
type: application
version: 3.6.3
version: 3.6.4
appVersion: "0.3.10"

0 comments on commit fb5c77e

Please sign in to comment.