Skip to content

Add distributed snapshotting support to kubernetes-distributed deployment - #653

Open
mnencia wants to merge 1 commit into
kubernetes-csi:masterfrom
mnencia:dev/651
Open

Add distributed snapshotting support to kubernetes-distributed deployment#653
mnencia wants to merge 1 commit into
kubernetes-csi:masterfrom
mnencia:dev/651

Conversation

@mnencia

@mnencia mnencia commented Apr 12, 2026

Copy link
Copy Markdown

What type of PR is this?

/kind feature

What this PR does / why we need it:

The distributed DaemonSet deployment (deploy/kubernetes-distributed/) only includes the csi-provisioner sidecar. This adds the csi-snapshotter with --node-deployment=true, so snapshots work on each node's local volumes.

To support multiple sidecar RBAC roles, this introduces a unified ServiceAccount (csi-hostpathplugin-sa) with explicit ClusterRoleBindings for both the provisioner and snapshotter roles, following the same pattern used by the kubernetes-latest deployment.

The deploy script now handles the full snapshot infrastructure: CRD installation, snapshot-controller deployment with --enable-distributed-snapshotting=true, and node-reader RBAC (required for distributed snapshotting but commented out in the upstream snapshot-controller RBAC). If the snapshot-controller was already deployed (e.g., by prow.sh) without the flag, the script patches it. The destroy script cleans up all of these resources.

Snapshot E2E tests are enabled via snapshotDataSource and SnapshotClass in test-driver.yaml.

Which issue(s) this PR fixes:

Part of #651

Special notes for your reviewer:

Builds on prior work in #392 by @denisok, which went stale before merging.

The distributed snapshotting feature in external-snapshotter (kubernetes-csi/external-snapshotter#585) requires coordination between two components:

  1. The common snapshot-controller must run with --enable-distributed-snapshotting=true to label VolumeSnapshotContent objects with node affinity
  2. The per-node csi-snapshotter sidecar must run with --node-deployment=true to filter by those labels

The upstream snapshot-controller RBAC has Node read permissions commented out. The deploy script applies them via a separate snapshot-controller-node-reader ClusterRole.

Tested on a 3-node Kind cluster: provisioning on different workers, snapshot creation and deletion all work correctly.

Does this PR introduce a user-facing change?:

The kubernetes-distributed deployment now supports volume snapshots on per-node volumes.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Apr 12, 2026
@k8s-ci-robot
k8s-ci-robot requested a review from jingxu97 April 12, 2026 10:42
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mnencia
Once this PR has been reviewed and has the lgtm label, please assign gnufied for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

Welcome @mnencia!

It looks like this is your first PR to kubernetes-csi/csi-driver-host-path 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-csi/csi-driver-host-path has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

Hi @mnencia. Thanks for your PR.

I'm waiting for a kubernetes-csi member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 12, 2026
@mnencia
mnencia marked this pull request as ready for review April 12, 2026 10:43
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 12, 2026
mnencia added a commit to cloudnative-pg/cloudnative-pg that referenced this pull request Apr 13, 2026
Replace the single-node StatefulSet csi-hostpath deployment with
the distributed DaemonSet variant, which runs the CSI driver on
every node with per-node provisioning, snapshotting, and resizing
via --node-deployment sidecars.

This enables multi-node test scenarios (pod failover, node drain,
etc.) where PVCs can be created on different nodes instead of all
landing on the same one.

The resizer sidecar uses a custom image
(ghcr.io/mnencia/csi-resizer:node-deployment) built from
kubernetes-csi/external-resizer#573, pending upstream merge.
The distributed deployment manifests are sourced from
mnencia/csi-driver-host-path#dev/651-with-resizer, pending
kubernetes-csi/csi-driver-host-path#653.

Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
@jsafrane

Copy link
Copy Markdown
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 17, 2026
Comment thread deploy/kubernetes-distributed/deploy.sh Outdated
run kubectl apply --kustomize "${TEMP_DIR}"
done

# Install snapshot CRDs and snapshot-controller if not already present.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think ‎kubernetes-distributed should be in sync with deploy.sh. Either both of them should install snapshot CRDs and the controller or none of them. I personally prefer keep them as they are, without the CRD and controller installation.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Stripped the snapshot CRDs and snapshot-controller install from deploy.sh and the matching cleanup from destroy.sh. The README now documents that snapshot-controller --enable-distributed-snapshotting=true (and the VolumeSnapshot* CRDs) is a prerequisite the operator installs separately, the same way deploy/util/deploy-hostpath.sh works.

While I was at it I also reverted the snapshotDataSource: true flip in deploy/kubernetes-distributed/test-driver.yaml. That was the cause of the pull-kubernetes-csi-csi-driver-host-distributed-on-kubernetes-1-28 failure: with the snapshotter sidecar present but no fix for cross-node snapshot restore, the snapshot E2E suite deadlocks at PreBind waiting for bindTimeout. Cross-node restore is handled by a follow-up controller (csi-topology-coordinator) that I will open as a separate PR; the test-driver flag flips back on there once the controller is in place.

@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 24, 2026
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Apr 24, 2026
…ment

Add the csi-snapshotter sidecar with --node-deployment=true to the
plugin DaemonSet, so each node runs its own snapshotter against its
local .snap data. Add a VolumeSnapshotClass for the
hostpath.csi.k8s.io driver.

Bind one csi-hostpathplugin-sa ServiceAccount to both the
external-provisioner and external-snapshotter ClusterRoles and Roles,
matching the kubernetes-latest deployment layout. The distributed
plugin pod runs both sidecars on every node, so a single
ServiceAccount must hold both role sets.

deploy.sh does not install the external snapshot-controller or the
VolumeSnapshot CRDs. Operators must install snapshot-controller with
--enable-distributed-snapshotting=true and the matching CRDs before
deploying the driver, the same as for deploy/util/deploy-hostpath.sh.
The README documents the prerequisite.

Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
mnencia added a commit to cloudnative-pg/cloudnative-pg that referenced this pull request Apr 27, 2026
Replace the single-node StatefulSet csi-hostpath deployment with
the distributed DaemonSet variant, which runs the CSI driver on
every node with per-node provisioning, snapshotting, and resizing
via --node-deployment sidecars.

This enables multi-node test scenarios (pod failover, node drain,
etc.) where PVCs can be created on different nodes instead of all
landing on the same one.

The resizer sidecar uses a custom image
(ghcr.io/mnencia/csi-resizer:node-deployment) built from
kubernetes-csi/external-resizer#573, pending upstream merge.
The distributed deployment manifests are sourced from
mnencia/csi-driver-host-path#dev/651-with-resizer, pending
kubernetes-csi/csi-driver-host-path#653.

Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
@k8s-triage-robot

Copy link
Copy Markdown

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@kubernetes-prow kubernetes-prow Bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 24, 2026
@mnencia

mnencia commented Jul 25, 2026

Copy link
Copy Markdown
Author

/remove-lifecycle stale

@kubernetes-prow kubernetes-prow Bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants