Skip to content

Conversation

alaypatel07
Copy link
Contributor

@alaypatel07 alaypatel07 commented Oct 3, 2025

  • One-line PR description:
    KEP-5304: Adding downward API for DRA Device Attributes to Pod
  • Other comments:

@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory labels Oct 3, 2025
@k8s-ci-robot k8s-ci-robot added sig/node Categorizes an issue or PR as relevant to SIG Node. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Oct 3, 2025
@alaypatel07
Copy link
Contributor Author

/wg-device-management

@alaypatel07 alaypatel07 force-pushed the kep-5304 branch 3 times, most recently from 3c92417 to 3557abc Compare October 3, 2025 16:27
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

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 k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Oct 3, 2025
@alaypatel07 alaypatel07 force-pushed the kep-5304 branch 2 times, most recently from 92f13db to 96e3424 Compare October 3, 2025 17:03
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Oct 3, 2025
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Oct 3, 2025
@kannon92
Copy link
Contributor

kannon92 commented Oct 3, 2025

Please combine PRR into this PR.

We usually review as one PR.

@alaypatel07
Copy link
Contributor Author

@kannon92 This PR already has the PRR. If a single PR is to be reviewed, all I need to do is close the other PR


- Provide a stable Downward API path for device attributes associated with `pod.spec.resourceClaims[*]` requests
- Support any attributes defined in ResourceSlice objects, controlled by the allowlist mechanism
- Allow resource owners to explicitly allowlist which attributes are exposed (maximum 8 per request) for security and control
Copy link
Member

Choose a reason for hiding this comment

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

Who do we consider as the "resource owners" here and how do specify the allowlist? From reading this KEP, it seems like there is a system allowlist that for alpha will contain resource.kubernetes.io/pcieRoot and dra.kubervirt.io/mdevUUID and an allowlist on the request. I would think of the "resource owners" as the cluster admin (or whoever configures the DRA driver) and there doesn't seem to be an allowlist available for them.

- Environment variables are set at container start time: Once a container starts, its environment variables are immutable. If device attributes change after container start, env vars will not reflect the change.
- Projected volumes support updates: Files in projected volumes will be updated atomically when the kubelet's cache detects changes to the underlying ResourceClaim or ResourceSlice.
- Allowlist enforcement: The kubelet MUST enforce the per-request allowlist. If an attribute is not in the allowlist, attempts to reference it via `draDeviceFieldRef` will fail.
- Attribute names: Any attribute name that exists in the ResourceSlice can be referenced, as long as it is allowlisted. The API server does not validate attribute names against a hardcoded list, allowing vendors to define their own attributes (e.g., `dra.kubervirt.io/mdevUUID`).
Copy link
Member

Choose a reason for hiding this comment

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

The sentence Enforce membership in the supported attribute set (alpha: resource.kubernetes.io/pcieRoot, dra.kubervirt.io/mdevUUID) in https://github.com/kubernetes/enhancements/blob/656815421ad608bb4b0ed0f3f9a067d819e97cda/keps/sig-node/5304-dra-attributes-downward-api/README.md#resource-api-per-request-allowlist seems to contradict this?

// DRADeviceFieldRef selects a DRA-resolved device attribute for a given claim+request.
// +featureGate=DRADownwardDeviceAttributes
// +structType=atomic
type DRADeviceFieldRef struct {
Copy link
Member

Choose a reason for hiding this comment

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

This can map to more than one device, since each request might ask for multiple devices. How is the data surfaced in the env variables or the volume? The DRA device names doesn't necessarily map to any identifier that is known to the consumer of this information.

}
```

Validation:
Copy link
Member

Choose a reason for hiding this comment

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

So this is validation on admission, but presumably it is an error if any of the references can't be resolved when the kubelet tries to resolve the references? Or is it just ignored?

3. Watches ResourceSlices: Resolves standardized attributes from `spec.devices[*].attributes` for the matching device name
4. Maintains Cache: Keeps a per-Pod map of `(claimName, requestName) -> {attribute: value}` with a readiness flag

Resolution Semantics:
Copy link
Member

Choose a reason for hiding this comment

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

What about error handling here? I'm wondering what happens if:

  • A claim or request can't be found?
  • The requested attribute is not available for one or more of the allocated devices?

// DRADeviceFieldRef selects a DRA-resolved device attribute for a given claim+request.
// +featureGate=DRADownwardDeviceAttributes
// +structType=atomic
type DRADeviceFieldRef struct {
Copy link
Member

Choose a reason for hiding this comment

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

The name here seems inconsistent with the current naming convention: https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/api/core/v1/types.go#L2473

- For container environment variables, resolution happens at container start using the latest ready values
- For projected volumes, kubelet updates files via AtomicWriter when cache changes
- Kubelet MUST honor the per-request allowlist; if `draDeviceFieldRef.attribute` is not in the allowlist, the value is not exposed
- If data is not ready when a container starts, resolution fails for required env vars or leaves optional ones unset
Copy link
Member

Choose a reason for hiding this comment

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

How can users specify a reference as optional? Looking at the current code, it looks like this should be a field on DRADeviceFieldRef.

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. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory sig/node Categorizes an issue or PR as relevant to SIG Node. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants