|
1 | 1 | ## Debuggable scheduler |
2 | 2 |
|
3 | | -The "debuggable scheduler" is the core concept of the simulator. |
4 | | - |
5 | | -### What's the "debuggable scheduler"? |
6 | | - |
7 | | -The debuggable scheduler is the scheduler that schedules Pods like other schedulers, |
8 | | -but it exposes the scheduling results from each scheduling plugin on Pod annotation. |
| 3 | +The "debuggable scheduler" is the core component of the simulator, |
| 4 | +which is responsible for scheduling Pods like the normal scheduler, but also recording all the scheduling details to the Pod annotations. |
9 | 5 |
|
10 | 6 | ```yaml |
11 | 7 | kind: Pod |
@@ -35,60 +31,45 @@ metadata: |
35 | 31 | scheduler-simulator/selected-node: node-282x7 |
36 | 32 | ``` |
37 | 33 |
|
38 | | -The simulator runs the debuggable scheduler built from the upstream scheduler by default, |
39 | | -that's why we can see the scheduling results like the above in the simulator. |
40 | | -
|
41 | | -## Build a debuggable scheduler from your scheduler |
42 | | -
|
43 | | -You can use the [`debuggablescheduler` package](../pkg/debuggablescheduler) to transform your scheduler into a debuggable scheduler. |
| 34 | +The simulator works with the debuggable scheduler built from the upstream scheduler by default, |
| 35 | +and the web UI just visualizes those scheduling details on the annotations. |
44 | 36 |
|
45 | | -The debuggable scheduler could work anywhere, in the simulator or even in your cluster. |
| 37 | +## Integrate your plugins to the simulator |
46 | 38 |
|
47 | | -### Change your scheduler |
48 | | - |
49 | | -Here, we assume you're registering your custom plugins in your scheduler like this: |
50 | | - |
51 | | -```go |
52 | | -// your scheduler's main package |
53 | | -func main() { |
54 | | - command := app.NewSchedulerCommand( |
55 | | - app.WithPlugin(yourcustomplugin.Name, yourcustomplugin.New), |
56 | | - ) |
57 | | -
|
58 | | - code := cli.Run(command) |
59 | | - os.Exit(code) |
60 | | -} |
61 | | -``` |
| 39 | +You can integrate your plugins to the simulator, that is, to the debuggable scheduler working within the simulator, by following these steps: |
62 | 40 |
|
63 | | -Then, you need to replace few lines to use the [`debuggablescheduler` package](../pkg/debuggablescheduler). |
| 41 | +1. Register your plugins [here](../cmd/scheduler/scheduler.go#L17) in a very similar way you do with the normal scheduler. |
64 | 42 |
|
65 | 43 | ```go |
66 | | -func main() { |
67 | | - command, cancelFn, err := debuggablescheduler.NewSchedulerCommand( |
| 44 | + command, cancelFn, err := debuggablescheduler.NewSchedulerCommand( |
68 | 45 | debuggablescheduler.WithPlugin(yourcustomplugin.Name, yourcustomplugin.New), |
69 | 46 | debuggablescheduler.WithPluginExtenders(noderesources.Name, extender.New), // [optional] see plugin-extender.md about PluginExtender. |
70 | 47 | ) |
71 | | - if err != nil { |
72 | | - klog.Info(fmt.Sprintf("failed to build the scheduler command: %+v", err)) |
73 | | - os.Exit(1) |
74 | | - } |
75 | | - code := cli.Run(command) |
76 | | - cancelFn() |
77 | | - os.Exit(code) |
78 | | -} |
79 | 48 | ``` |
80 | 49 |
|
81 | | -As you see, `debuggablescheduler.NewSchedulerCommand` has much similar interface as the `app.NewSchedulerCommand`. |
82 | | -You can register your plugins by `debuggablescheduler.WithPlugin` option. |
| 50 | +2. Rebuild the scheduler and restart. |
| 51 | + |
| 52 | +```sh |
| 53 | +make docker_build docker_up_local |
| 54 | +``` |
83 | 55 |
|
84 | 56 | ### The plugin extender |
85 | 57 |
|
86 | | -We have the plugin extender feature to expand the debuggable scheduler more. |
87 | | -See [plugin-extender.md](./plugin-extender.md) to know more about it. |
| 58 | +We have the plugin extender feature to provide more debuggability from the debuggable scheduler. |
| 59 | +See [plugin-extender.md](./plugin-extender.md). |
88 | 60 |
|
89 | | -### The example debuggable scheduler |
| 61 | +### Use the debuggable scheduler in your dev cluster |
| 62 | + |
| 63 | +The debuggable scheduler can work outside the simulator, that is, in your clusters too. |
| 64 | +which allows you to have the same debuggability with your custom scheduler in real clusters. |
90 | 65 |
|
91 | | -We have the sample implementation in [./sample/debuggable-scheduler](./sample/debuggable-scheduler). |
| 66 | +It's just a single binary that doesn't contain anything but the debuggability features that we described so far. |
| 67 | + |
| 68 | +> [!NOTE] |
| 69 | +> We do not recommend using it in the production cluster because the debuggable scheduler contains the overhead. |
| 70 | +> Also, you may want to pay attention to the fact that the annotations would be visible to all cluster users, |
| 71 | +> which could leak the hints of other tenants to cluster users. |
| 72 | +
|
| 73 | +### The example debuggable scheduler |
92 | 74 |
|
93 | | -You can try to run it in the simulator via [external scheduler](./external-scheduler.md) feature. |
94 | | -See [external-scheduler.md#the-example-external-scheduler](./external-scheduler.md#the-example-external-scheduler). |
| 75 | +We have the sample to show how to implement the debuggable scheduler in [./sample/debuggable-scheduler](./sample/debuggable-scheduler). |
0 commit comments