Skip to content

Commit 99181ae

Browse files
committed
SPEC: #928 support non-inlined plugin loading
Signed-off-by: Benjamin Leggett <[email protected]>
1 parent 0137b32 commit 99181ae

File tree

1 file changed

+100
-16
lines changed

1 file changed

+100
-16
lines changed

Diff for: SPEC.md

+100-16
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,15 @@ A network configuration consists of a JSON object with the following keys:
109109

110110
- `cniVersion` (string): [Semantic Version 2.0](https://semver.org) of CNI specification to which this configuration list and all the individual configurations conform. Currently "1.1.0"
111111
- `cniVersions` (string list): List of all CNI versions which this configuration supports. See [version selection](#version-selection) below.
112-
- `name` (string): Network name. This should be unique across all network configurations on a host (or other administrative domain). Must start with an alphanumeric character, optionally followed by any combination of one or more alphanumeric characters, underscore, dot (.) or hyphen (-).
112+
- `name` (string): Network name. This should be unique across all network configurations on a host (or other administrative domain). Must start with an alphanumeric character, optionally followed by any combination of one or more alphanumeric characters, underscore, dot (.) or hyphen (-). Must not contain characters disallowed in file paths.
113113
- `disableCheck` (boolean): Either `true` or `false`. If `disableCheck` is `true`, runtimes must not call `CHECK` for this network configuration list. This allows an administrator to prevent `CHECK`ing where a combination of plugins is known to return spurious errors.
114-
- `plugins` (list): A list of CNI plugins and their configuration, which is a list of plugin configuration objects.
114+
- `loadOnlyInlinedPlugins` (boolean): Either `true` or `false`. If `false` (default), indicates [plugin configuration objects](#plugin-configuration-objects) should be loaded from a sibling directory with the same name as the network `name` field. These sibling directories should exist at the same path as the network configuration itself. Any valid plugin configuration objects within a named sibling directory will be appended to the final list of `plugins` for that network name. If set to `true`, plugin configuration objects in sibling directories will be ignored. If `plugins` is not present in the network configuration, `loadOnlyInlinedPlugins` cannot be set to `true`.
115+
- `plugins` (list): A list of inlined [plugin configuration objects](#plugin-configuration-objects). If this key is populated with inlined plugin objects, and `loadOnlyInlinedPlugins` is true, the final set of plugins for a network must consist of all the plugin objects in this list, merged with all the plugins loaded from the sibling folder with the same name as the network.
115116

116117
#### Plugin configuration objects:
117-
Plugin configuration objects may contain additional fields than the ones defined here.
118-
The runtime MUST pass through these fields, unchanged, to the plugin, as defined in section 3.
118+
Runtimes may aggregate plugin configuration objects from multiple sources, and must unambiguously associate each loaded plugin configuration object with a single, valid network configuration. All aggregated plugin configuration objects must be parsed, and each plugin with a parsable configuration object must be invoked.
119+
120+
Plugin configuration objects may contain additional fields beyond the ones defined here. The runtime MUST pass through these fields, unchanged, to the invoked plugin, as defined in section 3.
119121

120122
**Required keys:**
121123
- `type` (string): Matches the name of the CNI plugin binary on disk. Must not contain characters disallowed in file paths for the system (e.g. / or \\).
@@ -146,18 +148,68 @@ Plugins that consume any of these configuration keys should respect their intend
146148
Plugins may define additional fields that they accept and may generate an error if called with unknown fields. Runtimes must preserve unknown fields in plugin configuration objects when transforming for execution.
147149

148150
#### Example configuration
151+
Network configuration with no inlined plugin confs, and two loaded plugin confs:
152+
`/etc/cni/net.d/10-dbnet.conf`:
149153
```jsonc
150154
{
151155
"cniVersion": "1.1.0",
152156
"cniVersions": ["0.3.1", "0.4.0", "1.0.0", "1.1.0"],
153157
"name": "dbnet",
154-
"plugins": [
158+
"loadOnlyInlinedPlugins": false,
159+
}
160+
```
161+
162+
`/etc/cni/net.d/dbnet/5-bridge.conf`:
163+
```jsonc
164+
{
165+
"type": "bridge",
166+
// plugin specific parameters
167+
"bridge": "cni0",
168+
"keyA": ["some more", "plugin specific", "configuration"],
169+
170+
"ipam": {
171+
"type": "host-local",
172+
// ipam specific
173+
"subnet": "10.1.0.0/16",
174+
"gateway": "10.1.0.1",
175+
"routes": [
176+
{"dst": "0.0.0.0/0"}
177+
]
178+
},
179+
"dns": {
180+
"nameservers": [ "10.1.0.1" ]
181+
}
182+
}
183+
```
184+
185+
`/etc/cni/net.d/dbnet/10-tuning.conf`:
186+
```jsonc
187+
{
188+
"type": "tuning",
189+
"capabilities": {
190+
"mac": true
191+
},
192+
"sysctl": {
193+
"net.core.somaxconn": "500"
194+
}
195+
}
196+
```
197+
198+
Network configuration with one inlined plugin conf, and one loaded plugin conf:
199+
`/etc/cni/net.d/10-dbnet.conf`:
200+
```jsonc
201+
{
202+
"cniVersion": "1.1.0",
203+
"cniVersions": ["0.3.1", "0.4.0", "1.0.0", "1.1.0"],
204+
"name": "dbnet",
205+
"loadOnlyInlinedPlugins": false,
206+
plugins: [
155207
{
156208
"type": "bridge",
157209
// plugin specific parameters
158210
"bridge": "cni0",
159211
"keyA": ["some more", "plugin specific", "configuration"],
160-
212+
161213
"ipam": {
162214
"type": "host-local",
163215
// ipam specific
@@ -170,19 +222,51 @@ Plugins may define additional fields that they accept and may generate an error
170222
"dns": {
171223
"nameservers": [ "10.1.0.1" ]
172224
}
173-
},
225+
}
226+
]
227+
}
228+
```
229+
230+
`/etc/cni/net.d/dbnet/10-tuning.conf`:
231+
```jsonc
232+
{
233+
"type": "tuning",
234+
"capabilities": {
235+
"mac": true
236+
},
237+
"sysctl": {
238+
"net.core.somaxconn": "500"
239+
}
240+
}
241+
```
242+
243+
Network configuration with one inlined plugin conf, and no loaded plugin conf:
244+
`/etc/cni/net.d/10-dbnet.conf`:
245+
```jsonc
246+
{
247+
"cniVersion": "1.1.0",
248+
"cniVersions": ["0.3.1", "0.4.0", "1.0.0", "1.1.0"],
249+
"name": "dbnet",
250+
"loadOnlyInlinedPlugins": true,
251+
"plugins": [
174252
{
175-
"type": "tuning",
176-
"capabilities": {
177-
"mac": true
253+
"type": "bridge",
254+
// plugin specific parameters
255+
"bridge": "cni0",
256+
"keyA": ["some more", "plugin specific", "configuration"],
257+
258+
"ipam": {
259+
"type": "host-local",
260+
// ipam specific
261+
"subnet": "10.1.0.0/16",
262+
"gateway": "10.1.0.1",
263+
"routes": [
264+
{"dst": "0.0.0.0/0"}
265+
]
178266
},
179-
"sysctl": {
180-
"net.core.somaxconn": "500"
267+
"dns": {
268+
"nameservers": [ "10.1.0.1" ]
181269
}
182-
},
183-
{
184-
"type": "portmap",
185-
"capabilities": {"portMappings": true}
186270
}
187271
]
188272
}

0 commit comments

Comments
 (0)