mirror of https://github.com/helm/helm
First, some notes about priority and how some code flow works. For Helm handling values, the expected order of precidence is: 1. User specified values (e.g CLI) 2. Imported values 3. Parent chart values 4. Subchart values Helm handles dependency values slightly differently. If there are dependencies in the charts folder that are not marked as dependencies all of the values, including nil values, are pulled in. If those charts are listed as a dependency in the Chart.yaml file than they are processed for import handling. Prior to the changes here, it caused nil values at the top level to NOT remove values specified. The changes: 1. The order of priority was chagned from the list above. Parnet chart values would override specifically imported values. This is due to a change from just over a year ago that introduced a bug. That was undone by changing the precidence when maps were merged. 2. To handle merging while retaining the nil values, which was causing inconsistent behavior, a new set of Merge functions were introduced. These functions are just like coalesce except that they DO NOT remove nil/null values. The new functions are used in a backward compatible manner meaning some new functions were introduced that called them. Specific issues fixed (that are known): Closes #9027 Can now delete subkeys from charts when specified in the parent. This behavior was previously inconsistent. Sometimes they could be deleted and other times it did not work. Now it is consistent. Closes #10899 Imported values (from library or other subcharts) are now used following the order above. The previous behavior was inconsistent. import-values using just a string would import them. When named with a child/parent it did not work if the parent already had a value. If string and named were mixed the imports worked if the string happened first but just for the string not the named. If the named parent/child went first then none of them worked for cases where the parent already had a value. It was inconsistent and the tests sometimes mirrored the functionality rather than expected behavior. Tests for this fall into the sub-packages and are in the template tests to verify it's happening in the output. Including having values passed at the CLI as the ultimate highest priority to be used. This relates to a fix that went in for #9940. The expected values there don't fit the precedence above where the parent value would override the imported value. That fix/change introduced more bugs. Closes #10052 This is the case where imported values using the parent/child designation just didn't work right. That has been fixed and there are tests. The underlying issue had to do with the precedence order handling. Note, a lot of tests were added. Hope we got it more right this time. Signed-off-by: Matt Farina <matt.farina@suse.com>pull/12162/head
parent
4e447d87cd
commit
0a5148faff
@ -0,0 +1,32 @@
|
||||
---
|
||||
# Source: issue-9027/charts/subchart/templates/values.yaml
|
||||
global:
|
||||
hash:
|
||||
key3: 13
|
||||
key4: 4
|
||||
key5: 5
|
||||
key6: 6
|
||||
hash:
|
||||
key3: 13
|
||||
key4: 4
|
||||
key5: 5
|
||||
key6: 6
|
||||
---
|
||||
# Source: issue-9027/templates/values.yaml
|
||||
global:
|
||||
hash:
|
||||
key1: null
|
||||
key2: null
|
||||
key3: 13
|
||||
subchart:
|
||||
global:
|
||||
hash:
|
||||
key3: 13
|
||||
key4: 4
|
||||
key5: 5
|
||||
key6: 6
|
||||
hash:
|
||||
key3: 13
|
||||
key4: 4
|
||||
key5: 5
|
||||
key6: 6
|
@ -0,0 +1,122 @@
|
||||
---
|
||||
# Source: subchart/templates/subdir/serviceaccount.yaml
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: subchart-sa
|
||||
---
|
||||
# Source: subchart/templates/subdir/configmap.yaml
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: subchart-cm
|
||||
data:
|
||||
value: qux
|
||||
---
|
||||
# Source: subchart/templates/subdir/role.yaml
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: subchart-role
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: ["pods"]
|
||||
verbs: ["get","list","watch"]
|
||||
---
|
||||
# Source: subchart/templates/subdir/rolebinding.yaml
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: subchart-binding
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: subchart-role
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: subchart-sa
|
||||
namespace: default
|
||||
---
|
||||
# Source: subchart/charts/subcharta/templates/service.yaml
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: subcharta
|
||||
labels:
|
||||
helm.sh/chart: "subcharta-0.1.0"
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 80
|
||||
protocol: TCP
|
||||
name: apache
|
||||
selector:
|
||||
app.kubernetes.io/name: subcharta
|
||||
---
|
||||
# Source: subchart/charts/subchartb/templates/service.yaml
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: subchartb
|
||||
labels:
|
||||
helm.sh/chart: "subchartb-0.1.0"
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 80
|
||||
protocol: TCP
|
||||
name: nginx
|
||||
selector:
|
||||
app.kubernetes.io/name: subchartb
|
||||
---
|
||||
# Source: subchart/templates/service.yaml
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: subchart
|
||||
labels:
|
||||
helm.sh/chart: "subchart-0.1.0"
|
||||
app.kubernetes.io/instance: "release-name"
|
||||
kube-version/major: "1"
|
||||
kube-version/minor: "20"
|
||||
kube-version/version: "v1.20.0"
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 80
|
||||
protocol: TCP
|
||||
name: nginx
|
||||
selector:
|
||||
app.kubernetes.io/name: subchart
|
||||
---
|
||||
# Source: subchart/templates/tests/test-config.yaml
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: "release-name-testconfig"
|
||||
annotations:
|
||||
"helm.sh/hook": test
|
||||
data:
|
||||
message: Hello World
|
||||
---
|
||||
# Source: subchart/templates/tests/test-nothing.yaml
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: "release-name-test"
|
||||
annotations:
|
||||
"helm.sh/hook": test
|
||||
spec:
|
||||
containers:
|
||||
- name: test
|
||||
image: "alpine:latest"
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: "release-name-testconfig"
|
||||
command:
|
||||
- echo
|
||||
- "$message"
|
||||
restartPolicy: Never
|
@ -0,0 +1,122 @@
|
||||
---
|
||||
# Source: subchart/templates/subdir/serviceaccount.yaml
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: subchart-sa
|
||||
---
|
||||
# Source: subchart/templates/subdir/configmap.yaml
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: subchart-cm
|
||||
data:
|
||||
value: baz
|
||||
---
|
||||
# Source: subchart/templates/subdir/role.yaml
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: subchart-role
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: ["pods"]
|
||||
verbs: ["get","list","watch"]
|
||||
---
|
||||
# Source: subchart/templates/subdir/rolebinding.yaml
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: subchart-binding
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: subchart-role
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: subchart-sa
|
||||
namespace: default
|
||||
---
|
||||
# Source: subchart/charts/subcharta/templates/service.yaml
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: subcharta
|
||||
labels:
|
||||
helm.sh/chart: "subcharta-0.1.0"
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 80
|
||||
protocol: TCP
|
||||
name: apache
|
||||
selector:
|
||||
app.kubernetes.io/name: subcharta
|
||||
---
|
||||
# Source: subchart/charts/subchartb/templates/service.yaml
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: subchartb
|
||||
labels:
|
||||
helm.sh/chart: "subchartb-0.1.0"
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 80
|
||||
protocol: TCP
|
||||
name: nginx
|
||||
selector:
|
||||
app.kubernetes.io/name: subchartb
|
||||
---
|
||||
# Source: subchart/templates/service.yaml
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: subchart
|
||||
labels:
|
||||
helm.sh/chart: "subchart-0.1.0"
|
||||
app.kubernetes.io/instance: "release-name"
|
||||
kube-version/major: "1"
|
||||
kube-version/minor: "20"
|
||||
kube-version/version: "v1.20.0"
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 80
|
||||
protocol: TCP
|
||||
name: nginx
|
||||
selector:
|
||||
app.kubernetes.io/name: subchart
|
||||
---
|
||||
# Source: subchart/templates/tests/test-config.yaml
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: "release-name-testconfig"
|
||||
annotations:
|
||||
"helm.sh/hook": test
|
||||
data:
|
||||
message: Hello World
|
||||
---
|
||||
# Source: subchart/templates/tests/test-nothing.yaml
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: "release-name-test"
|
||||
annotations:
|
||||
"helm.sh/hook": test
|
||||
spec:
|
||||
containers:
|
||||
- name: test
|
||||
image: "alpine:latest"
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: "release-name-testconfig"
|
||||
command:
|
||||
- echo
|
||||
- "$message"
|
||||
restartPolicy: Never
|
@ -0,0 +1,122 @@
|
||||
---
|
||||
# Source: subchart/templates/subdir/serviceaccount.yaml
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: subchart-sa
|
||||
---
|
||||
# Source: subchart/templates/subdir/configmap.yaml
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: subchart-cm
|
||||
data:
|
||||
value: bar
|
||||
---
|
||||
# Source: subchart/templates/subdir/role.yaml
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: subchart-role
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: ["pods"]
|
||||
verbs: ["get","list","watch"]
|
||||
---
|
||||
# Source: subchart/templates/subdir/rolebinding.yaml
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: subchart-binding
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: subchart-role
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: subchart-sa
|
||||
namespace: default
|
||||
---
|
||||
# Source: subchart/charts/subcharta/templates/service.yaml
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: subcharta
|
||||
labels:
|
||||
helm.sh/chart: "subcharta-0.1.0"
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 80
|
||||
protocol: TCP
|
||||
name: apache
|
||||
selector:
|
||||
app.kubernetes.io/name: subcharta
|
||||
---
|
||||
# Source: subchart/charts/subchartb/templates/service.yaml
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: subchartb
|
||||
labels:
|
||||
helm.sh/chart: "subchartb-0.1.0"
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 80
|
||||
protocol: TCP
|
||||
name: nginx
|
||||
selector:
|
||||
app.kubernetes.io/name: subchartb
|
||||
---
|
||||
# Source: subchart/templates/service.yaml
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: subchart
|
||||
labels:
|
||||
helm.sh/chart: "subchart-0.1.0"
|
||||
app.kubernetes.io/instance: "release-name"
|
||||
kube-version/major: "1"
|
||||
kube-version/minor: "20"
|
||||
kube-version/version: "v1.20.0"
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 80
|
||||
protocol: TCP
|
||||
name: nginx
|
||||
selector:
|
||||
app.kubernetes.io/name: subchart
|
||||
---
|
||||
# Source: subchart/templates/tests/test-config.yaml
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: "release-name-testconfig"
|
||||
annotations:
|
||||
"helm.sh/hook": test
|
||||
data:
|
||||
message: Hello World
|
||||
---
|
||||
# Source: subchart/templates/tests/test-nothing.yaml
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: "release-name-test"
|
||||
annotations:
|
||||
"helm.sh/hook": test
|
||||
spec:
|
||||
containers:
|
||||
- name: test
|
||||
image: "alpine:latest"
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: "release-name-testconfig"
|
||||
command:
|
||||
- echo
|
||||
- "$message"
|
||||
restartPolicy: Never
|
@ -0,0 +1,6 @@
|
||||
apiVersion: v2
|
||||
name: issue-9027
|
||||
version: 0.1.0
|
||||
dependencies:
|
||||
- name: subchart
|
||||
version: 0.1.0
|
@ -0,0 +1,3 @@
|
||||
apiVersion: v2
|
||||
name: subchart
|
||||
version: 0.1.0
|
@ -0,0 +1 @@
|
||||
{{ .Values | toYaml }}
|
@ -0,0 +1,17 @@
|
||||
global:
|
||||
hash:
|
||||
key1: 1
|
||||
key2: 2
|
||||
key3: 3
|
||||
key4: 4
|
||||
key5: 5
|
||||
key6: 6
|
||||
|
||||
|
||||
hash:
|
||||
key1: 1
|
||||
key2: 2
|
||||
key3: 3
|
||||
key4: 4
|
||||
key5: 5
|
||||
key6: 6
|
@ -0,0 +1 @@
|
||||
{{ .Values | toYaml }}
|
@ -0,0 +1,11 @@
|
||||
global:
|
||||
hash:
|
||||
key1: null
|
||||
key2: null
|
||||
key3: 13
|
||||
|
||||
subchart:
|
||||
hash:
|
||||
key1: null
|
||||
key2: null
|
||||
key3: 13
|
@ -0,0 +1,5 @@
|
||||
# This file is used to test values passed by file at the command line
|
||||
|
||||
configmap:
|
||||
enabled: true
|
||||
value: "qux"
|
@ -0,0 +1,8 @@
|
||||
{{ if .Values.configmap.enabled -}}
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ .Chart.Name }}-cm
|
||||
data:
|
||||
value: {{ .Values.configmap.value }}
|
||||
{{- end }}
|
@ -0,0 +1,11 @@
|
||||
apiVersion: v2
|
||||
name: app3
|
||||
description: A Helm chart for Kubernetes
|
||||
type: application
|
||||
version: 0.1.0
|
||||
|
||||
dependencies:
|
||||
- name: library
|
||||
version: 0.1.0
|
||||
import-values:
|
||||
- defaults
|
@ -0,0 +1,5 @@
|
||||
apiVersion: v2
|
||||
name: library
|
||||
description: A Helm chart for Kubernetes
|
||||
type: library
|
||||
version: 0.1.0
|
@ -0,0 +1,9 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
spec:
|
||||
type: {{ .Values.service.type }}
|
||||
ports:
|
||||
- port: {{ .Values.service.port }}
|
||||
targetPort: http
|
||||
protocol: TCP
|
||||
name: http
|
@ -0,0 +1,5 @@
|
||||
exports:
|
||||
defaults:
|
||||
service:
|
||||
type: ClusterIP
|
||||
port: 9090
|
@ -0,0 +1 @@
|
||||
{{- include "library.service" . }}
|
@ -0,0 +1,2 @@
|
||||
service:
|
||||
type: ClusterIP
|
@ -0,0 +1,9 @@
|
||||
apiVersion: v2
|
||||
name: app4
|
||||
description: A Helm chart for Kubernetes
|
||||
type: application
|
||||
version: 0.1.0
|
||||
|
||||
dependencies:
|
||||
- name: library
|
||||
version: 0.1.0
|
@ -0,0 +1,5 @@
|
||||
apiVersion: v2
|
||||
name: library
|
||||
description: A Helm chart for Kubernetes
|
||||
type: library
|
||||
version: 0.1.0
|
@ -0,0 +1,9 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
spec:
|
||||
type: {{ .Values.service.type }}
|
||||
ports:
|
||||
- port: {{ .Values.service.port }}
|
||||
targetPort: http
|
||||
protocol: TCP
|
||||
name: http
|
@ -0,0 +1,5 @@
|
||||
exports:
|
||||
defaults:
|
||||
service:
|
||||
type: ClusterIP
|
||||
port: 9090
|
@ -0,0 +1 @@
|
||||
{{- include "library.service" . }}
|
@ -0,0 +1,3 @@
|
||||
service:
|
||||
type: ClusterIP
|
||||
port: 1234
|
Loading…
Reference in new issue