Skip to content

Commit

Permalink
Adding pre-hook to helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
jorge-cr-13 committed May 30, 2024
1 parent a2da9bc commit e367b61
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions charts/base-otc/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ spec:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: {{ .Values.command | toYaml | nindent 12 }} # Add this line for ENTRYPOINT
args: {{ .Values.args | toYaml | nindent 12 }} # Add this line for CMD
env:
{{- if .Values.image.env }}
{{- range $key, $value := .Values.image.env }}
Expand Down
34 changes: 34 additions & 0 deletions charts/base-otc/templates/hooks/pre-install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{{- if .Values.preJob.enabled }}
apiVersion: batch/v1
kind: Job
metadata:
name: "pre-job"
labels:
{{- include "base-otc.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": pre-install
"helm.sh/hook-delete-policy": hook-succeeded
spec:
template:
metadata:
name: "pre-job"
labels:
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
restartPolicy: Never
containers:
- name: "pre-job-container"
image: "{{ .Values.preJob.image }}"
env:
{{- if .Values.preJob.env }}
{{- range $key, $value := .Values.preJob.env }}
- name: {{ $key | quote }}
value: {{ $value | quote }}
{{- end }}
{{- end }}
{{- end }}
3 changes: 3 additions & 0 deletions charts/base-otc/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ image:
# repository: nginx
pullPolicy: IfNotPresent

preJob:
enabled: false

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
Expand Down

0 comments on commit e367b61

Please sign in to comment.