Skip to content

Commit

Permalink
It's a customized scheduler try to resolve parallel tasks depends on …
Browse files Browse the repository at this point in the history
…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
vincent-pli committed Oct 30, 2020
1 parent f9f49d9 commit 3c53bab
Show file tree
Hide file tree
Showing 23 changed files with 3,252 additions and 0 deletions.
7 changes: 7 additions & 0 deletions scheduler/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM debian:stretch-slim

WORKDIR /

COPY bin/kube-scheduler /usr/local/bin

CMD ["kube-scheduler"]
45 changes: 45 additions & 0 deletions scheduler/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# 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.

COMMONENVVAR=GOOS=$(shell uname -s | tr A-Z a-z) GOARCH=$(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m)))
BUILDENVVAR=CGO_ENABLED=0
# If tag not explicitly set in users default to the git sha.
TAG ?= v0.0.1

.PHONY: all
all: build

.PHONY: build
build: autogen
$(COMMONENVVAR) $(BUILDENVVAR) go build -ldflags '-w' -o bin/kube-scheduler cmd/main.go

.PHONY: update-vendor
update-vendor:
hack/update-vendor.sh

.PHONY: unit-test
unit-test: update-vendor
hack/unit-test.sh

.PHONY: autogen
autogen: update-vendor
hack/update-generated-openapi.sh

.PHONY: verify-gofmt
verify-gofmt:
hack/verify-gofmt.sh

.PHONY: image
image: build
docker build . -t vincentpli/scheduler-framework-sample:$(TAG)
24 changes: 24 additions & 0 deletions scheduler/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# coscheduler-same-node
The repo is for trying to implements such a scheduler:
https://github.com/tektoncd/pipeline/issues/3052

# Installation
```
make image
docker push
```

# Take a try
`kubectl create -f manifests/sample/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.
40 changes: 40 additions & 0 deletions scheduler/cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
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 main

import (
"math/rand"
"os"
"time"

"k8s.io/kubernetes/cmd/kube-scheduler/app"

"sigs.k8s.io/scheduler-plugins/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)
}
}
36 changes: 36 additions & 0 deletions scheduler/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module sigs.k8s.io/scheduler-plugins

go 1.13

require (
k8s.io/api v0.18.0
k8s.io/apimachinery v0.18.0
k8s.io/apiserver v0.18.0
k8s.io/client-go v0.18.0
k8s.io/klog v1.0.0
k8s.io/kubernetes v1.18.0
)

replace (
k8s.io/api => k8s.io/api v0.18.0
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.18.0
k8s.io/apimachinery => k8s.io/apimachinery v0.18.0
k8s.io/apiserver => k8s.io/apiserver v0.18.0
k8s.io/cli-runtime => k8s.io/cli-runtime v0.18.0
k8s.io/client-go => k8s.io/client-go v0.18.0
k8s.io/cloud-provider => k8s.io/cloud-provider v0.18.0
k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.18.0
k8s.io/code-generator => k8s.io/code-generator v0.18.0
k8s.io/component-base => k8s.io/component-base v0.18.0
k8s.io/cri-api => k8s.io/cri-api v0.18.0
k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.18.0
k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.18.0
k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.18.0
k8s.io/kube-proxy => k8s.io/kube-proxy v0.18.0
k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.18.0
k8s.io/kubectl => k8s.io/kubectl v0.18.0
k8s.io/kubelet => k8s.io/kubelet v0.18.0
k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.18.0
k8s.io/metrics => k8s.io/metrics v0.18.0
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.18.0
)
Loading

0 comments on commit 3c53bab

Please sign in to comment.