Skip to content

Commit 9ab33e7

Browse files
author
kakzhou719
committed
add more plugin description
1 parent fcbe61f commit 9ab33e7

File tree

4 files changed

+155
-20
lines changed

4 files changed

+155
-20
lines changed

.github/workflows/.mlc_config.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"ignorePatterns": [
3+
{
4+
"pattern": "^http://127.0.0.1"
5+
},
6+
{
7+
"pattern": "^http://localhost"
8+
}
9+
]
10+
}

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
_output
8+
# Test binary, built with `go test -c`
9+
*.test
10+
11+
# Output of the go coverage tool, specifically when used with LiteIDE
12+
*.out
13+
.idea
14+
seautil/seautil
15+
sealer/sealer
16+
*.swp

README.md

Lines changed: 104 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# plugins
22

3+
## What is plugin
4+
5+
Sealer provide plugin mechanism that allows users to run sealer image according to different plugin configurations.
6+
7+
This will bring the possibility of flexible configuration of any image default setting, any cluster node, any cluster
8+
startup stage, such as host disk initialization, cluster preflight ,status checker before or after cluster installation
9+
and so on.
10+
11+
At present, sealer only support the `shell` type plugins. it provides a shell operation entry that means user could
12+
execute any shell scripts on any node at any cluster launch stage. user only need to do is writing a yaml file which
13+
defined shell data and its scope to experience sealer plugin feature.
14+
315
## Plugin Spec
416

517
PluginSpec defines the desired state of Plugin
@@ -13,27 +25,99 @@ type PluginSpec struct {
1325
}
1426
```
1527

16-
1. for `PluginSpec.Type`: plugin type,currently only supported "SHELL".
17-
2. for `PluginSpec.Data`: plugin`s real data, sealer will use it to do actual action.
18-
3. for `PluginSpec.Scope`: plugin`s scope, it is usually the role name, support use '|' to specify multiple scopes.
19-
4. for `PluginSpec.Action`: phase of this plugin will run. below is the phase list we currently supported.
28+
* for `PluginSpec.Type`: plugin type,currently only supported "SHELL".
29+
* for `PluginSpec.Data`: plugin`s real data, sealer will use it to do actual action.
30+
* for `PluginSpec.Scope`: plugin scope, it is usually the role name, support use '|' to specify multiple scopes.
31+
* for `PluginSpec.Action`: phase of this plugin will run. if action is `host type`,will execute on `PluginSpec.Scope`
32+
specified, if it is `cluster type`, only execute plugin at master0. below is the phase list we currently supported.
2033

2134
plugin will be executed by `PluginSpec.Name` in alphabetical order at the same stage.
2235

23-
The following is a detailed introduction for plugin action.
24-
25-
| action name | action scope | explanation |
26-
| :-----| ----: | :----: |
27-
| pre-init-host | cluster host | will run before init cluster host |
28-
| post-init-host | cluster host | will run after init cluster host |
29-
| pre-clean-host | cluster host | will run before clean cluster host |
30-
| post-clean-host | cluster host | will run after clean cluster host |
31-
| pre-install | master0 | will run before install cluster |
32-
| post-install | master0 | will run after install cluster |
33-
| pre-uninstall | master0 | will run before uninstall cluster |
34-
| post-uninstall | master0 | will run after uninstall cluster |
35-
| pre-scaleup | master0 | will run before scaleup cluster |
36-
| post-scaleup | master0 | will run after scaleup cluster |
37-
| upgrade-host | cluster host | will run before upgrade cluster |
38-
| upgrade | master0 | will run for upgrading cluster |
36+
The following is a detailed introduction for plugin action.it is divided into 2 categories, one is the `host type`
37+
plugin and the other is the `cluster type` plugin.
38+
39+
| action name | action scope | category| explanation |
40+
| :-----| ----: | ----: |----: |
41+
| pre-init-host | all host |host type | will run before init cluster host |
42+
| post-init-host | all host | host type| will run after init cluster host |
43+
| pre-clean-host | all host | host type| will run before clean cluster host |
44+
| post-clean-host | all host | host type| will run after clean cluster host |
45+
| pre-install | master0 | cluster type| will run before install cluster |
46+
| post-install | master0 |cluster type | will run after install cluster |
47+
| pre-uninstall | master0 |cluster type | will run before uninstall cluster |
48+
| post-uninstall | master0 | cluster type| will run after uninstall cluster |
49+
| pre-scaleup | master0 | cluster type| will run before scaleup cluster |
50+
| post-scaleup | master0 | cluster type| will run after scaleup cluster |
51+
| upgrade-host | all host | host type| will run before upgrade cluster |
52+
| upgrade | master0 | cluster type| will run for upgrading cluster |
53+
54+
## How to use
55+
56+
### use plugin though Kubefile
57+
58+
Define the default plugin in Kubefile to build the image and run it.
59+
60+
In many cases it is possible to use plugins without using Clusterfile, essentially sealer stores the Clusterfile plugin
61+
configuration in the Rootfs/Plugins directory before using it, so we can define the default plugin when we build the
62+
image.
63+
64+
For example, build a new sealer image with plugins/example/example.yaml, only need to do is coping your plugin file
65+
to `plugins/` directory.
66+
67+
Kubefile:
68+
69+
```shell script
70+
FROM docker.io/sealerio/kubernetes:v1-22-15-sealerio-2
71+
COPY example.yaml plugins/
72+
```
73+
74+
Build a Sealer Image that contains a plugin (or more plugins):
75+
76+
```shell script
77+
sealer build -t kubernetes-with-plugin:v1 .
78+
```
79+
80+
Run the image and the plugin will also be executed without having to define the plugin in the Clusterfile:
81+
`sealer run kubernetes-with-plugin:v1 -m x.x.x.x -p xxx`
82+
83+
### use plugin though Clusterfile
84+
85+
For example, set plugins/example/example.yaml content at clusterfile:
86+
87+
```yaml
88+
apiVersion: sealer.io/v2
89+
kind: Cluster
90+
metadata:
91+
name: default-kubernetes-cluster
92+
spec:
93+
image: docker.io/sealerio/kubernetes:v1.22.15
94+
ssh:
95+
passwd: xxx
96+
hosts:
97+
- ips: [ 192.168.0.2,192.168.0.3,192.168.0.4 ]
98+
roles: [ master ]
99+
- ips: [ 192.168.0.5 ]
100+
roles: [ node ]
101+
---
102+
apiVersion: sealer.io/v2
103+
kind: Plugin
104+
metadata:
105+
name: pre_init_host
106+
spec:
107+
type: SHELL
108+
action: pre-init-host
109+
scope: master
110+
data: |
111+
set -e;set -x
112+
echo "i am pre init host plugin"
113+
```
114+
115+
```shell script
116+
sealer apply -f Clusterfile
117+
```
118+
119+
## Available plugin list
39120

121+
| name | owner | category| link | description |
122+
| :-----| ----: | ----: |----: |----: |
123+
| example | sealer community | host type | plugins/example/example.yaml| just a little plugin example for user to quickly experience |

plugins/example/example.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright © 2021 Alibaba Group Holding Ltd.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
apiVersion: sealer.io/v2
16+
kind: Plugin
17+
metadata:
18+
name: pre_init_host # Specify this plugin name,will dump in $rootfs/plugin dir.
19+
spec:
20+
type: SHELL
21+
action: pre-init-host
22+
scope: master
23+
data: |
24+
set -e;set -x
25+
echo "i am pre init host plugin"

0 commit comments

Comments
 (0)