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

Implement ResourceFlavor API #133

Merged
merged 1 commit into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ resources:
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
namespaced: false
controller: true
domain: x-k8s.io
group: kueue
Expand All @@ -33,7 +33,7 @@ resources:
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
namespaced: false
domain: x-k8s.io
group: kueue
kind: ResourceFlavor
Expand Down
19 changes: 6 additions & 13 deletions api/v1alpha1/clusterqueue_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,29 +221,22 @@ type Resource struct {
// guaranteed: 100
//
// +listType=map
// +listMapKey=name
// +listMapKey=resourceFlavor
Flavors []Flavor `json:"flavors,omitempty"`
}

type Flavor struct {
// name is the type name, e.g., nvidia-tesla-k80.
// resourceFlavor is a reference to the resourceFlavor that defines this flavor.
// +kubebuilder:default=default
Name string `json:"name"`
ResourceFlavor ResourceFlavorReference `json:"resourceFlavor"`

// quota is the limit of resource usage at a point in time.
Quota Quota `json:"quota"`

// labels associated with this type. Those labels are matched against or
// converted to node affinity constraints on the workload’s pods.
// For example, cloud.provider.com/accelerator: nvidia-tesla-k80.
Labels map[string]string `json:"labels,omitempty"`

// taints associated with this constraint that workloads must explicitly
// “tolerate” to be able to use this type.
// e.g., cloud.provider.com/preemptible="true":NoSchedule
Taints []corev1.Taint `json:"taints,omitempty"`
}

// ResourceFlavorReference is the name of the ResourceFlavor.
type ResourceFlavorReference string

type Quota struct {
// guaranteed amount of resource requests that are available to be used by
// running workloads assigned to this quota. This value should not exceed
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/resourceflavor_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
)

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:resource:scope=Cluster

// ResourceFlavor is the Schema for the resourceflavors API
type ResourceFlavor struct {
Expand Down
14 changes: 0 additions & 14 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 7 additions & 47 deletions config/crd/bases/kueue.x-k8s.io_clusterqueues.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,18 +186,6 @@ spec:
name: on-demand quota: guaranteed: 100"
items:
properties:
labels:
additionalProperties:
type: string
description: 'labels associated with this type. Those
labels are matched against or converted to node affinity
constraints on the workload’s pods. For example, cloud.provider.com/accelerator:
nvidia-tesla-k80.'
type: object
name:
default: default
description: name is the type name, e.g., nvidia-tesla-k80.
type: string
quota:
description: quota is the limit of resource usage at a
point in time.
Expand Down Expand Up @@ -227,46 +215,18 @@ spec:
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
taints:
description: taints associated with this constraint that
workloads must explicitly “tolerate” to be able to use
this type. e.g., cloud.provider.com/preemptible="true":NoSchedule
items:
description: The node this Taint is attached to has
the "effect" on any pod that does not tolerate the
Taint.
properties:
effect:
description: Required. The effect of the taint on
pods that do not tolerate the taint. Valid effects
are NoSchedule, PreferNoSchedule and NoExecute.
type: string
key:
description: Required. The taint key to be applied
to a node.
type: string
timeAdded:
description: TimeAdded represents the time at which
the taint was added. It is only written for NoExecute
taints.
format: date-time
type: string
value:
description: The taint value corresponding to the
taint key.
type: string
required:
- effect
- key
type: object
type: array
resourceFlavor:
default: default
description: resourceFlavor is a reference to the resourceFlavor
that defines this flavor.
type: string
required:
- name
- quota
- resourceFlavor
type: object
type: array
x-kubernetes-list-map-keys:
- name
- resourceFlavor
x-kubernetes-list-type: map
name:
description: name of the resource. For example, cpu, memory
Expand Down
4 changes: 1 addition & 3 deletions config/crd/bases/kueue.x-k8s.io_resourceflavors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ spec:
listKind: ResourceFlavorList
plural: resourceflavors
singular: resourceflavor
scope: Namespaced
scope: Cluster
versions:
- name: v1alpha1
schema:
Expand Down Expand Up @@ -70,8 +70,6 @@ spec:
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
Expand Down
8 changes: 8 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ rules:
- get
- patch
- update
- apiGroups:
- kueue.x-k8s.io
resources:
- resourceflavors
verbs:
- get
- list
- watch
- apiGroups:
- scheduling.k8s.io
resources:
Expand Down
8 changes: 6 additions & 2 deletions config/samples/minimal.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
apiVersion: kueue.x-k8s.io/v1alpha1
kind: ResourceFlavor
metadata:
name: default
---
apiVersion: kueue.x-k8s.io/v1alpha1
kind: ClusterQueue
Expand All @@ -8,13 +12,13 @@ spec:
requestableResources:
- name: "cpu"
flavors:
- name: default
- resourceFlavor: default
quota:
guaranteed: 9
ceiling: 9
- name: "memory"
flavors:
- name: default
- resourceFlavor: default
quota:
guaranteed: 36Gi
ceiling: 36Gi
Expand Down
4 changes: 4 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "QueuedWorkload")
os.Exit(1)
}
if err = core.NewResourceFlavorReconciler(cache).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "ResourceFlavor")
os.Exit(1)
}
if err = job.NewReconciler(mgr.GetScheme(), mgr.GetClient(),
mgr.GetEventRecorderFor(constants.JobControllerName)).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "Job")
Expand Down
Loading