Skip to content

Commit

Permalink
Merge pull request kosmos-io#103 from qiuming520/main
Browse files Browse the repository at this point in the history
add kosmos-scheduler for kube-scheduler v1.26
  • Loading branch information
kosmos-robot authored Oct 18, 2023
2 parents 452cf66 + 43a7c82 commit 4c69a94
Show file tree
Hide file tree
Showing 21 changed files with 1,202 additions and 39 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ TARGETS := clusterlink-controller-manager \
clusterlink-network-manager \
clusterlink-proxy \
clustertree-knode-manager \
scheduler \

CTL_TARGETS := kosmosctl

Expand Down Expand Up @@ -106,6 +107,7 @@ upload-images: images
docker push ${REGISTRY}/clusterlink-floater:${VERSION}
docker push ${REGISTRY}/clusterlink-elector:${VERSION}
docker push ${REGISTRY}/clustertree-knode-manager:${VERSION}
docker push ${REGISTRY}/scheduler:${VERSION}

.PHONY: release
release:
Expand Down
4 changes: 3 additions & 1 deletion cmd/scheduler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import (
"k8s.io/component-base/cli"
"k8s.io/kubernetes/cmd/kube-scheduler/app"

_ "github.com/kosmos.io/kosmos/pkg/apis/config/scheme"
"github.com/kosmos.io/kosmos/pkg/scheduler/lifted/plugins/knodetainttoleration"
"github.com/kosmos.io/kosmos/pkg/scheduler/lifted/plugins/knodevolumebinding"
)

