Skip to content

[k8s] add expanding persistent volumes in tenant clusters - #1438

Merged
klinch0 merged 1 commit into
mainfrom
feature/expanding-persistent-volumes-in-tenant-clusters
Sep 23, 2025
Merged

[k8s] add expanding persistent volumes in tenant clusters#1438
klinch0 merged 1 commit into
mainfrom
feature/expanding-persistent-volumes-in-tenant-clusters

Conversation

@klinch0

@klinch0 klinch0 commented Sep 20, 2025

Copy link
Copy Markdown
Contributor

What this PR does

Release note

- add expanding persistent volumes in tenant clusters

Summary by CodeRabbit

  • New Features

    • Enabled PersistentVolumeClaim expansion in the KubeVirt CSI StorageClass.
    • Added CSI resizer sidecar to the controller for online volume resizing.
    • Introduced cluster-scoped RBAC to allow required access to PersistentVolumes.
  • Chores

    • Updated Kubernetes app chart to 0.29.2 and set app version to 1.32.6.
    • Upgraded KubeVirt CSI driver image to 0.37.0.
    • Refreshed versions map entries for the new release.
    • Simplified CoreDNS configuration to use the default image repository.

@coderabbitai

coderabbitai Bot commented Sep 20, 2025

Copy link
Copy Markdown
Contributor

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Increments Kubernetes app chart to 0.29.2 with appVersion 1.32.6, updates kubevirt-csi-driver image, adds csi-resizer sidecar to the controller, introduces cluster-scoped RBAC for PV access, enables StorageClass volume expansion, adjusts CoreDNS values (removes image repository), and updates versions_map entries.

Changes

Cohort / File(s) Summary of Changes
Chart metadata update
packages/apps/kubernetes/Chart.yaml
Bumps chart version 0.29.1 → 0.29.2; adds appVersion: 1.32.6.
KubeVirt CSI image references
packages/apps/kubernetes/images/kubevirt-csi-driver.tag, packages/system/kubevirt-csi-node/values.yaml
Switches kubevirt-csi-driver image to kklinch0/kubevirt-csi-driver:0.37.0 with new digest in both app image tag file and system values.
CSI controller sidecar
packages/apps/kubernetes/templates/csi/deploy.yaml
Adds csi-resizer container (registry.k8s.io/sig-storage/csi-resizer:v1.13.1) with args, mounts, resources, and hardened securityContext; reuses existing volumes.
Cluster-scoped RBAC for kcsi
packages/apps/kubernetes/templates/csi/infra-cluster-service-account.yaml
Adds ClusterRole (get on persistentvolumes) and ClusterRoleBinding to kcsi ServiceAccount.
StorageClass expansion
packages/system/kubevirt-csi-node/templates/deploy.yaml
Adds allowVolumeExpansion: true to StorageClass.
CoreDNS values tweak
packages/system/coredns/values.yaml
Removes coredns.image.repository field; replicaCount unchanged.
Versions map update
packages/apps/versions_map
Pins 0.29.1 to commit 53fbe7c and adds 0.29.2 with HEAD.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Admin as Admin
  participant KAPI as Kubernetes API Server
  participant Resizer as csi-resizer (sidecar)
  participant Ctrl as kcsi-controller (CSI)
  participant CSI as KubeVirt CSI Driver

  Admin->>KAPI: Patch PVC with larger size
  KAPI-->>Resizer: PVC/PV size change event (watch)
  Resizer->>Ctrl: gRPC over /csi/csi.sock: ControllerExpandVolume
  Ctrl->>CSI: Perform volume expansion
  CSI-->>Ctrl: Expansion result (success/failure)
  Ctrl-->>Resizer: gRPC response
  Resizer->>KAPI: Update PV/PVC status and capacity
  note over Resizer,KAPI: Requires ClusterRole get on persistentvolumes
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

ok-to-test

Suggested reviewers

  • kvaps
  • lllamnyp

Poem

