Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(csi/providersDir): add configurable providersDir #603

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions templates/csi-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
62 changes: 62 additions & 0 deletions test/unit/csi-daemonset.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
"type": "string"
}
}
},
"providersDir": {
"type": "string"
},
"kubeletRootDir": {
"type": "string"
}
}
},
Expand Down
4 changes: 4 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,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
Expand Down