Skip to content

Commit

Permalink
add new options migrate
Browse files Browse the repository at this point in the history
  • Loading branch information
devops-mher committed Aug 26, 2023
1 parent 964dfec commit 89210ec
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 5 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.2
version: 3.6.3
appVersion: 1.3.0
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.2
version: 3.6.3
appVersion: "0.3.10"
6 changes: 3 additions & 3 deletions charts/frontend/templates/cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "laravel.fullname" . }}
name: {{ include "ucraft-base-helm.fullname" . }}
spec:
schedule: "{{ .Values.cronjob.schedule }}"
concurrencyPolicy: "{{ .Values.cronjob.concurrencyPolicy }}"
Expand All @@ -14,7 +14,7 @@ spec:
template:
metadata:
labels:
app: {{ include "laravel.fullname" . }}
app: {{ include "ucraft-base-helm.fullname" . }}
annotations:
{{- if .Values.cronjob.configMaps }}
{{- range $v := .Values.cronjob.configMaps }}
Expand Down Expand Up @@ -54,7 +54,7 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: "{{ include "laravel.fullname" . }}"
- name: "{{ include "ucraft-base-helm.fullname" . }}"
image: "{{ .Values.cronjob.image.repository }}:{{ .Values.cronjob.image.tag }}"
imagePullPolicy: {{ default "IfNotPresent" .Values.cronjob.image.pullPolicy }}

Expand Down
70 changes: 70 additions & 0 deletions charts/frontend/templates/migrate-public-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.image.repository }}:{{ .Values.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/frontend/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,75 @@ extraDeploy:
ports:
- containerPort: 80
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: {}


cronjob:
enabled: false
Expand Down

0 comments on commit 89210ec

Please sign in to comment.