I hop through charts with tidy cheer,
A resizer joins the pods this year.
With PV rights and growth in hand,
Our volumes stretch across the land.
CoreDNS sheds a line—so neat!
New tags, new hops—release complete. 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "[k8s] add expanding persistent volumes in tenant clusters" is concise and accurately captures the PR's primary intent — enabling expandable persistent volumes in tenant clusters — and aligns with the changeset which adds allowVolumeExpansion to the StorageClass, a csi-resizer sidecar, and supporting cluster-scoped RBAC. It is specific enough for a reviewer scanning history and avoids vague wording.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/expanding-persistent-volumes-in-tenant-clusters

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello klinch0, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the storage capabilities within tenant Kubernetes clusters by enabling persistent volume expansion. It achieves this by integrating the Kubernetes CSI resizer component into the KubeVirt CSI driver deployment, updating the underlying CSI driver image, and configuring the StorageClass to support volume resizing. These changes provide greater flexibility for users to adjust their storage resources dynamically without manual intervention.

Highlights

  • Persistent Volume Expansion: Enabled the expansion of persistent volumes in tenant Kubernetes clusters by adding the "allowVolumeExpansion: true" flag to the KubeVirt CSI StorageClass definition.
  • CSI Resizer Integration: Introduced the "csi-resizer" sidecar container to the KubeVirt CSI provisioner deployment, along with necessary ClusterRole and ClusterRoleBinding permissions, to manage volume resizing operations.
  • KubeVirt CSI Driver Update: Upgraded the KubeVirt CSI driver image to version "0.37.0" across relevant configurations, ensuring compatibility and leveraging the latest features for storage management.
  • Configuration Schema Refinement: Updated "values.schema.json" to explicitly define default values for various Kubernetes addons and control plane components, improving configuration clarity and consistency.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on Gemini (@gemini-code-assist) comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request enables persistent volume expansion in tenant clusters by adding the csi-resizer sidecar and updating the StorageClass. It also includes updates to the Helm chart version, documentation, and values.schema.json. While the core changes are a good step, I have identified several issues. There is a critical issue with an invalid image version for the csi-resizer, which will prevent it from starting. The RBAC permissions for the CSI driver may also be insufficient. Furthermore, a container image is being pulled from a personal repository, which poses a security and maintenance risk. I've also noted several errors in the documentation and JSON schema files, including incorrect default values and typos.

Comment thread packages/apps/kubernetes/templates/csi/deploy.yaml
@@ -1 +1 @@
ghcr.io/cozystack/cozystack/kubevirt-csi-driver:0.29.1@sha256:cae43eae09fc39e5f2140d30ef55253f871cc565b8b7a564a54077b7cbd92212
kklinch0/kubevirt-csi-driver:0.37.0@sha256:d334ba727f0974b085f6e44ee52a61fa0c507063875b52006665dbacfa332cbd

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.

high

The CSI driver image is being pulled from a personal Docker Hub repository (kklinch0/...). For production-grade software, images should be sourced from an official or organization-controlled registry to ensure security, availability, and maintainability. Using personal repositories introduces a risk and should be avoided.

