Skip to content
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

dynamic resource allocation #111023

Merged
merged 21 commits into from Nov 12, 2022

Conversation

pohly
Copy link
Contributor

@pohly pohly commented Jul 8, 2022

What type of PR is this?

/kind feature
/kind api-change

What this PR does / why we need it:

This implements the API and control plane part (kube-scheduler, kube-controller-manager, kube-apiserver, controller side of example driver) for Dynamic Resource Allocation.

Which issue(s) this PR fixes:

Related-to: kubernetes/enhancements#3063

Special notes for your reviewer:

Let's try to gather who has reviewed what:

This is using the revised API from kubernetes/enhancements#3502.

To try out the feature, build Kubernetes, then in one console run:

RUNTIME_CONFIG=resource.k8s.io/v1alpha1 FEATURE_GATES=DynamicResourceAllocation=true KUBELET_RESOLV_CONF="/etc/resolv-9999.conf" DNS_ADDON="coredns" CGROUP_DRIVER=systemd CONTAINER_RUNTIME_ENDPOINT=unix:///var/run/crio/crio.sock LOG_LEVEL=6 ENABLE_CSI_SNAPSHOTTER=false API_SECURE_PORT=6444 ALLOW_PRIVILEGED=1 PATH=/nvme/gopath/src/k8s.io/kubernetes/third_party/etcd:$PATH ./hack/local-up-cluster.sh -O

In another:

go run ./test/e2e/dra/test-driver --feature-gates ContextualLogging=true -v=5 controller

In yet another:

sudo mkdir -p /var/run/cdi && sudo chmod a+rwx /var/run/cdi /var/lib/kubelet/plugins_registry /var/lib/kubelet/plugins/
go run ./test/e2e/dra/test-driver --feature-gates ContextualLogging=true -v=6 kubelet-plugin

And finally:

$ kubectl create -f test/e2e/dra/test-driver/deploy/example/resourceclass.yaml 
resourceclass/example created
$ kubectl create -f test/e2e/dra/test-driver/deploy/example/pod-inline.yaml 
configmap/pause-claim-parameters created
pod/pause created
$ kubectl get resourceclaims
NAME             CLASSNAME   ALLOCATIONMODE         STATE                AGE
pause-resource   example     WaitForFirstConsumer   allocated,reserved   19s
pohly@pohly-desktop:/nvme/gopath/src/k8s.io/kubernetes$ kubectl get pods
NAME    READY   STATUS    RESTARTS   AGE
pause   1/1     Running   0          23s

Does this PR introduce a user-facing change?

Add a `ResourceClaim` API (in the resource.k8s.io/v1alpha1 API group and
behind the `DynamicResourceAllocation` feature gate).
The new API is more flexible than the existing Device Plugins feature of Kubernetes because it
allows Pods to request (claim) special kinds of resources, which can be available at node level, cluster
level, or following any other model you implement.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

- [KEP]: https://github.com/kubernetes/enhancements/issues/3063
- [Usage]: TODO

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jul 8, 2022
pkg/features/kube_features.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added area/code-generation area/test sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. sig/testing Categorizes an issue or PR as relevant to SIG Testing. do-not-merge/invalid-owners-file Indicates that a PR should not merge because it has an invalid OWNERS file in it. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jul 8, 2022
Copy link
Contributor

@k8s-ci-robot k8s-ci-robot left a comment

Choose a reason for hiding this comment

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

@pohly: 4 invalid OWNERS files

In response to this:

What type of PR is this?

/kind feature
/kind api-change

What this PR does / why we need it:

This implements the API and control plane part (kube-scheduler, kube-controller-manager, kube-apiserver, controller side of example driver) for Dynamic Resource Allocation.

Which issue(s) this PR fixes:

Related-to: kubernetes/enhancements#3063

Special notes for your reviewer:

This is using the revised API from pohly/enhancements#13. Before we move forward with the implementation, I would like to get confirmation from @alculquicondor and @thockin that this approach is okay and clarify a few remaining questions around the API. I'll add some of my own questions as PR comments.

We also need to decide how we want to merge this: everything in one big PR or split up along reasonable boundaries? Right now, the kubelet changes would be a good fit for a separate PR (different developer and reviewers, current functionality from this PR can be used without kubelet changes as the extended Pod spec will simply get ignored by kubelet).

Either way, the PR is not complete yet. The functionality for the control plane is all there, but tests and API validation are incomplete.

Does this PR introduce a user-facing change?

When the new `DynamicResourceAllocation` feature is enabled, additional resources can be requested for pods through the new ResourceClaim API and third-party resource drivers.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

- [KEP]: https://github.com/kubernetes/enhancements/issues/3063
- [Usage]: TODO

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/test-infra repository.

staging/src/k8s.io/component-helpers/cdi/OWNERS Outdated Show resolved Hide resolved
test/integration/cdi/example-driver/OWNERS Outdated Show resolved Hide resolved
pkg/controller/resourceclaim/OWNERS Outdated Show resolved Hide resolved
pkg/scheduler/framework/plugins/dynamicresources/OWNERS Outdated Show resolved Hide resolved
pkg/apis/core/types.go Outdated Show resolved Hide resolved
pkg/apis/core/types.go Outdated Show resolved Hide resolved
pkg/apis/core/register.go Outdated Show resolved Hide resolved
pkg/apis/core/types.go Outdated Show resolved Hide resolved
@pohly pohly force-pushed the dynamic-resource-allocation branch from bd80049 to dc8b94b Compare July 8, 2022 13:22
Copy link
Contributor

@k8s-ci-robot k8s-ci-robot left a comment

Choose a reason for hiding this comment

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

@pohly: 2 invalid OWNERS files

In response to this:

What type of PR is this?

/kind feature
/kind api-change

What this PR does / why we need it:

This implements the API and control plane part (kube-scheduler, kube-controller-manager, kube-apiserver, controller side of example driver) for Dynamic Resource Allocation.

Which issue(s) this PR fixes:

Related-to: kubernetes/enhancements#3063

Special notes for your reviewer:

This is using the revised API from pohly/enhancements#13. Before we move forward with the implementation, I would like to get confirmation from @alculquicondor and @thockin that this approach is okay and clarify a few remaining questions around the API. I'll add some of my own questions as PR comments.

We also need to decide how we want to merge this: everything in one big PR or split up along reasonable boundaries? Right now, the kubelet changes would be a good fit for a separate PR (different developer and reviewers, current functionality from this PR can be used without kubelet changes as the extended Pod spec will simply get ignored by kubelet).

Either way, the PR is not complete yet. The functionality for the control plane is all there, but tests and API validation are incomplete.

Does this PR introduce a user-facing change?

When the new `DynamicResourceAllocation` feature is enabled, additional resources can be requested for pods through the new ResourceClaim API and third-party resource drivers.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

- [KEP]: https://github.com/kubernetes/enhancements/issues/3063
- [Usage]: TODO

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/test-infra repository.

pkg/controller/resourceclaim/OWNERS Outdated Show resolved Hide resolved
pkg/scheduler/framework/plugins/dynamicresources/OWNERS Outdated Show resolved Hide resolved
@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Nov 11, 2022

@pohly: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubernetes-node-crio-dra 7f7749b link false /test pull-kubernetes-node-crio-dra
pull-publishing-bot-validate 7b6e911 link false /test pull-publishing-bot-validate

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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/test-infra repository. I understand the commands that are listed here.

@BenTheElder
Copy link
Member

The publishing bot tests want the package to exist in the merged branch before adding rules to publish it.

@dims
Copy link
Member

dims commented Nov 11, 2022

/skip pull-publishing-bot-validate

NOTE: this is by design, this CI job will fail in this PR as this PR is adding the new staging repo.

@BenTheElder
Copy link
Member

BenTheElder commented Nov 12, 2022

/skip
(doesn't take arguments / doesn't work with arguments, skips all failing non-required-but-reporting-status jobs)
https://prow.k8s.io/command-help

@thockin thockin removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 12, 2022
@k8s-ci-robot k8s-ci-robot merged commit d1c0171 into kubernetes:master Nov 12, 2022
SIG Node CI/Test Board automation moved this from PRs - Needs Approver to Done Nov 12, 2022
SIG Node PR Triage automation moved this from Triage to Done Nov 12, 2022
SIG Auth Old automation moved this from In Progress to Closed / Done Nov 12, 2022
jaehnri pushed a commit to jaehnri/kubernetes that referenced this pull request Jan 3, 2023
No particular benefit and no relevant changes, it's just to stay up-to-date and
to avoid having to pull that in when merging
kubernetes#111023 which indirectly depends
on the newer release.
// +listType=set
// +featureGate=DynamicResourceAllocation
// +optional
Claims []ResourceClaim `json:"claims,omitempty" protobuf:"bytes,3,opt,name=claims"`
Copy link
Member

@liggitt liggitt Feb 16, 2023

Choose a reason for hiding this comment

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

We just ran across this while reviewing #107776

The ResourceRequirements type is also used within the PersistentVolumeSpec type (which is also used indirectly in pod specs via ephemeral volumes), and the "clear if feature-gate is disabled" logic is only wired to podspec-handling. That means in 1.26 PVC objects or PodSpecs with ephemeral volumes defined can persist data in this field even if the feature is disabled.

Can you open a PR to clear this field in PVC and ephemeral volume create/update flows, and file a follow-up issue to consider splitting the type used in PVCs so it doesn't continue inheriting work done that is targeted at pods?

@81981266
Copy link

Have we decided whether to implement Topology support for DRA or not? @pohly

@pohly
Copy link
Contributor Author

pohly commented Jan 3, 2024

Have we decided whether to implement Topology support for DRA or not?

With topology you mean sub-node topologuy like NUMA? This is out-of-scope for this KEP. It operates at the same level as current scheduler, which is nodes.

However, there are some aspects of DRA that can be used to implement a controller which makes holistic decisions about all pending claims needed by a pod. See @klueska's presentations at KubeCon and the Slack discussions.

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. area/apiserver area/cloudprovider area/code-generation area/dependency Issues or PRs related to dependency changes area/e2e-test-framework Issues or PRs related to refactoring the kubernetes e2e test framework area/kubectl area/kubelet area/provider/gcp Issues or PRs related to gcp provider area/release-eng Issues or PRs related to the Release Engineering subproject area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/cli Categorizes an issue or PR as relevant to SIG CLI. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/release Categorizes an issue or PR as relevant to SIG Release. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. sig/storage Categorizes an issue or PR as relevant to SIG Storage. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on. wg/structured-logging Categorizes an issue or PR as relevant to WG Structured Logging.
Projects
Archived in project
Archived in project
Archived in project
SIG Auth Old
Closed / Done
Development

Successfully merging this pull request may close these issues.

None yet