I have an umbrella helm chart which has subcharts. Some of the subcharts have pre-install/pre-upgrade hooks (jobs).
Every time I run helm upgrade <release name> <umbrella chart> the pre-upgrade hooks of all subcharts are executed, even if there are no changes in corresponding subcharts.
Is this expected behavior? And is there a possibility to run subchart hooks only in case when there are changes in subchart?
UPD: more details
So this is the chart structure:
parent_chart/
├─ charts/
│ ├─ child_chart_1/
│ │ ├─ templates/
│ │ │ ├─ hooks_1.yaml
│ │ │ ├─ deployment_1.yaml
│ │ ├─ Chart.yaml
│ │ ├─ values.yaml
│ ├─ child_chart_2/
│ │ ├─ templates/
│ │ │ ├─ deployment_2.yaml
│ │ │ ├─ hooks_2.yaml
│ │ ├─ Chart.yaml
│ │ ├─ values.yaml
├─ values.yaml
├─ Chart.yaml
hook manifest looks like this:
apiVersion: batch/v1
kind: Job
metadata:
name: {{ .Release.Name }}-migration-hook
namespace: {{ .Values.namespace }}
labels:
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
annotations:
"helm.sh/hook": pre-install, pre-upgrade
"helm.sh/hook-weight": "-5"
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
spec:
...
Let's assume this chart is installed.
Then I do changes in child_chart_1/values.yaml and upgrade the umbrella chart:
helm upgrade release_name parent_chart
During the upgrade hooks from both hooks_1.yaml and hooks_2.yaml are executed, but I need only hooks_1.yaml to run, because there are no changes in child_chart_2.