This repo refers to the paper "Introducing k4.0s: a Model for Mixed-Criticality Container Orchestration in Industry 4.0" @ ADSN 2022
Hello world. This is a fork of https://github.com/sanposhiho/kube-scheduler-simulator-cli .
This repository is scenario system for kube-scheduler. You can write scenario and check the scheduler's behaviours.
And, also you can change the scheduler implementations on submodule/kubernetes. It helps changing implementations and debugging for scheeduler.
see scenario
function on sched.go.
func scenario(client clientset.Interface) error {
ctx := context.Background()
// create node0 ~ node9, but all nodes are unschedulable
for i := 0; i < 9; i++ {
suffix := strconv.Itoa(i)
_, err := client.CoreV1().Nodes().Create(ctx, &v1.Node{
ObjectMeta: metav1.ObjectMeta{
Name: "node" + suffix,
},
Spec: v1.NodeSpec{
Unschedulable: true,
},
}, metav1.CreateOptions{})
if err != nil {
return fmt.Errorf("create node: %w", err)
}
}
klog.Info("scenario: all nodes created")
_, err := client.CoreV1().Pods("default").Create(ctx, &v1.Pod{
ObjectMeta: metav1.ObjectMeta{Name: "pod1"},
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: "container1",
Image: "k8s.gcr.io/pause:3.5",
},
},
},
}, metav1.CreateOptions{})
if err != nil {
return fmt.Errorf("create pod: %w", err)
}
klog.Info("scenario: pod1 created")
// wait to schedule
time.Sleep(3 * time.Second)
pod1, err := client.CoreV1().Pods("default").Get(ctx, "pod1", metav1.GetOptions{})
if err != nil {
return fmt.Errorf("get pod: %w", err)
}
klog.Info("scenario: pod1 is bound to " + pod1.Spec.NodeName)
return nil
}
We have kubernetes/kubernetes repo as git submodule on submodules/kubernetes
On this simulator, we build the scheduler with the submodule. So you can change scheduler version or even you can change implementations by changing the scheduler implementations on submodule/kubernetes.
To run this scheduler and start scenario, you have to install Go and etcd. You can install etcd with submodules/kubernetes/kubernetes/kubernetes/hack/install-etcd.sh.
add k8s.io/kubernetes => ./
on replace directive. like this:
replace (
...
...
(the other replacements...)
..
.
k8s.io/kubernetes => ./
And, make start
starts the scheduler and your scenario.
This scheduler-playground starts scheduler, etcd, api-server and pv-controller.
The whole mechanism is based on kubernetes-sigs/kube-scheduler-simulator