Develop out of tree plugin.
Motivations
Sealer support common plugins such as hostname plugin,label plugin,which is build in,user could define and use it
according their requests. Sealer also support to load out of tree plugin which is written by golang. This page is about
how to extend the new plugin type and how to develop an out of tree plugin.
Uses case
How to develop an out of tree plugin
if user doesn’t want their plugin code to be open sourced, we can develop an out of tree plugin to use it.
- implement the golang plugin interface and expose the variable named
Plugin
.
- package name must be “main”
- exposed variable must be “Plugin”
- exposed variable must be “PluginType”
Examples:list_nodes.go
1 | package main |
- build the new plugin as so file. plugin file and sealer source code must in the same golang runtime in order to avoid
compilation problems. we suggest the so file must build with the specific sealer version you used. otherwise,sealer
will fail to load the so file. you can replace the build file at the test directory
under Example to build your own so file.
1 | go build -buildmode=plugin -o list_nodes.so list_nodes.go |
- use the new so file
Copy the so file and plugin config file to your cloud image.We can also append plugin yaml to Clusterfile and
use sealer apply -f Clusterfile
to test it.
Kubefile:
1 | FROM kubernetes:v1.19.8 |
1 | sealer build -m lite -t kubernetes-post-install:v1.19.8 . |
list_nodes.yaml:
1 | apiVersion: sealer.aliyun.com/v1alpha1 |
apply it in your cluster: sealer run kubernetes-post-install:v1.19.8 -m x.x.x.x -p xxx