Skip to content

Commit

Permalink
capacity scheduling on framework api define
Browse files Browse the repository at this point in the history
  • Loading branch information
denkensk committed Sep 29, 2020
1 parent 88c2dea commit 09a84c7
Show file tree
Hide file tree
Showing 61 changed files with 2,098 additions and 121 deletions.
2 changes: 1 addition & 1 deletion hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ bash "${CODEGEN_PKG}"/generate-groups.sh \
all \
sigs.k8s.io/scheduler-plugins/pkg/generated \
sigs.k8s.io/scheduler-plugins/pkg/apis \
podgroup:v1alpha1 \
"scheduling:v1alpha1" \
--go-header-file "${SCRIPT_ROOT}"/hack/boilerplate/boilerplate.generatego.txt
34 changes: 34 additions & 0 deletions manifests/capacityscheduling/crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: elasticquotas.scheduling.sigs.k8s.io
spec:
group: scheduling.sigs.k8s.io
versions:
- name: v1alpha1
served: true
storage: true
scope: Namespaced
names:
plural: elasticquotas
singular: elasticquota
kind: ElasticQuota
shortNames:
- eq
- eqs
validation:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
min:
type: object
max:
type: object
status:
type: object
properties:
used:
type: object
14 changes: 14 additions & 0 deletions manifests/capacityscheduling/elasticquota-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: scheduling.sigs.k8s.io/v1alpha1
kind: ElasticQuota
metadata:
name: test
namespace: test
spec:
max:
cpu: 20
memory: 40Gi
nvidia.com/gpu: 2
min:
cpu: 10
memory: 20Gi
nvidia.com/gpu: 1
24 changes: 24 additions & 0 deletions manifests/capacityscheduling/scheduler-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: kubescheduler.config.k8s.io/v1beta1
kind: KubeSchedulerConfiguration
leaderElection:
leaderElect: false
clientConnection:
kubeconfig: "REPLACE_ME_WITH_KUBE_CONFIG_PATH"
profiles:
- schedulerName: default-scheduler
plugins:
preFilter:
enabled:
- name: CapacityScheduling
postFilter:
enabled:
- name: CapacityScheduling
disabled:
- name: "*"
reserve:
enabled:
- name: CapacityScheduling
pluginConfig:
- name: CapacityScheduling
args:
kubeConfigPath: "REPLACE_ME_WITH_KUBE_CONFIG_PATH"
22 changes: 22 additions & 0 deletions pkg/apis/capacity/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
Copyright 2020 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package capacity

// GroupName is the group name used in this package
const (
GroupName = "capacity.sigs.k8s.io"
)
21 changes: 21 additions & 0 deletions pkg/apis/capacity/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
Copyright 2020 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// +k8s:deepcopy-gen=package
// +groupName=capacity.sigs.k8s.io

// Package v1alpha1 is the v1alpha1 version of the API.
package v1alpha1
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"

"sigs.k8s.io/scheduler-plugins/pkg/apis/podgroup"
"sigs.k8s.io/scheduler-plugins/pkg/apis/capacity"
)

// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: podgroup.GroupName, Version: "v1alpha1"}
var SchemeGroupVersion = schema.GroupVersion{Group: capacity.GroupName, Version: "v1alpha1"}

// Kind takes an unqualified kind and returns back a Group qualified GroupKind
func Kind(kind string) schema.GroupKind {
Expand All @@ -47,8 +47,8 @@ var (
// Adds the list of known types to Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&PodGroup{},
&PodGroupList{},
&ElasticQuota{},
&ElasticQuotaList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
Expand Down
76 changes: 76 additions & 0 deletions pkg/apis/capacity/v1alpha1/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
Copyright 2020 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +genclient
// +genclient:noStatus
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ElasticQuota sets elastic quota restrictions per namespace
type ElasticQuota struct {
metav1.TypeMeta `json:",inline"`

// Standard object's metadata.
// +optional
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`

// ElasticQuotaSpec defines the Min and Max for Quota.
// +optional
Spec ElasticQuotaSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`

// ElasticQuotaStatus defines the observed use.
// +optional
Status ElasticQuotaStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
}

// ElasticQuotaSpec defines the Min and Max for Quota.
type ElasticQuotaSpec struct {
// Min is the set of desired guaranteed limits for each named resource.
// +optional
Min v1.ResourceList `json:"min,omitempty" protobuf:"bytes,1,rep,name=min, casttype=ResourceList,castkey=ResourceName"`

// Max is the set of desired max limits for each named resource. The usage of max is based on the resource configurations of
// successfully scheduled pods.
// +optional
Max v1.ResourceList `json:"max,omitempty" protobuf:"bytes,2,rep,name=max, casttype=ResourceList,castkey=ResourceName"`
}

// ElasticQuotaStatus defines the observed use.
type ElasticQuotaStatus struct {
// Used is the current observed total usage of the resource in the namespace.
// +optional
Used v1.ResourceList `json:"used,omitempty" protobuf:"bytes,1,rep,name=used,casttype=ResourceList,castkey=ResourceName"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ElasticQuotaList is a list of ElasticQuota items.
type ElasticQuotaList struct {
metav1.TypeMeta `json:",inline"`

// Standard list metadata.
// +optional
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`

// Items is a list of ElasticQuota objects.
Items []ElasticQuota `json:"items" protobuf:"bytes,2,rep,name=items"`
}

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

1 change: 1 addition & 0 deletions pkg/apis/config/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&CoschedulingArgs{},
&NodeResourcesAllocatableArgs{},
&CapacitySchedulingArgs{},
)
return nil
}
Expand Down
Loading

0 comments on commit 09a84c7

Please sign in to comment.