"md0": {
"ephemeralStorage": "20Gi",
"gpus": [],
"gpus": {},

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.

high

The default value for gpus is set to {}, but the schema defines it as an array. The correct default for an empty array is []. This mismatch can cause issues with schema validation and tooling.

Suggested change
"gpus": {},
"gpus": [],

storageClass: replicated
csiDriver:
image: ghcr.io/cozystack/cozystack/kubevirt-csi-driver:0.29.1@sha256:cae43eae09fc39e5f2140d30ef55253f871cc565b8b7a564a54077b7cbd92212
image: kklinch0/kubevirt-csi-driver:0.37.0@sha256:d334ba727f0974b085f6e44ee52a61fa0c507063875b52006665dbacfa332cbd

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.

high

The CSI driver image is being pulled from a personal Docker Hub repository (kklinch0/...). For production-grade software, images should be sourced from an official or organization-controlled registry to ensure security, availability, and maintainability. Using personal repositories introduces a risk and should be avoided.

Comment thread packages/apps/kubernetes/README.md Outdated
Comment on lines +99 to +100
| `nodeGroups[name].minReplicas` | Minimum amount of replicas | `int` | `{}` |
| `nodeGroups[name].maxReplicas` | Maximum amount of replicas | `int` | `{}` |

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.

medium

The default values for nodeGroups[name].minReplicas and nodeGroups[name].maxReplicas have been changed to {}, but their type is int. This is incorrect and will be confusing for users reading the documentation. Please provide a valid integer default (like 0 and 10 before) or use n/a if there is no default.

Comment thread packages/apps/kubernetes/README.md Outdated
Comment on lines +104 to +108
| `nodeGroups[name].resources` | } Resources available to each worker node | `object` | `{}` |
| `nodeGroups[name].resources.cpu` | CPU available to each worker node | `*quantity` | `null` |
| `nodeGroups[name].resources.memory` | Memory (RAM) available to each worker node | `*quantity` | `null` |
| `nodeGroups[name].gpus` | List of GPUs to attach (WARN: NVIDIA driver requires at least 4 GiB of RAM) | `[]object` | `{}` |
| `nodeGroups[name].gpus[i].name` | Name of GPU, such as "nvidia.com/AD102GL_L40S" | `string` | `""` |
| `nodeGroups[name].gpus` | } List of GPUs to attach (WARN: NVIDIA driver requires at least 4 GiB of RAM) | `[]object` | `[]` |
| `nodeGroups[name].gpus.name` | Name of GPU, such as "nvidia.com/AD102GL_L40S" | `string` | `""` |

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.

medium

There are a few issues in this part of the documentation:

  • Lines 104 and 107: The descriptions for nodeGroups[name].resources and nodeGroups[name].gpus start with a } character, which seems to be a typo.
  • Line 108: The parameter nodeGroups[name].gpus[i].name has been changed to nodeGroups[name].gpus.name. Since gpus is an array of objects, the previous notation was clearer. The new notation is confusing as it implies gpus is an object. Consider using a notation like gpus[].name to indicate it's a property of an object within an array.

},
"gpus": {
"description": "List of GPUs to attach (WARN: NVIDIA driver requires at least 4 GiB of RAM)",
"description": "} List of GPUs to attach (WARN: NVIDIA driver requires at least 4 GiB of RAM)",

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.

medium

The description for gpus starts with a } character, which appears to be a typo.

Suggested change
"description": "} List of GPUs to attach (WARN: NVIDIA driver requires at least 4 GiB of RAM)",
"description": "List of GPUs to attach (WARN: NVIDIA driver requires at least 4 GiB of RAM)",

},
"resources": {
"description": "Resources available to each worker node",
"description": "} Resources available to each worker node",

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.

medium

The description for resources starts with a } character, which appears to be a typo.

Suggested change
"description": "} Resources available to each worker node",
"description": "Resources available to each worker node",

Signed-off-by: kklinch0 <kklinch0@gmail.com>
@klinch0
klinch0 force-pushed the feature/expanding-persistent-volumes-in-tenant-clusters branch from 966d873 to ca19529 Compare September 20, 2025 11:10

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 0

♻️ Duplicate comments (2)
packages/system/kubevirt-csi-node/values.yaml (1)

3-3: Do not use a personal Docker Hub image for the CSI driver.

Use an organization-controlled registry (e.g., ghcr.io/cozystack/...) and pin a known-good digest. Personal repos are a supply‑chain and availability risk.

Verify all references to this image across the repo:

#!/bin/bash
rg -n 'kklinch0/kubevirt-csi-driver|kubevirt-csi-driver:' -C2
packages/apps/kubernetes/images/kubevirt-csi-driver.tag (1)

1-1: Replace personal image with org-controlled image.

Same concern as values.yaml. Promote/publish 0.37.0 to your official registry and reference that digest here.

#!/bin/bash
# Ensure only a single source of truth for the driver image tag
rg -nP 'kubevirt-csi-driver:(\d+\.\d+\.\d+)|kklinch0/kubevirt-csi-driver' -C2
🧹 Nitpick comments (2)
packages/apps/kubernetes/Chart.yaml (1)

19-19: Version bump looks good. Consider minor bump for a new feature.