func main() {
Expand All @@ -15,8 +17,8 @@ func main() {
// used by various kinds of workloads.
command := app.NewSchedulerCommand(
app.WithPlugin(knodetainttoleration.Name, knodetainttoleration.New),
app.WithPlugin(knodevolumebinding.Name, knodevolumebinding.New),
)

code := cli.Run(command)
os.Exit(code)
}
101 changes: 101 additions & 0 deletions deploy/scheduler/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: kosmos-scheduler
namespace: kosmos-system
labels:
component: scheduler
spec:
replicas: 1
selector:
matchLabels:
component: scheduler
template:
metadata:
labels:
component: scheduler
spec:
volumes:
- name: scheduler-config
configMap:
name: scheduler-config
defaultMode: 420
containers:
- name: kosmos-scheduler
image: ghcr.io/kosmos-io/scheduler:0.0.2
command:
- scheduler
- --leader-elect=true
- --leader-elect-resource-name=kosmos-scheduler
- --leader-elect-resource-namespace=kosmos-system
- --config=/etc/kubernetes/kube-scheduler/scheduler-config.yaml
resources:
requests:
cpu: 200m
volumeMounts:
- name: scheduler-config
readOnly: true
mountPath: /etc/kubernetes/kube-scheduler
livenessProbe:
httpGet:
path: /healthz
port: 10259
scheme: HTTPS
initialDelaySeconds: 15
periodSeconds: 10
failureThreshold: 3
readinessProbe:
httpGet:
path: /healthz
port: 10259
scheme: HTTPS
restartPolicy: Always
dnsPolicy: ClusterFirst
serviceAccountName: kosmos-scheduler
serviceAccount: kosmos-scheduler

---
apiVersion: v1
kind: ConfigMap
metadata:
name: scheduler-config
namespace: kosmos-system
data:
scheduler-config.yaml: |
apiVersion: kubescheduler.config.k8s.io/v1
kind: KubeSchedulerConfiguration
leaderElection:
leaderElect: true
profiles:
- schedulerName: kosmos-scheduler
plugins:
preFilter:
disabled:
- name: "VolumeBinding"
enabled:
- name: "KnodeVolumeBinding"
filter:
disabled:
- name: "VolumeBinding"
- name: "TaintToleration"
enabled:
- name: "KNodeTaintToleration"
- name: "KnodeVolumeBinding"
score:
disabled:
- name: "VolumeBinding"
reserve:
disabled:
- name: "VolumeBinding"
enabled:
- name: "KnodeVolumeBinding"
preBind:
disabled:
- name: "VolumeBinding"
enabled:
- name: "KnodeVolumeBinding"
pluginConfig:
- name: KnodeVolumeBinding
args:
bindTimeoutSeconds: 5
170 changes: 170 additions & 0 deletions deploy/scheduler/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: kosmos-scheduler
namespace: kosmos-system

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: kosmos-scheduler
subjects:
- kind: ServiceAccount
name: kosmos-scheduler
namespace: kosmos-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: kosmos-scheduler

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: kosmos-scheduler
rules:
- verbs:
- create
- patch
- update
apiGroups:
- ''
- events.k8s.io
resources:
- events
- verbs:
- create
apiGroups:
- coordination.k8s.io
resources:
- leases
- verbs:
- get
- update
apiGroups:
- coordination.k8s.io
resources:
- leases
resourceNames:
- kosmos-scheduler
- verbs:
- create
apiGroups:
- ''
resources:
- endpoints
- verbs:
- get
- update
apiGroups:
- ''
resources:
- endpoints
resourceNames:
- kube-scheduler
- verbs:
- get
- list
- watch
apiGroups:
- ''
resources:
- nodes
- verbs:
- delete
- get
- list
- watch
apiGroups:
- ''
resources:
- pods
- verbs:
- create
apiGroups:
- ''
resources:
- bindings
- pods/binding
- verbs:
- patch
- update
apiGroups:
- ''
resources:
- pods/status
- verbs:
- get
- list
- watch
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
- update
apiGroups:
- ''
resources:
- persistentvolumeclaims
- persistentvolumes
- verbs:
- create
apiGroups:
- authentication.k8s.io
resources:
- tokenreviews
- verbs:
- create
apiGroups:
- authorization.k8s.io
resources:
- subjectaccessreviews
- verbs:
- get
- list
- watch
apiGroups:
- storage.k8s.io
resources:
- '*'
- verbs:
- get
- list
- watch
apiGroups:
- ''
resources:
- configmaps
- namespaces
21 changes: 15 additions & 6 deletions hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,27 @@ create_gopath_tree "${REPO_ROOT}" "${link_path}"

deepcopy-gen \
--go-header-file hack/boilerplate/boilerplate.go.txt \
--input-dirs=github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1 \
--input-dirs="github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1,github.com/kosmos.io/kosmos/pkg/apis/config,github.com/kosmos.io/kosmos/pkg/apis/config/v1" \
--output-base="${REPO_ROOT}" \
--output-package=pkg/apis/kosmos/v1alpha1 \
--output-package="pkg/apis/kosmos/v1alpha1,pkg/apis/config,pkg/apis/config/v1" \
--output-file-base=zz_generated.deepcopy

echo "Generating with register-gen"
GO111MODULE=on go install k8s.io/code-generator/cmd/register-gen
register-gen \
--go-header-file hack/boilerplate/boilerplate.go.txt \
--input-dirs=github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1 \
--input-dirs="github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1" \
--output-base="${REPO_ROOT}" \
--output-package=pkg/apis/kosmos/v1alpha1 \
--output-package="pkg/apis/kosmos/v1alpha1" \
--output-file-base=zz_generated.register

echo "Generating with conversion-gen"
GO111MODULE=on go install k8s.io/code-generator/cmd/conversion-gen
conversion-gen \
--go-header-file hack/boilerplate/boilerplate.go.txt \
--input-dirs=github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1 \
--input-dirs="github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1,github.com/kosmos.io/kosmos/pkg/apis/config/v1" \
--output-base="${REPO_ROOT}" \
--output-package=github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1 \
--output-package="github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1,pkg/apis/config/v1" \
--output-file-base=zz_generated.conversion

echo "Generating with client-gen"
Expand All @@ -73,6 +73,15 @@ client-gen \
--output-package=github.com/kosmos.io/kosmos/pkg/generated/clientset \
--clientset-name=versioned

echo "Generating with defaults-gen"
GO111MODULE=on go install k8s.io/code-generator/cmd/defaulter-gen
defaulter-gen \
--go-header-file hack/boilerplate/boilerplate.go.txt \
--input-dirs="github.com/kosmos.io/kosmos/pkg/apis/config/v1" \
--output-base="${REPO_ROOT}" \
--output-package="pkg/apis/config/v1" \
--output-file-base=zz_generated.defaults

echo "Generating with lister-gen"
GO111MODULE=on go install k8s.io/code-generator/cmd/lister-gen
lister-gen \
Expand Down
1 change: 1 addition & 0 deletions hack/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ CLUSTERLINK_GO_PACKAGE="github.com/kosmos.io/kosmos"
MIN_Go_VERSION=go1.19.0

CLUSTERLINK_TARGET_SOURCE=(
scheduler=cmd/scheduler
clusterlink-proxy=cmd/clusterlink/proxy
clusterlink-operator=cmd/clusterlink/operator
clusterlink-elector=cmd/clusterlink/elector
Expand Down
20 changes: 20 additions & 0 deletions pkg/apis/config/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
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.
*/

// +k8s:deepcopy-gen=package
// +groupName=kubescheduler.config.k8s.io

package config // import "github.com/kosmos.io/kosmos/pkg/apis"
Loading

0 comments on commit 4c69a94

Please sign in to comment.