Skip to content

Commit

Permalink
Merge pull request #98 from dasmeta/DMVP-3648
Browse files Browse the repository at this point in the history
fix(DMVP-3648): Add job , update deployment template
  • Loading branch information
aghamyan44 authored Apr 8, 2024
2 parents e23c436 + ae2ce50 commit 7e69a32
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 2 deletions.
4 changes: 2 additions & 2 deletions charts/base/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.60
version: 0.1.61

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.1.60"
appVersion: "0.1.61"
41 changes: 41 additions & 0 deletions charts/base/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -491,3 +491,44 @@ base:
- mountPath: /config.json
name: config-json
subPath: config.json

### Job
job:
name: db-commands
annotations:
"helm.sh/hook": pre-install,pre-upgrade
image:
repository: ********.dkr.ecr.eu-central-1.amazonaws.com/
tag: latest
pullPolicy: IfNotPresent
volumes:
- name: storage
mountPath: /opt/storage/
envFrom:
secret: api
command:
- "/bin/bash"
- "-c"
- |
env > .env

### Deployment read full secret

envFrom:
secret: site-stage

### Deployment add additionalvolume mount path for same pvc

deployment:
volumes:
- name: storage
mountPath: /storage/aaaa
subPath: aaaa
persistentVolumeClaim:
claimName: storage

additionalvolumeMounts:
- name: storage
mountPath: /storage/bbbb
subPath: bbbb

8 changes: 8 additions & 0 deletions charts/base/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ spec:
name: {{ include "base.fullname" . }}
optional: true
{{- end }}
{{- if .Values.envFrom.secret }}
- secretRef:
name: {{ .Values.envFrom.secret }}
optional: true
{{- end }}
{{- if .Values.deployment.volumes }}
volumeMounts:
{{- range $index, $element := .Values.deployment.volumes }}
Expand All @@ -249,6 +254,9 @@ spec:
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.deployment.additionalvolumeMounts }}
{{- toYaml .Values.deployment.additionalvolumeMounts | nindent 12 }}
{{- end }}
{{- if .Values.deployment.lifecycle }}
lifecycle:
{{- toYaml .Values.deployment.lifecycle | nindent 12 }}
Expand Down
115 changes: 115 additions & 0 deletions charts/base/templates/job.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
{{- if .Values.job -}}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ .Values.job.name | default (include "base.fullname" .) }}
labels:
{{- include "base.labels" . | nindent 4 }}
{{- if .Values.labels }}
{{- range $key, $value := .Values.labels }}
{{ $value.name }}: {{ $value.value | quote}}
{{- end }}
{{- end }}
annotations:
{{- if .Values.job.annotations }}
{{- toYaml .Values.job.annotations | nindent 4 }}
{{- end }}
spec:
template:
metadata:
annotations:
configmap: "{{ .Values.config | toYaml | sha256sum | trunc 8 }}"
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "base.selectorLabels" . | nindent 8 }}
{{- if .Values.labels }}
{{- range $key, $value := .Values.labels }}
{{ $value.name }}: {{ $value.value | quote }}
{{- end }}
{{- end }}
spec:
containers:
- name: {{ .Values.job.name | default (include "base.fullname" .) }}
image: "{{ .Values.job.image.repository }}:{{ .Values.job.image.tag | default .Chart.AppVersion }}"
{{- if .Values.job.command }}
command:
{{ toYaml .Values.job.command | nindent 12 }}
{{- end }}
{{- if or .Values.job.extraEnv .Values.job.secrets}}
env:
{{- range $key, $value := .Values.job.extraEnv }}
- name: {{ $key | quote}}
value: {{ $value | quote }}
{{- end }}
{{- range $secret := .Values.job.secrets }}
{{- if ne (kindOf $secret) "string" }}
{{- range $map_key,$map_value := $secret }}
- name: {{ $map_key }}
valueFrom:
secretKeyRef:
key: {{ $map_value.key }}
name: {{ $map_value.from }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.job.envFrom }}
envFrom:
{{- if .Values.job.envFrom.configMap }}
- configMapRef:
name: {{ .Values.job.envFrom.configMap }}
{{- end }}
{{- if .Values.job.envFrom.secret }}
- secretRef:
name: {{ .Values.job.envFrom.secret }}
optional: true
{{- end }}
{{- end }}
{{- if .Values.job.volumes }}
volumeMounts:
{{- if .Values.job.additionalvolumeMounts }}
{{- toYaml .Values.job.additionalvolumeMounts | nindent 10 }}
{{- end }}
{{- range $index, $element := .Values.job.volumes }}
- name: {{ coalesce $element.name (add $index 1) }}
mountPath: {{ $element.mountPath }}
readOnly: {{ $element.readOnly | default false }}
{{- end }}
{{- end }}
{{- if .Values.deployment.volumes }}
volumes:
{{- range $index, $element := .Values.deployment.volumes }}
- name: {{ coalesce $element.name (add $index 1) }}
{{- if $element.configMap }}
configMap:
name: {{ $element.configMap.name }}
{{- end }}
{{- if $element.persistentVolumeClaim }}
persistentVolumeClaim:
{{- if $element.persistentVolumeClaim.claimName }}
claimName: {{ $element.persistentVolumeClaim.claimName }}
{{- else }}
claimName: {{ include "base.fullname" $ }}
{{- end }}
{{- end }}
{{- if $element.secret }}
secret:
secretName: {{ $element.secret.secretName }}
{{- end }}
{{- if $element.emptyDir }}
emptyDir:
medium: {{ $element.emptyDir.medium }}
sizeLimit: {{ $element.emptyDir.sizeLimit }}
{{- end }}
{{- if $element.hostPath }}
hostPath:
path: {{ $element.hostPath.path }}
type: {{ $element.hostPath.type }}
{{- end }}
{{- end }}
{{- end }}
restartPolicy: Never
backoffLimit: 4
{{- end }}

0 comments on commit 7e69a32

Please sign in to comment.