|
| 1 | +## Tutorial |
| 2 | + |
| 3 | +This is the basic tutorial describing the basic flow you can follow to build your scheduler plugins made of wasm. |
| 4 | + |
| 5 | +### Build your wasm binary via SDK |
| 6 | + |
| 7 | +[Go SDK](../guest/) is the only language SDK that we support for now. |
| 8 | + |
| 9 | +Like [Scheduling Framework](https://kubernetes.io/docs/concepts/scheduling-eviction/scheduling-framework/), |
| 10 | +the Go SDK provides [the interfaces](../guest/api/types.go) so that you can develop your own scheduling |
| 11 | +via a similar experience to Go scheduler plugin. |
| 12 | + |
| 13 | +Some of them look different from [the interfaces in Scheduling Framework](https://github.com/kubernetes/kubernetes/blob/master/pkg/scheduler/framework/interface.go) though, |
| 14 | +it's the same how they're called by the scheduler. |
| 15 | + |
| 16 | +You can learn how you can implement your wasm plugins by referring to [./examples](./examples/). |
| 17 | + |
| 18 | +Currently, Go SDK uses TinyGo for its compile, you can refer to [Makefile](../Makefile) to see how we build example implementations. |
| 19 | +Each example takes a different approach to build them, as README in them describes. |
| 20 | + |
| 21 | +### Integrate your wasm binary into your scheduler |
| 22 | + |
| 23 | +We have [a scheduler plugin](../scheduler/) which loads and runs wasm plugins. |
| 24 | +For now, you have to build [the scheduler with the plugin](../scheduler/cmd/scheduler/main.go) by yourself though, |
| 25 | +we'll provide an official docker image after our first release. |
| 26 | + |
| 27 | +You have to enable the scheduler plugin with your wasm binary in `KubeSchedulerConfiguration`, as following. |
| 28 | + |
| 29 | +```yaml |
| 30 | +apiVersion: kubescheduler.config.k8s.io/v1 |
| 31 | +kind: KubeSchedulerConfiguration |
| 32 | +profiles: |
| 33 | + - plugins: |
| 34 | + multipoint: |
| 35 | + enabled: |
| 36 | + - name: wasmplugin1 |
| 37 | + - name: wasmplugin2 |
| 38 | + pluginConfig: |
| 39 | + - name: wasmplugin1 |
| 40 | + args: |
| 41 | + guestPath: "/path/to/wasm-plugin1" |
| 42 | + - name: wasmplugin2 |
| 43 | + args: |
| 44 | + guestPath: "/path/to/wasm-plugin2" |
| 45 | +``` |
| 46 | +
|
| 47 | +- A wasm plugin **must** be enabled via `multiPoint` even if your wasm plugin only uses some of extension points. |
| 48 | +- All plugins with the plugin config matching [the wasm config format](../scheduler/plugin/config.go) are considered to be wasm plugins. |
0 commit comments