Skip to content

feat: add support for generic ephemeral volumes#16590

Merged
knative-prow[bot] merged 1 commit into
knative:mainfrom
jbunting:feat/ephemeral-volumes
May 12, 2026
Merged

feat: add support for generic ephemeral volumes#16590
knative-prow[bot] merged 1 commit into
knative:mainfrom
jbunting:feat/ephemeral-volumes

Conversation

@jbunting
Copy link
Copy Markdown
Contributor

@jbunting jbunting commented May 8, 2026

Relates to #4417

Description

This feature introduces support for generic ephemeral volumes (volumeClaimTemplate) in Knative Serving, enabling users to dynamically provision per-pod storage through any Kubernetes StorageClass. This is particularly useful for workloads that need local high-performance scratch space, such as NVMe storage on cloud VMs provisioned via a local StorageClass, while retaining Knative's autoscaling capabilities.

Proposed Changes

  • Add support for generic ephemeral volume type in Knative Serving
  • Enable users to mount ephemeral volumes into their Knative service containers
  • Add feature flag control for ephemeral volume support
  • Exempt ephemeral volumes from forced readOnly defaulting and validation, matching existing behavior for emptyDir and PersistentVolumeClaim
  • Add ephemeral volume field to Configuration, Revision, and Service CRD schemas

Release Note

Adding support for generic ephemeral volumes. This feature allows users to mount dynamically provisioned ephemeral volumes into their Knative service containers using volumeClaimTemplate. It enables per-pod storage provisioned through any Kubernetes StorageClass, such as local NVMe or cloud provider block storage. The feature is behind the flag `kubernetes.podspec-volumes-ephemeral`.

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented May 8, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: jbunting / name: Jared Bunting (1295f8e)

@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 8, 2026

Welcome @jbunting! It looks like this is your first PR to knative/serving 🎉

@knative-prow knative-prow Bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 8, 2026
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 8, 2026

Hi @jbunting. Thanks for your PR.

I'm waiting for a knative 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.

@knative-prow knative-prow Bot requested review from dsimansk and skonto May 8, 2026 04:17
@linkvt
Copy link
Copy Markdown
Member

linkvt commented May 8, 2026

Thanks for this PR, looks great from my side but a maintainer has to give it another look :)

/ok-to-test

@knative-prow knative-prow Bot 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 May 8, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

Codecov Report

❌ Patch coverage is 92.30769% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 80.20%. Comparing base (fb213e0) to head (1295f8e).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
pkg/apis/serving/v1/revision_defaults.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16590      +/-   ##
==========================================
- Coverage   80.21%   80.20%   -0.01%     
==========================================
  Files         217      217              
  Lines       13545    13556      +11     
==========================================
+ Hits        10865    10873       +8     
  Misses       2318     2318              
- Partials      362      365       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

FeaturePodSpecShareProcessNamespace = "kubernetes.podspec-shareprocessnamespace"
FeaturePodSpecTolerations = "kubernetes.podspec-tolerations"
FeaturePodSpecTopologySpreadConstraints = "kubernetes.podspec-topologyspreadconstraints"
FeaturePodSpecVolumesEphemeral = "kubernetes.podspec-volumes-ephemeral"
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.

We should probably also add a test for this new feature as there are tests in features_test.go for the other Volumes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point, I'll add that.

Comment on lines +1183 to +1187
ephemeral:
description: |-
This is accessible behind a feature flag - kubernetes.podspec-volumes-ephemeral
type: object
x-kubernetes-preserve-unknown-fields: true
Copy link
Copy Markdown
Member

@linkvt linkvt May 8, 2026

Choose a reason for hiding this comment

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

I just learned that we should extend the following code to get these changes instead of manually applying them:

}, {
name: "csi",
flag: config.FeaturePodSpecVolumesCSI,
}, {
name: "image",
flag: config.FeaturePodSpecVolumesImage,
}},

(CI failed for this reason)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah, I missed that. I'll get that updated.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've added this and the related test is passing now.

@jbunting jbunting force-pushed the feat/ephemeral-volumes branch from 7f2b2c7 to d0ccf6c Compare May 8, 2026 19:58
@jbunting
Copy link
Copy Markdown
Contributor Author

jbunting commented May 8, 2026

/retest

Add a new feature flag `kubernetes.podspec-volumes-ephemeral` to allow
generic ephemeral volumes (volumeClaimTemplate) in Knative services.
This enables workloads that need per-pod dynamically provisioned storage,
such as local NVMe scratch space on cloud VMs.

Also exempt ephemeral volumes from the forced readOnly default, matching
the existing behavior for emptyDir and PersistentVolumeClaim volumes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jbunting jbunting force-pushed the feat/ephemeral-volumes branch from d0ccf6c to 1295f8e Compare May 8, 2026 20:01
@knative-prow knative-prow Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 8, 2026
@jbunting
Copy link
Copy Markdown
Contributor Author

jbunting commented May 8, 2026

/test all

Copy link
Copy Markdown
Member

@linkvt linkvt left a comment

Choose a reason for hiding this comment

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

/lgtm but I'm not a maintainer who still has to review and approve

@knative-prow knative-prow Bot added the lgtm Indicates that a PR is ready to be merged. label May 9, 2026
@jbunting
Copy link
Copy Markdown
Contributor Author

jbunting commented May 11, 2026

/lgtm but I'm not a maintainer who still has to review and approve

Thanks for looking at it!

Is there anything else I can do to make it easier for a maintainer to look at?

@linkvt
Copy link
Copy Markdown
Member

linkvt commented May 11, 2026

Not right now, it's not a completely new topic (similar logic exists for the other volume types already) so it's just about when he's finding time.

@dprotaso
Copy link
Copy Markdown
Member

/lgtm
/approve

thanks for the contribution

What are your thoughts about allowing ephemeral volumes without the feature flag?

Generally we were cautious of volumes in the past to avoid people shooting themselves in the foot - eg. NFS volumes not handling load well when things scale up. But it's not obvious to me if that's possible with this ephemeral volumes - seems akin to emptyDir which we allow.

@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 12, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dprotaso, jbunting, linkvt

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

The pull request process is described 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

@knative-prow knative-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 12, 2026
@knative-prow knative-prow Bot merged commit 4135535 into knative:main May 12, 2026
67 checks passed
@jbunting
Copy link
Copy Markdown
Contributor Author

I'm far from an expert but I'm pretty sure that's accurate -- ephemeral volumes are pretty much akin to emptyDir. That's definitely how we use them (we just need the dirs to be created on a specific drive on the node and emptyDir doesn't give us that flexibility without a whole bunch of kubelet reconfiguration that would be bad for other reasons). So yeah, "more configurable emptyDir" seems about right to me.

That being said, I think not having it behind a feature flag makes plenty of sense. I included the feature flag because I figured following the existing pattern would be the smoothest way to contribute.

@dprotaso
Copy link
Copy Markdown
Member

Thanks for the reply

That being said, I think not having it behind a feature flag makes plenty of sense. I included the feature flag because I figured following the existing pattern would be the smoothest way to contribute.

I say let's use the feature flag for a release or two and revisit the decision

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

3 participants