forked from tektoncd/experimental
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It's a customized scheduler try to resolve parallel tasks depends on …
…same volume but maybe run on different nodes. This is a draft version, try to introduce `Scheduler framework` to handle the issue, for now we adopt `affinity assistant` but has issue to measure total resource requirements. Details please check issue: tektoncd/pipeline#3052 I think we will enhance it soon based on further discussion, thanks.
- Loading branch information
1 parent
f9f49d9
commit 51dfe52
Showing
14 changed files
with
2,141 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
defaultBaseImage: gcr.io/distroless/static:nonroot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# The OWNERS file is used by prow to automatically merge approved PRs. | ||
# See https://github.com/kubernetes/test-infra/tree/master/prow/plugins/approve/approvers. | ||
# It supports a list of approvers and reviewers and their github names must be provided. | ||
|
||
approvers: | ||
- ImJasonH | ||
- jlpettersson | ||
- vincent-pli |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# coscheduler-same-node | ||
The repo is for trying to implements such a scheduler: | ||
https://github.com/tektoncd/pipeline/issues/3052 | ||
|
||
# Installation | ||
``` | ||
ko apply -f config/ | ||
``` | ||
|
||
# Take a try | ||
`kubectl create -f examples/pods.yaml` | ||
|
||
# Description | ||
The `scheduler` is based on [Scheduler plugin framework](https://github.com/kubernetes/enhancements/blob/master/keps/sig-scheduling/20180409-scheduling-framework.md) | ||
|
||
Use special labels of `pod` to mark the group of pods. | ||
``` | ||
labels: | ||
pod-group.scheduling.sigs.k8s.io/name: test | ||
pod-group.scheduling.sigs.k8s.io/total: "2" | ||
``` | ||
|
||
The `pod`s in same `pod-group` will be scheduler to same node if the node can satisfy the resource requirement of whole group, or all pods in the group will `pending`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
Copyright 2020 The Tekton 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 main | ||
|
||
import ( | ||
"math/rand" | ||
"os" | ||
"time" | ||
|
||
"k8s.io/kubernetes/cmd/kube-scheduler/app" | ||
|
||
"github.com/tektoncd/experimental/scheduler/pkg/coscheduler" | ||
) | ||
|
||
func main() { | ||
rand.Seed(time.Now().UnixNano()) | ||
// Register custom plugins to the scheduler framework. | ||
// Later they can consist of scheduler profile(s) and hence | ||
// used by various kinds of workloads. | ||
command := app.NewSchedulerCommand( | ||
app.WithPlugin(coscheduler.CoschedulerName, coscheduler.NewCoscheduler), | ||
) | ||
if err := command.Execute(); err != nil { | ||
os.Exit(1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: sample-sa | ||
namespace: kube-system |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
kind: ClusterRole | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: sample-cr | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- endpoints | ||
- events | ||
verbs: | ||
- create | ||
- get | ||
- update | ||
- apiGroups: | ||
- "" | ||
resourceNames: | ||
- scheduler-framework-sample | ||
resources: | ||
- endpoints | ||
verbs: | ||
- delete | ||
- get | ||
- patch | ||
- update | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- nodes | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- pods | ||
verbs: | ||
- delete | ||
- get | ||
- list | ||
- watch | ||
- update | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- bindings | ||
- pods/binding | ||
verbs: | ||
- create | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- pods/status | ||
verbs: | ||
- patch | ||
- update | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- replicationcontrollers | ||
- services | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- apps | ||
- extensions | ||
resources: | ||
- replicasets | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- apps | ||
resources: | ||
- statefulsets | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- policy | ||
resources: | ||
- poddisruptionbudgets | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- persistentvolumeclaims | ||
- persistentvolumes | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- configmaps | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- "storage.k8s.io" | ||
resources: | ||
- storageclasses | ||
- csinodes | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- "coordination.k8s.io" | ||
resources: | ||
- leases | ||
verbs: | ||
- create | ||
- get | ||
- list | ||
- update | ||
- apiGroups: | ||
- "events.k8s.io" | ||
resources: | ||
- events | ||
verbs: | ||
- create | ||
- patch | ||
- update | ||
- apiGroups: | ||
- batch.klsf.ibm.com | ||
resources: | ||
- lsfjobs | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- list | ||
- patch | ||
- update | ||
- watch | ||
- apiGroups: | ||
- batch.klsf.ibm.com | ||
resources: | ||
- lsfjobs/status | ||
verbs: | ||
- get | ||
- patch | ||
- update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
kind: ClusterRoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: sample-crb | ||
namespace: kube-system | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: sample-cr | ||
subjects: | ||
- kind: ServiceAccount | ||
name: sample-sa | ||
namespace: kube-system |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: scheduler-config | ||
namespace: kube-system | ||
data: | ||
scheduler-config.yaml: | | ||
apiVersion: kubescheduler.config.k8s.io/v1alpha1 | ||
kind: KubeSchedulerConfiguration | ||
schedulerName: scheduler-framework-sample | ||
leaderElection: | ||
leaderElect: true | ||
lockObjectName: scheduler-framework-sample | ||
lockObjectNamespace: kube-system | ||
plugins: | ||
queueSort: | ||
enabled: | ||
- name: CoschedulerSamenode | ||
disabled: | ||
- name: "*" | ||
preFilter: | ||
enabled: | ||
- name: CoschedulerSamenode | ||
filter: | ||
enabled: | ||
- name: CoschedulerSamenode | ||
postBind: | ||
enabled: | ||
- name: CoschedulerSamenode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: scheduler-framework-sample | ||
namespace: kube-system | ||
labels: | ||
component: scheduler-framework-sample | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
component: scheduler-framework-sample | ||
template: | ||
metadata: | ||
labels: | ||
component: scheduler-framework-sample | ||
spec: | ||
serviceAccount: sample-sa | ||
priorityClassName: system-cluster-critical | ||
volumes: | ||
- name: scheduler-config | ||
configMap: | ||
name: scheduler-config | ||
containers: | ||
- name: scheduler-ctrl | ||
image: ko://github.com/tektoncd/experimental/scheduler/cmd | ||
imagePullPolicy: Always | ||
args: | ||
- kube-scheduler | ||
- --config=/scheduler/scheduler-config.yaml | ||
- --v=3 | ||
resources: | ||
requests: | ||
cpu: "50m" | ||
volumeMounts: | ||
- name: scheduler-config | ||
mountPath: /scheduler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: static-web | ||
labels: | ||
pod-group.scheduling.sigs.k8s.io/name: test | ||
pod-group.scheduling.sigs.k8s.io/total: "2" | ||
spec: | ||
schedulerName: scheduler-framework-sample | ||
containers: | ||
- name: web | ||
image: nginx | ||
resources: | ||
requests: | ||
cpu: "4000m" | ||
limits: | ||
cpu: "4000m" | ||
ports: | ||
- name: web | ||
containerPort: 80 | ||
protocol: TCP | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: static-web-1 | ||
labels: | ||
pod-group.scheduling.sigs.k8s.io/name: test | ||
pod-group.scheduling.sigs.k8s.io/total: "2" | ||
spec: | ||
schedulerName: scheduler-framework-sample | ||
containers: | ||
- name: web | ||
image: nginx | ||
resources: | ||
requests: | ||
cpu: "4000m" | ||
limits: | ||
cpu: "4000m" | ||
ports: | ||
- name: web | ||
containerPort: 80 | ||
protocol: TCP |
Oops, something went wrong.