From fdac436c3c024974fc2eec67d21041cba8ac42a3 Mon Sep 17 00:00:00 2001 From: Daniil Loktev Date: Thu, 12 Nov 2026 10:55:04 +0300 Subject: [PATCH 1/2] feat(csi): register the storage-foundation proxy socket when the module is enabled Signed-off-by: Daniil Loktev --- charts/helm_lib/templates/_csi_node.tpl | 8 ++++ tests/tests/helm_lib_csi_node_test.yaml | 61 +++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/charts/helm_lib/templates/_csi_node.tpl b/charts/helm_lib/templates/_csi_node.tpl index 3c9d746..a1d594d 100644 --- a/charts/helm_lib/templates/_csi_node.tpl +++ b/charts/helm_lib/templates/_csi_node.tpl @@ -164,7 +164,15 @@ spec: - name: CSI_ENDPOINT value: "/csi/csi.sock" - name: DRIVER_REG_SOCK_PATH + {{- /* + storage-foundation serves dr-proxy.sock next to the socket of the + driver on every node: kubelet calls the driver through it. + */}} + {{- if $context.Values.global.enabledModules | has "storage-foundation" }} + value: "/var/lib/kubelet/csi-plugins/{{ $driverFQDN }}/dr-proxy.sock" + {{- else }} value: "/var/lib/kubelet/csi-plugins/{{ $driverFQDN }}/csi.sock" + {{- end }} - name: KUBE_NODE_NAME valueFrom: fieldRef: diff --git a/tests/tests/helm_lib_csi_node_test.yaml b/tests/tests/helm_lib_csi_node_test.yaml index d4fa363..913096c 100644 --- a/tests/tests/helm_lib_csi_node_test.yaml +++ b/tests/tests/helm_lib_csi_node_test.yaml @@ -424,3 +424,64 @@ tests: documentSelector: path: kind value: DaemonSet + + - it: registers the socket of the driver + set: + global: + modules: + placement: {} + modulesImages: + registry: + base: "deckhouse.io/deckhouse/ce" + digests: + common: + csiNodeDriverRegistrar125: csiNodeDriverRegistrar125 + discovery: + kubernetesVersion: "1.25" + _testvalues: + forceCsiNodeAndStaticNodesDepoloy: true + nodeImage: nodeImage + driverFQDN: driverFQDN + documentSelector: + path: kind + value: DaemonSet + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: DRIVER_REG_SOCK_PATH + value: /var/lib/kubelet/csi-plugins/driverFQDN/csi.sock + + - it: registers the socket of the storage-foundation proxy when the module is enabled + set: + global: + enabledModules: + - storage-foundation + modules: + placement: {} + modulesImages: + registry: + base: "deckhouse.io/deckhouse/ce" + digests: + storageFoundation: + csiNodeDriverRegistrar: csiNodeDriverRegistrar + discovery: + kubernetesVersion: "1.25" + _testvalues: + forceCsiNodeAndStaticNodesDepoloy: true + nodeImage: nodeImage + driverFQDN: driverFQDN + documentSelector: + path: kind + value: DaemonSet + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: DRIVER_REG_SOCK_PATH + value: /var/lib/kubelet/csi-plugins/driverFQDN/dr-proxy.sock + - contains: + path: spec.template.spec.containers[0].env + content: + name: CSI_ENDPOINT + value: /csi/csi.sock From 24819902e9448981a29e883e8cc107a58c4dad9c Mon Sep 17 00:00:00 2001 From: Daniil Loktev Date: Fri, 13 Nov 2026 13:25:42 +0300 Subject: [PATCH 2/2] feat(csi): run the storage-foundation DR proxy as a sidecar of the node plugin Signed-off-by: Daniil Loktev --- charts/helm_lib/templates/_csi_node.tpl | 64 +++++++++++++++++++++++-- tests/tests/helm_lib_csi_node_test.yaml | 51 +++++++++++++++++++- 2 files changed, 109 insertions(+), 6 deletions(-) diff --git a/charts/helm_lib/templates/_csi_node.tpl b/charts/helm_lib/templates/_csi_node.tpl index a1d594d..2bc8a32 100644 --- a/charts/helm_lib/templates/_csi_node.tpl +++ b/charts/helm_lib/templates/_csi_node.tpl @@ -47,6 +47,17 @@ memory: 25Mi {{- $securityPolicyExceptionEnabled := $config.securityPolicyExceptionEnabled | default false }} {{- $kubernetesSemVer := semver $context.Values.global.discovery.kubernetesVersion }} {{- $driverRegistrarImage := include "helm_lib_csi_image_with_common_fallback" (list $context "csiNodeDriverRegistrar" $kubernetesSemVer) }} + {{- /* + storage-foundation replicates block volumes to another cluster: kubelet calls the driver through + the DR proxy, a sidecar that gives the pods asking for the replication of their volumes the DRBD + devices of the volumes. A storage-foundation without the proxy image leaves the node plugin as is. + */}} + {{- $drProxyImage := "" }} + {{- if $context.Values.global.enabledModules | has "storage-foundation" }} + {{- if hasKey (index $context.Values.global.modulesImages.digests "storageFoundation" | default dict) "dr" }} + {{- $drProxyImage = include "helm_lib_csi_image_with_common_fallback" (list $context "dr" $kubernetesSemVer) }} + {{- end }} + {{- end }} {{- if $driverRegistrarImage }} {{- if or $forceCsiNodeAndStaticNodesDepoloy (include "_helm_lib_cloud_or_hybrid_cluster" $context) }} {{- if ($context.Values.global.enabledModules | has "vertical-pod-autoscaler-crd") }} @@ -164,11 +175,8 @@ spec: - name: CSI_ENDPOINT value: "/csi/csi.sock" - name: DRIVER_REG_SOCK_PATH - {{- /* - storage-foundation serves dr-proxy.sock next to the socket of the - driver on every node: kubelet calls the driver through it. - */}} - {{- if $context.Values.global.enabledModules | has "storage-foundation" }} + {{- /* The DR proxy serves dr-proxy.sock next to the socket of the driver. */}} + {{- if $drProxyImage }} value: "/var/lib/kubelet/csi-plugins/{{ $driverFQDN }}/dr-proxy.sock" {{- else }} value: "/var/lib/kubelet/csi-plugins/{{ $driverFQDN }}/csi.sock" @@ -275,6 +283,38 @@ spec: requests: {{- include "helm_lib_module_ephemeral_storage_logs_with_extra" 10 | nindent 12 }} {{- include "node_resources" $context | nindent 12 }} + {{- if $drProxyImage }} + - name: dr-proxy + securityContext: + privileged: true + allowPrivilegeEscalation: true + readOnlyRootFilesystem: true + runAsUser: 0 + runAsNonRoot: false + seccompProfile: + type: RuntimeDefault + image: {{ $drProxyImage | quote }} + command: ["/dr-agent"] + args: + - "proxy" + - "--listen=/csi/dr-proxy.sock" + - "--driver=/csi/csi.sock" + volumeMounts: + - name: plugin-dir + mountPath: /csi + - name: kubelet-dir + mountPath: /var/lib/kubelet + mountPropagation: "Bidirectional" + - name: device-dir + mountPath: /dev + - name: dr-run + mountPath: /run/storage-foundation/dr + resources: + requests: + {{- include "helm_lib_module_ephemeral_storage_only_logs" 10 | nindent 12 }} + cpu: 10m + memory: 20Mi + {{- end }} {{- if $additionalContainers }} {{- $additionalContainers | toYaml | nindent 6 }} @@ -310,6 +350,12 @@ spec: hostPath: path: /dev type: Directory + {{- if $drProxyImage }} + - name: dr-run + hostPath: + path: /run/storage-foundation/dr + type: DirectoryOrCreate + {{- end }} {{- if $additionalNodeVolumes }} {{- $additionalNodeVolumes | toYaml | nindent 6 }} @@ -431,6 +477,14 @@ spec: description: | Allow access to host device directory. CSI Node Driver requires access to /dev to manage block devices and perform disk operations for persistent volumes. + {{- if $drProxyImage }} + - path: /run/storage-foundation/dr + readOnly: false + metadata: + description: | + Allow access to the directory of the storage-foundation DR agent. + The DR proxy calls the agent through its socket and reads the markers of the replicated volumes there. + {{- end }} {{- if $additionalNodeVolumes }} {{- range $volume := $additionalNodeVolumes }} {{- if $volume.hostPath }} diff --git a/tests/tests/helm_lib_csi_node_test.yaml b/tests/tests/helm_lib_csi_node_test.yaml index 913096c..c8e098c 100644 --- a/tests/tests/helm_lib_csi_node_test.yaml +++ b/tests/tests/helm_lib_csi_node_test.yaml @@ -452,7 +452,7 @@ tests: name: DRIVER_REG_SOCK_PATH value: /var/lib/kubelet/csi-plugins/driverFQDN/csi.sock - - it: registers the socket of the storage-foundation proxy when the module is enabled + - it: puts the storage-foundation DR proxy in front of the node plugin when the module ships it set: global: enabledModules: @@ -465,6 +465,7 @@ tests: digests: storageFoundation: csiNodeDriverRegistrar: csiNodeDriverRegistrar + dr: drDigest discovery: kubernetesVersion: "1.25" _testvalues: @@ -485,3 +486,51 @@ tests: content: name: CSI_ENDPOINT value: /csi/csi.sock + - equal: + path: spec.template.spec.containers[2].name + value: dr-proxy + - equal: + path: spec.template.spec.containers[2].image + value: deckhouse.io/deckhouse/ce/modules/storage-foundation@drDigest + - equal: + path: spec.template.spec.containers[2].args + value: ["proxy", "--listen=/csi/dr-proxy.sock", "--driver=/csi/csi.sock"] + - contains: + path: spec.template.spec.volumes + content: + name: dr-run + hostPath: + path: /run/storage-foundation/dr + type: DirectoryOrCreate + + - it: leaves the node plugin as is with a storage-foundation that ships no DR proxy + set: + global: + enabledModules: + - storage-foundation + modules: + placement: {} + modulesImages: + registry: + base: "deckhouse.io/deckhouse/ce" + digests: + storageFoundation: + csiNodeDriverRegistrar: csiNodeDriverRegistrar + discovery: + kubernetesVersion: "1.25" + _testvalues: + forceCsiNodeAndStaticNodesDepoloy: true + nodeImage: nodeImage + driverFQDN: driverFQDN + documentSelector: + path: kind + value: DaemonSet + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: DRIVER_REG_SOCK_PATH + value: /var/lib/kubelet/csi-plugins/driverFQDN/csi.sock + - lengthEqual: + path: spec.template.spec.containers + count: 2