Enabling volume expansion and adding a sidecar is a feature, not a fix; 0.30.0 may better reflect semver for the chart.

packages/apps/kubernetes/templates/csi/deploy.yaml (1)

208-231: Enable leader election; csi-resizer:v1.13.1 verified

packages/apps/kubernetes/templates/csi/deploy.yaml (lines 208–231): image exists and requires Kubernetes ≥ v1.16 (v1.13.x series documented for recent releases up through v1.32).

-        - name: csi-resizer
-          image: registry.k8s.io/sig-storage/csi-resizer:v1.13.1
+        - name: csi-resizer
+          image: registry.k8s.io/sig-storage/csi-resizer:v1.13.1
           args:
             - "-csi-address=/csi/csi.sock"
             - "-kubeconfig=/etc/kubernetes/kubeconfig/super-admin.svc"
             - "-v=5"
             - "-timeout=3m"
             - '-handle-volume-inuse-error=false'
+            - "--leader-election=true"
+            - "--leader-election-namespace=$(INFRACLUSTER_NAMESPACE)"

Also pin other non-resizer sidecars (avoid :latest) for reproducibility.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 53fbe7c and ca19529.

📒 Files selected for processing (8)
  • packages/apps/kubernetes/Chart.yaml (1 hunks)
  • packages/apps/kubernetes/images/kubevirt-csi-driver.tag (1 hunks)
  • packages/apps/kubernetes/templates/csi/deploy.yaml (1 hunks)
  • packages/apps/kubernetes/templates/csi/infra-cluster-service-account.yaml (1 hunks)
  • packages/apps/versions_map (1 hunks)
  • packages/system/coredns/values.yaml (0 hunks)
  • packages/system/kubevirt-csi-node/templates/deploy.yaml (1 hunks)
  • packages/system/kubevirt-csi-node/values.yaml (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/system/coredns/values.yaml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build
🔇 Additional comments (4)
packages/apps/kubernetes/Chart.yaml (1)

25-25: Confirm appVersion alignment.
appVersion 1.32.6 appears in Chart.yaml and is referenced by Cilium image tags — confirm controller/sidecar images and any user‑visible "app version" semantics in release notes actually target 1.32.6. Refs: packages/apps/kubernetes/Chart.yaml:25; packages/apps/kubernetes/files/versions.yaml:5; packages/system/cilium/charts/cilium/values.yaml:2356; packages/system/cilium/charts/cilium/README.md:381.

packages/apps/versions_map (1)

75-76: Pin kubernetes 0.29.2 to a commit SHA (replace HEAD)
packages/apps/versions_map:76 — currently kubernetes 0.29.2 HEAD; replace HEAD with the exact commit SHA to ensure reproducible chart releases.

packages/apps/kubernetes/templates/csi/infra-cluster-service-account.yaml (1)

39-61: RBAC likely too narrow for PVs.

At minimum, add list and watch on persistentvolumes; consider patch if annotations/status updates are needed by the driver flow.

Apply:

-  verbs: ["get"]
+  verbs: ["get", "list", "watch"]
packages/system/kubevirt-csi-node/templates/deploy.yaml (1)

276-276: StorageClass expansion enabled — verify driver capabilities end-to-end

  • Confirmed: allowVolumeExpansion: true at packages/system/kubevirt-csi-node/templates/deploy.yaml:276; csi-resizer sidecar present in controller manifest packages/apps/kubernetes/templates/csi/deploy.yaml:208–209 (image registry.k8s.io/sig-storage/csi-resizer:v1.13.1).
  • Action: Verify kubevirt-csi-driver v0.37.0 implements ControllerExpandVolume and NodeExpandVolume (both controller- and node-side expansion behavior).
  • Recommendation: Make allowVolumeExpansion configurable via values (default false) if expansion should be opt-in.

@lllamnyp Timofei Larkin (lllamnyp) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@klinch0
klinch0 merged commit 3ac83ac into main Sep 23, 2025
20 checks passed
@klinch0
klinch0 deleted the feature/expanding-persistent-volumes-in-tenant-clusters branch September 23, 2025 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants