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

ElasticQuota of Capacity Scheduling Api define #50

Merged
merged 1 commit into from
Sep 29, 2020
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
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" \
Huang-Wei marked this conversation as resolved.
Show resolved Hide resolved
--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"`
}
41 changes: 38 additions & 3 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.

25 changes: 25 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
Huang-Wei marked this conversation as resolved.
Show resolved Hide resolved

// 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
Loading