-
Notifications
You must be signed in to change notification settings - Fork 48
VEP94: add projected volumes in Volume API #95
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
Open
vladikr
wants to merge
1
commit into
kubevirt:main
Choose a base branch
from
vladikr:projected_vols
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
130 changes: 130 additions & 0 deletions
130
veps/sig-compute/projected-volumes-for-service-account-tokens.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| # VEP #94: Extend Volume API to Support Projected Volumes for Service Account Tokens | ||
|
|
||
| ## Release Signoff Checklist | ||
| Items marked with (R) are required *prior to targeting to a milestone / release*. | ||
| - [X] (R) Enhancement issue created, which links to VEP dir in [kubevirt/enhancements] (not the initial VEP PR) | ||
| - [ ] (R) Target version is explicitly mentioned and approved | ||
| - [ ] (R) Graduation criteria filled | ||
|
|
||
| ## Overview | ||
| This VEP proposes extending KubeVirt's Volume API to support Projected Volumes, | ||
| similar to Kubernetes, enabling flexible mounting of service account | ||
| tokens with custom audiences and paths into virtual machines via virtiofs for | ||
| token rotations. This addresses an existing limitation in dynamic | ||
| authentication scenarios like AWS IRSA. | ||
|
|
||
| ## Motivation | ||
| KubeVirt currently mounts service accounts at a hardcoded path which works fine | ||
| for standard Kubernetes API tokens but fails for advanced projections like | ||
| those in AWS IRSA. There are mounted at | ||
| `/var/run/secrets/eks.amazonaws.com/serviceaccount` with audience | ||
| `sts.amazonaws.com`. This prevents VMs from accessing rotated tokens and forces | ||
| users to invent custom workarounds like mutation webhooks or sidecars, adding | ||
| complexity, overhead and security risks. | ||
|
|
||
| KubeVirt exposes virtual machines through a Kubernetes-native API with a | ||
| similar look and feel to Pods, simplifying the user experience and making VM | ||
| management consistent with existing Kubernetes workloads. Supporting Projected | ||
| Volumes extends this approach by enabling declarative and flexible handling of | ||
| projected service account tokens inside VMs. This directly benefits use cases | ||
| in environments like EKS and other multi-cloud setups. | ||
|
|
||
| Discussions in issue #13311 highlight the need for an upstream fix, as | ||
| workarounds are temporary and not integrated. | ||
|
|
||
| ## Goals | ||
| - Extend VolumeSource with Projected field, supporting ServiceAccountTokenProjection. | ||
| - Enable dynamic token propagation via virtiofs. | ||
| - Introduce feature gate for controlled rollout. | ||
| - Ensure backward compatibility and integration tests. | ||
|
|
||
| ## Non Goals | ||
| - Full support for all Kubernetes projection types (focus on service accounts). | ||
| - Support for non-virtiofs dynamic updates. | ||
|
|
||
| ## Definition of Users | ||
| VM owners and workload developers running KubeVirt in cloud environments, such | ||
| as EKS, multi-cloud who need secure, dynamically rotated tokens inside their | ||
| VMs for authentication with external services. Cluster administrators may be | ||
| indirectly impacted but are not the primary users. | ||
|
|
||
| ## User Stories | ||
| - As a VM owner running workloads on EKS, I want to mount IRSA tokens with | ||
| custom audiences into my VM so that applications inside the VM can | ||
| authenticate securely without custom webhooks or sidecars. | ||
| - As a workload developer, I want projected service account tokens to be | ||
| mounted declaratively through the VMI spec, so that I can configure | ||
| authentication in a Kubernetes-native way without extra operational overhead. | ||
| - As a VM user, I want tokens inside my VM to rotate automatically without | ||
| requiring VM restarts, so my applications continue to run securely without | ||
| interruption. | ||
|
|
||
| ## Repos | ||
| - kubevirt/kubevirt (core API and virt-launcher) | ||
|
|
||
| ## Design | ||
| Add `Projected` to `VolumeSource`, with `ServiceAccountTokenProjection` for | ||
| audience, expiration, and path. Virt-launcher detects projections and shares | ||
| via virtiofs. Feature gate: ProjectedVolumes. | ||
|
|
||
| ## API Examples | ||
| ```yaml | ||
| volumes: | ||
| - name: irsa-volume | ||
| projected: | ||
| sources: | ||
| - serviceAccountToken: | ||
| audience: "sts.amazonaws.com" | ||
| expirationSeconds: 3600 | ||
| path: "token" | ||
| ``` | ||
|
|
||
| ## Alternatives | ||
| - Mutation Webhooks: Inject sidecars or modify VM definitions at admission time | ||
| to deliver tokens. While effective, this introduces an external dependency | ||
| and is not integrated into core KubeVirt. (based on repo: kubevirt/irsa-mutation-webhook) | ||
|
|
||
| - Sidecar Injections (based on PR #14568): Run custom containers inside the | ||
| virt-launcher pod to provide token files to the VM. This offers flexibility | ||
| but increases pod complexity, operational burden, and maintenance costs and not supported directly supported. | ||
|
|
||
| - Recursive Secret Scanning: Extend virt-launcher to recursively scan | ||
| /var/run/secrets and expose contents to the VM. This raises significant | ||
| security risks by unintentionally exposing unrelated secrets. | ||
|
|
||
| - QEMU Guest Agent Extensions: Extend the guest agent protocol to push | ||
| projected tokens into the VM filesystem. This avoids virtiofs but requires | ||
| custom controllers for token rotation and introduces additional moving parts. | ||
|
|
||
| - Userspace NFS Server: Run a lightweight NFS server and mount it into the VM | ||
| to deliver projected files. This adds dependencies on NFS, and is not aligned | ||
| with Kubernetes-native volume semantics. | ||
|
|
||
| These are workarounds; the proposed API extension provides a declarative, upstream solution. | ||
|
|
||
| ## Scalability | ||
| Per-VM handling; scales with existing volume limits. Minimal overhead as | ||
| projections are pod-level. | ||
|
|
||
| ## Update/Rollback Compatibility | ||
| - New field is optional; existing VMIs remain unaffected. | ||
| - On downgrade, projected volumes fall back to errors or no-op. | ||
|
|
||
| ## Functional Testing Approach | ||
| - Unit tests: API validation, struct marshaling. | ||
| - Integration tests: Deploy VMI with projected token, verify mount and rotation in guest. | ||
|
|
||
| ## Implementation History | ||
| October 01, 2025: VEP drafted. | ||
|
|
||
| ## Graduation Requirements | ||
| ### Alpha | ||
| - Feature gate enabled. | ||
| - Initial implementation for service account projections. | ||
|
|
||
| ### Beta | ||
| - Full IRSA support. | ||
|
|
||
| ### GA | ||
| - Documentation complete. | ||
| - Featuregate removal. | ||
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking that maybe the API should be:
The only drawback (that I can see) is it will not be integrated with
the rest of projected volume sources (e.g., configMap) if we support
those in the future.
Let me explain:
The current Kubevirt API is:
I don't really like this API because it suggests it can be more
than a single
serviceAccountvolume, so it's confusing. For instance,the k8s API is explicit about that:
So, if we use the proposed API in this VEP we also must define the
serviceAccountNamesomewhere, so we have few options:1- define both the volume and the projection:
Even if this option will allow more projected sources in the future, and
is more similar to k8s API, I think it's not an option because both
have
volumes.namewhich one we should mount?, is very confusing.2- Add
serviceAccountNameunderserviceAccountTokenI also don't think this is a good API, it's not consistent with the
actual API, so what happens if the user defines this and
volumes.serviceAccount.serviceAccountName, which one should havepriority?. The only "pro" I can see is it will allow sharing other projected
sources in the future (if we want to support them)
That is the reason I think
is a bit better, even if it will not be shared with others projected
sources in the future, and is not close to the k8s API. I also have
the advantage that the current admitter code will still prevent
multiple
serviceAccount's@vladikr wdyt?