feat: add helm_lib_api_version_exists and grant VRR RBAC to csi provisioner - #207
Merged
Conversation
…sioner Adds `helm_lib_api_version_exists` — a CRD-presence check over two sources: `.Values.global.discovery.apiVersions` (GVKs from the `crds/` directories of enabled modules, refreshed by deckhouse in global values) and `.Capabilities.APIVersions` (real cluster discovery, which also covers CRDs installed outside of a deckhouse module). Unlike the existing `helm_lib_kind_exists`, it matches the full group/version/kind, does not fail on empty capabilities and takes `global.discovery.apiVersions` into account, so it is usable as a template gate for optional CRDs. Uses it in `helm_lib_csi_controller_rbac`: when the `storage-foundation.deckhouse.io/v1alpha1/VolumeRestoreRequest` CRD is present, the provisioner ClusterRole additionally grants read access to volumerestorerequests and create/patch on persistentvolumeclaims. With storage-foundation enabled, the stock external-provisioner sidecar is replaced with its fork, which runs the VolumeRestoreRequest executor under the module's `csi` ServiceAccount; without these permissions the sidecar gets 403 on the volumerestorerequests informer in every module that deploys it. volumerestorerequests/status is deliberately not granted — the status is owned by the storage-foundation controller. Signed-off-by: v.oleynikov <vasily.oleynikov@flant.com>
krpsh123
approved these changes
Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Preparation for the migration of CSI modules from
snapshot-controllertostorage-foundation.Two changes,
charts/helm_libversion bumped to1.72.13:New define
helm_lib_api_version_exists(_api_version_and_kind.tpl) — returns"true"when a<group>/<version>/<Kind>is available, checking two sources:.Values.global.discovery.apiVersions— GVKs collected by deckhouse from thecrds/directories of enabled modules and put into global values (a change there re-renders every module, so gates built on this helper open without manual action once the CRD provider is enabled);.Capabilities.APIVersions— real cluster discovery, which also covers CRDs installed outside a deckhouse module (by hand, by a third-party operator, by vanilla external-snapshotter).The existing
helm_lib_kind_existsis left untouched and is not reused: itfails on empty capabilities, ignoresglobal.discovery.apiVersionsand matches the kind by suffix without the API group.VolumeRestoreRequest RBAC in
helm_lib_csi_controller_rbac— gated on the presence ofstorage-foundation.deckhouse.io/v1alpha1/VolumeRestoreRequest, the provisioner ClusterRole additionally gets:Why the VRR rules belong here
When
storage-foundationis enabled,helm_lib_csi_image_with_common_fallbackreplaces all CSI sidecars with the storage-foundation forks. The forked external-provisioner additionally runs the VolumeRestoreRequest executor: a cluster-wide informer onvolumerestorerequeststhat provisions the target volume and creates the PV/PVC pair for it. The sidecar is deployed by the driver module, so itscsiServiceAccount needs those permissions in every module that uses this define — including modules without snapshot support, since the executor lives in the provisioner sidecar, not in the snapshotter one.Today these permissions are handed out by the storage-foundation hook
040-vrr-provisioner-rbacfrom a hardcoded namespace list containing a singled8-sds-local-volume, which leaves the other modules with a 403 loop on the informer (reproduced incsi-nfs). storage-foundation itself marks the hook a workaround. Static rules in lib-helm replace it: the hook is to be removed once this version is synced into deckhouse for the in-tree cloud providers.Notes:
volumerestorerequests/statusis deliberately not granted. The status is set by the storage-foundation VRR controller from the state of the target PVC; the sidecar only executes, so it cannot fabricate a Ready status.volumecapturerequestsare not granted either — VCRs are reconciled by the storage-foundation controller alone; the module's csi-snapshotter sidecar only needs the stockexternal-snapshotterrole from this same define.get/list/watch/update) up toget/list/watch/create/update/patch— the set the storage-foundation hook grants.global.discovery.apiVersionschange re-renders the module, so the rules appear no later than the provisioner image is swapped for the fork.Tests
tests/tests/helm_lib_api_version_exists_test.yaml: GVK only inglobal.discovery.apiVersions, only inCapabilities, in neither, and empty capabilities (returns a value without failing).helm_lib_csi_controller_rbacsuite extended with the CRD-present / CRD-absent cases; its test template now passesglobal.discoveryandCapabilitiesin the context.make ci/tests/unit— 358 tests, all green.make doc/diff— clean (charts/helm_lib/README.mdregenerated).For consumers of this helper
Templates that gate on the snapshot stack should use the marker GVK
snapshot.storage.k8s.io/v1/VolumeSnapshotClassinstead of.Values.global.enabledModules | has "snapshot-controller", so that the gate does not depend on which module provides the CRDs: