Skip to content

Commit b1df360

Browse files
authored
Merge pull request #100 from sanposhiho/doc
doc: add a simple tutorial to guide users
2 parents 30ca499 + 634aaa4 commit b1df360

File tree

3 files changed

+52
-11
lines changed

3 files changed

+52
-11
lines changed

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ scheduler, and loading custom scheduler plugin via configuration.
99

1010
This project contains everything needed to extend the scheduler:
1111
- Documentation describing what type of actions are possible, e.g. `Filter`.
12-
- Language SDKs used to build scheduler plugins, compiled to wasm.
13-
- The scheduler plugin which loads and runs wasm plugins
12+
- [Language SDKs](./guest/) used to build scheduler plugins, compiled to wasm.
13+
- [The scheduler plugin](./scheduler/) which loads and runs wasm plugins
1414

15-
## Example
16-
17-
You can learn how you build your wasm plugins by trying [./examples](./examples/).
15+
You can learn how you build your wasm plugins by referring to [the tutorial](./docs/tutorial.md).
1816

1917
## Motivation
2018

docs/tutorial.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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.

examples/README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
## Examples
22

33
These examples help you understand how you build your wasm plugins with our Go SDK (which is the only language SDK supported for now).
4+
Each example takes a different approach, refer to README in them for the details.
45

56
- [NodeNumber Plugin](./nodenumber/): The simple example plugin in which you can simply get how the wasm plugin looks like.
67
- [Adbanced NodeNumber Plugin](./advanced/): The example plugin one step advanced, which is more complicated than the first one, but more efficient and testable.
7-
8-
### Go SDK Interfaces
9-
10-
Like [Scheduling Framework](https://kubernetes.io/docs/concepts/scheduling-eviction/scheduling-framework/), the Go SDK provides [the interfaces](../guest/api/types.go).
11-
12-
Some of them look different from [the interfaces in Scheduling Framework](https://github.com/kubernetes/kubernetes/blob/master/pkg/scheduler/framework/interface.go) though, it's the same how they're called by the scheduler.

0 commit comments

Comments
 (0)