Skip to content

Commit

Permalink
coscheduling based on crd
Browse files Browse the repository at this point in the history
  • Loading branch information
cwdsuzhou committed Sep 16, 2020
1 parent 3bcd296 commit f6aa1d9
Show file tree
Hide file tree
Showing 22 changed files with 2,977 additions and 1,061 deletions.
2 changes: 1 addition & 1 deletion hack/integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ runTests() {
kube::log::status "Running integration test cases"

# TODO: make args customizable.
go test -mod=vendor sigs.k8s.io/scheduler-plugins/test/integration/...
go test -count=1 -mod=vendor sigs.k8s.io/scheduler-plugins/test/integration/...

cleanup
}
Expand Down
4 changes: 2 additions & 2 deletions kep/42-podgroup-coscheduling/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ type PodGroupStatus struct {
// Current phase of PodGroup.
Phase PodGroupPhase `json:"phase"`

// OccupiedBy marks the workload (e.g., deployment, statefulset) UID that occupy the podgroup.
// It is empty if not initialized.
// OccupiedBy marks the workload (e.g., deployment, statefulset) UID that occupy the podgroup.
//It is empty if not initialized.
OccupiedBy string `json:"occupiedBy,omitempty"`

// The number of actively running pods.
Expand Down
15 changes: 15 additions & 0 deletions manifests/coscheduling/crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: podgroups.scheduling.sigs.k8s.io
spec:
group: scheduling.sigs.k8s.io
names:
kind: PodGroup
plural: podgroups
singular: podgroup
shortNames:
- pg
- pgs
scope: Namespaced
version: v1
4 changes: 2 additions & 2 deletions manifests/coscheduling/scheduler-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ profiles:
permit:
enabled:
- name: Coscheduling
reserve:
postbind:
enabled:
- name: Coscheduling
# optional plugin configs
pluginConfig:
pluginConfig:
- name: Coscheduling
args:
permitWaitingTimeSeconds: 10
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,8 @@ type CoschedulingArgs struct {
// If the deleted PodGroup stays longer than the PodGroupExpirationTime,
// the PodGroup will be deleted from PodGroupInfos.
PodGroupExpirationTimeSeconds *int64
// KubeMaster is the url of api-server
KubeMaster string
// KubeConfig for scheduler
KubeConfig string
}
4 changes: 4 additions & 0 deletions pkg/apis/config/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@ type CoschedulingArgs struct {
// If the deleted PodGroup stays longer than the PodGroupExpirationTime,
// the PodGroup will be deleted from PodGroupInfos.
PodGroupExpirationTimeSeconds *int64 `json:"podGroupExpirationTimeSeconds,omitempty"`
// KubeMaster is the url of api-server
KubeMaster string `json:"kubeMaster,omitempty"`
// KubeConfig for scheduler
KubeConfig string `json:"kubeConfig,omitempty"`
}
9 changes: 8 additions & 1 deletion 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.

32 changes: 23 additions & 9 deletions pkg/coscheduling/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Overview

This folder holds the coscheduling plugin implementations based on [Lightweight coscheduling based on back-to-back queue
sorting](https://github.com/kubernetes-sigs/scheduler-plugins/tree/master/kep/2-lightweight-coscheduling).
This folder holds the coscheduling plugin implementations based on [Coscheduling based on PodGroup CRD](https://github.com/kubernetes-sigs/scheduler-plugins/tree/master/kep/42-podgroup-coscheduling).

## Maturity Level

Expand All @@ -14,11 +13,19 @@ sorting](https://github.com/kubernetes-sigs/scheduler-plugins/tree/master/kep/2-

## Tutorial
### PodGroup
We use a special label named pod-group.scheduling.sigs.k8s.io/name to define a PodGroup. Pods that set this label and use the same value belong to the same PodGroup.
We use a special label named podgroup.scheduling.sigs.k8s.io to define a PodGroup. Pods that set this label and use the same value belong to the same PodGroup.

```
apiVersion: scheduling.sigs.k8s.io/v1alpha1
kind: PodGroup
metadata:
name: nginx
spec:
maxScheduleTime: 10s
minMember: 3
---
labels:
pod-group.scheduling.sigs.k8s.io/name: nginx
pod-group.scheduling.sigs.k8s.io/min-available: "2"
podgroups.scheduling.sigs.k8s.io: nginx
```
We will calculate the sum of the Running pods and the Waiting pods (assumed but not bind) in scheduler, if the sum is greater than or equal to the minAvailable, the Waiting pods
will be created.
Expand Down Expand Up @@ -53,14 +60,22 @@ profiles:
permit:
enabled:
- name: Coscheduling
reserve:
postbind:
enabled:
- name: Coscheduling
```

### Demo
Suppose we have a cluster which can only afford 3 nginx pods. We create a ReplicaSet with replicas=6, and set the value of minAvailable to 3.
```yaml
apiVersion: scheduling.sigs.k8s.io/v1alpha1
kind: PodGroup
metadata:
name: nginx
spec:
maxScheduleTime: 10s
minMember: 3
---
apiVersion: apps/v1
kind: ReplicaSet
metadata:
Expand All @@ -77,8 +92,7 @@ spec:
name: nginx
labels:
app: nginx
pod-group.scheduling.sigs.k8s.io/name: nginx
pod-group.scheduling.sigs.k8s.io/min-available: "3"
podgroup.scheduling.sigs.k8s.io: nginx
spec:
containers:
- name: nginx
Expand Down Expand Up @@ -113,4 +127,4 @@ nginx-gnjsv 0/1 Pending 0 3s
nginx-hqhhz 0/1 Pending 0 3s
nginx-n47r7 0/1 Pending 0 3s
nginx-n7vtq 0/1 Pending 0 3s
```
```
Loading

0 comments on commit f6aa1d9

Please sign in to comment.