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 457a643
Show file tree
Hide file tree
Showing 44 changed files with 943 additions and 85 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"
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
11 changes: 10 additions & 1 deletion pkg/apis/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,20 @@ type NodeResourcesAllocatableArgs struct {

// Resources to be considered when scoring.
// Allowed weights start from 1.
// An example resource set might includes "cpu" (millicores) and "memory" (bytes)
// An example resource set might include "cpu" (millicores) and "memory" (bytes)
// with weights of 1<<20 and 1 respectfully. That would mean 1 MiB has equivalent
// weight as 1 millicore.
Resources []schedulerconfig.ResourceSpec `json:"resources,omitempty"`

// Whether to prioritize nodes with least or most allocatable resources.
Mode *ModeType `json:"mode,omitempty"`
}

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

type CapacitySchedulingArgs struct {
metav1.TypeMeta

// KubeConfigPath is the path of kubeconfig.
KubeConfigPath *string
}
8 changes: 8 additions & 0 deletions pkg/apis/config/v1beta1/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ var (
defaultNodeResourcesAllocatableResourcesToWeightMap = []schedulerconfig.ResourceSpec{
{Name: "cpu", Weight: 1 << 20}, {Name: "memory", Weight: 1},
}

defaultKubeConfigPath string = "/etc/kubernetes/scheduler.conf"
)

func SetDefaults_CoschedulingArgs(obj *CoschedulingArgs) {
Expand All @@ -58,3 +60,9 @@ func SetDefaults_NodeResourcesAllocatableArgs(obj *NodeResourcesAllocatableArgs)
obj.Mode = &defaultNodeResourcesAllocatableMode
}
}

func SetDefaults_CapacitySchedulingArgs(obj *CapacitySchedulingArgs) {
if obj.KubeConfigPath == nil {
obj.KubeConfigPath = &defaultKubeConfigPath
}
}
1 change: 1 addition & 0 deletions pkg/apis/config/v1beta1/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
12 changes: 11 additions & 1 deletion pkg/apis/config/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,21 @@ type NodeResourcesAllocatableArgs struct {

// Resources to be considered when scoring.
// Allowed weights start from 1.
// An example resource set might includes "cpu" (millicores) and "memory" (bytes)
// An example resource set might include "cpu" (millicores) and "memory" (bytes)
// with weights of 1<<20 and 1 respectfully. That would mean 1 MiB has equivalent
// weight as 1 millicore.
Resources []schedulerconfig.ResourceSpec `json:"resources,omitempty"`

// Whether to prioritize nodes with least or most allocatable resources.
Mode *ModeType `json:"mode,omitempty"`
}

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

// CapacitySchedulingArgs defines the scheduling parameters for CapacityScheduling plugin.
type CapacitySchedulingArgs struct {
metav1.TypeMeta `json:",inline"`

// KubeConfigPath is the path of kubeconfig.
KubeConfigPath *string `json:"kubeconfigpath,omitempty"`
}
30 changes: 30 additions & 0 deletions pkg/apis/config/v1beta1/zz_generated.conversion.go

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

30 changes: 30 additions & 0 deletions pkg/apis/config/v1beta1/zz_generated.deepcopy.go

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

5 changes: 5 additions & 0 deletions pkg/apis/config/v1beta1/zz_generated.defaults.go

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

30 changes: 30 additions & 0 deletions pkg/apis/config/zz_generated.deepcopy.go

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

33 changes: 0 additions & 33 deletions pkg/apis/podgroup/v1alpha1/zz_generated.defaults.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package podgroup
package scheduling

// GroupName is the group name used in this package
const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ limitations under the License.
// +groupName=scheduling.sigs.k8s.io

// Package v1alpha1 is the v1alpha1 version of the API.
package v1alpha1 // import "sigs.k8s.io/scheduler-plugins/pkg/apis/podgroup/v1alpha1"
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/scheduling"
)

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

// Kind takes an unqualified kind and returns back a Group qualified GroupKind
func Kind(kind string) schema.GroupKind {
Expand All @@ -47,6 +47,8 @@ var (
// Adds the list of known types to Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&ElasticQuota{},
&ElasticQuotaList{},
&PodGroup{},
&PodGroupList{},
)
Expand Down
Loading

0 comments on commit 457a643

Please sign in to comment.