diff --git a/templates/csi-daemonset.yaml b/templates/csi-daemonset.yaml index 66fe055de..0ab521151 100644 --- a/templates/csi-daemonset.yaml +++ b/templates/csi-daemonset.yaml @@ -70,10 +70,10 @@ spec: volumes: - name: providervol hostPath: - path: "/etc/kubernetes/secrets-store-csi-providers" + path: {{ .Values.csi.daemonSet.providersDir }} - name: mountpoint-dir hostPath: - path: /var/lib/kubelet/pods + path: {{ .Values.csi.daemonSet.kubeletRootDir }}/pods {{- if .Values.csi.volumes }} {{- toYaml .Values.csi.volumes | nindent 8}} {{- end }} diff --git a/test/unit/csi-daemonset.bats b/test/unit/csi-daemonset.bats index c546d0a5b..5cfd8a7e8 100644 --- a/test/unit/csi-daemonset.bats +++ b/test/unit/csi-daemonset.bats @@ -315,6 +315,68 @@ load _helpers [ "${actual}" = "{}" ] } +@test "csi/daemonset: csi providersDir default" { + cd `chart_dir` + + # Test that it defines it + local object=$(helm template \ + --show-only templates/csi-daemonset.yaml \ + --set 'csi.enabled=true' \ + . | tee /dev/stderr | + yq -r '.spec.template.spec.volumes[] | select(.name == "providervol")' | tee /dev/stderr) + + local actual=$(echo $object | + yq -r '.hostPath.path' | tee /dev/stderr) + [ "${actual}" = "/etc/kubernetes/secrets-store-csi-providers" ] +} + +@test "csi/daemonset: csi kubeletRootDir default" { + cd `chart_dir` + + # Test that it defines it + local object=$(helm template \ + --show-only templates/csi-daemonset.yaml \ + --set 'csi.enabled=true' \ + . | tee /dev/stderr | + yq -r '.spec.template.spec.volumes[] | select(.name == "mountpoint-dir")' | tee /dev/stderr) + + local actual=$(echo $object | + yq -r '.hostPath.path' | tee /dev/stderr) + [ "${actual}" = "/var/lib/kubelet/pods" ] +} + +@test "csi/daemonset: csi providersDir override " { + cd `chart_dir` + + # Test that it defines it + local object=$(helm template \ + --show-only templates/csi-daemonset.yaml \ + --set 'csi.enabled=true' \ + --set 'csi.daemonSet.providersDir=/alt/csi-prov-dir' \ + . | tee /dev/stderr | + yq -r '.spec.template.spec.volumes[] | select(.name == "providervol")' | tee /dev/stderr) + + local actual=$(echo $object | + yq -r '.hostPath.path' | tee /dev/stderr) + [ "${actual}" = "/alt/csi-prov-dir" ] +} + +@test "csi/daemonset: csi kubeletRootDir override" { + cd `chart_dir` + + # Test that it defines it + local object=$(helm template \ + --show-only templates/csi-daemonset.yaml \ + --set 'csi.enabled=true' \ + --set 'csi.daemonSet.kubeletRootDir=/alt/kubelet-root' \ + . | tee /dev/stderr | + yq -r '.spec.template.spec.volumes[] | select(.name == "mountpoint-dir")' | tee /dev/stderr) + + local actual=$(echo $object | + yq -r '.hostPath.path' | tee /dev/stderr) + [ "${actual}" = "/alt/kubelet-root/pods" ] +} + #-------------------------------------------------------------------- # volumeMounts diff --git a/values.schema.json b/values.schema.json index c6d7d1039..76ecb5933 100644 --- a/values.schema.json +++ b/values.schema.json @@ -24,6 +24,12 @@ "type": "string" } } + }, + "providersDir": { + "type": "string" + }, + "kubeletRootDir": { + "type": "string" } } }, diff --git a/values.yaml b/values.yaml index 4e3f70c9d..fe998f5a9 100644 --- a/values.yaml +++ b/values.yaml @@ -754,6 +754,10 @@ csi: # YAML-formatted multi-line templated string map of the annotations to apply # to the daemonSet. annotations: {} + # Provider host path (must match the CSI provider's path) + providersDir: "/etc/kubernetes/secrets-store-csi-providers" + # Kubelet host path + kubeletRootDir: "/var/lib/kubelet" pod: # Extra annotations for the provider pods. This can either be YAML or a