You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/features/pouch_with_plugin.md
+25-13Lines changed: 25 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,12 @@
1
1
# Pouch with plugin
2
2
3
-
In order to run custom code provided by users which will be triggered at some point, we support a plugin framework which introduced from golang 1.8. At this time in this plugin framework we enable users to add custom code at four point:
3
+
In order to run custom code provided by users which will be triggered at some point, we support a plugin framework which introduced from golang 1.8. At this time in this plugin framework we enable users to add custom code at file points:
4
4
5
5
* pre-start daemon point
6
6
* pre-stop daemon point
7
7
* pre-create container point
8
8
* pre-start container point
9
+
* pre-create-endapoint container point
9
10
10
11
Above four points are organized by two Plugin interfaces, which are DaemonPlugin and ContainerPlugin, defined as follow:
11
12
@@ -21,15 +22,20 @@ type DaemonPlugin interface {
21
22
PreStopHook() error
22
23
}
23
24
24
-
// ContainerPlugin defines in which place a plugin will be triggered in container lifecycle
25
+
// ContainerPlugin defines places where a plugin will be triggered in container lifecycle
25
26
type ContainerPlugin interface {
26
-
// PreCreate defines plugin point where receives an container create request, in this plugin point user
27
-
// could change the container create body passed-in by http request body
28
-
PreCreate(io.ReadCloser) (io.ReadCloser, error)
29
-
30
-
// PreStart returns an array of priority and args which will pass to runc, the every priority
31
-
// used to sort the pre start array that pass to runc, network plugin hook always has priority value 0.
32
-
PreStart(interface{}) ([]int, [][]string, error)
27
+
// PreCreate defines plugin point where receives an container create request, in this plugin point user
28
+
// could change the container create body passed-in by http request body
29
+
PreCreate(io.ReadCloser) (io.ReadCloser, error)
30
+
31
+
// PreStart returns an array of priority and args which will pass to runc, the every priority
32
+
// used to sort the pre start array that pass to runc, network plugin hook always has priority value 0.
33
+
PreStart(interface{}) ([]int, [][]string, error)
34
+
35
+
//NetworkGenericParams accepts the container id and env of this container and returns the priority of this endpoint
36
+
// and if this endpoint should enable resolver and a map which will be used as generic params to create endpoints of
@@ -130,7 +141,8 @@ and if you use the exact code above, every time you start a container the file a
130
141
131
142
## usage
132
143
133
-
at pre-start daemon point you can start assist processes like network plugins and dfget proxy which need by pouchd and whose life cycle is the same as pouchd.
134
-
at pre-stop daemon point you can stop the assist processes gracefully, but the trigger of this point is not a promise, because pouchd may be killed by SIGKILL.
135
-
at pre-create container point you can change the input stream by some rules, in some company they have some stale orchestration system who use env to pass-in some limit which is an attribute in pouch, then you can use this point to convert value in env to attribute in ContainerConfig or HostConfig of pouch create api.
136
-
at pre-start container point you can set more pre-start hooks to oci spec, where you can do some special thing before container entrypoint start, priority decide the order of executing of the hook. libnetwork hook has priority 0, so if the hook is expected to run before network in container setup you should set priority to a value big then 0, and vice versa.
144
+
* at pre-start daemon point you can start assist processes like network plugins and dfget proxy which need by pouchd and whose life cycle is the same as pouchd.
145
+
* at pre-stop daemon point you can stop the assist processes gracefully, but the trigger of this point is not a promise, because pouchd may be killed by SIGKILL.
146
+
* at pre-create container point you can change the input stream by some rules, in some company they have some stale orchestration system who use env to pass-in some limit which is an attribute in pouch, then you can use this point to convert value in env to attribute in ContainerConfig or HostConfig of pouch create api.
147
+
* at pre-start container point you can set more pre-start hooks to oci spec, where you can do some special thing before container entrypoint start, priority decide the order of executing of the hook. libnetwork hook has priority 0, so if the hook is expected to run before network in container setup you should set priority to a value big then 0, and vice versa.
148
+
* at pre-create-endpoint container point you can return the priority of this endpoint and if this endpoint need enable resolver and the generic params of this endpoint.
0 commit comments