feat(csi): make provider hostPaths configurable (#603)

*  add configurable values for providersDir and kubeletRootDir

Signed-off-by: Toni Tauro <toni.tauro@adfinis.com>

Co-authored-by: Ben Ash <32777270+benashz@users.noreply.github.com>
This commit is contained in:
Toni Tauro 2021-09-15 20:12:24 +02:00 committed by GitHub
parent 8932c372b7
commit 23e0348842
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 74 additions and 2 deletions

View file

@ -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 }}

View file

@ -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

View file

@ -24,6 +24,12 @@
"type": "string"
}
}
},
"providersDir": {
"type": "string"
},
"kubeletRootDir": {
"type": "string"
}
}
},

View file

@ -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