Browse code

Add configuration option for containerd cri

Disable cri plugin by default in containerd and
allows an option to enable the plugin. This only
has an effect on containerd when supervised by
dockerd. When containerd is managed outside of
dockerd, the configuration is not effected.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>

Derek McGowan authored on 2018/06/20 07:53:40
Showing 5 changed files
... ...
@@ -29,6 +29,7 @@ func installCommonConfigFlags(conf *config.Config, flags *pflag.FlagSet) {
29 29
 	flags.StringVarP(&conf.Root, "graph", "g", defaultDataRoot, "Root of the Docker runtime")
30 30
 	flags.StringVar(&conf.ExecRoot, "exec-root", defaultExecRoot, "Root directory for execution state files")
31 31
 	flags.StringVar(&conf.ContainerdAddr, "containerd", "", "containerd grpc address")
32
+	flags.BoolVar(&conf.CriContainerd, "cri-containerd", false, "start containerd with cri")
32 33
 
33 34
 	// "--graph" is "soft-deprecated" in favor of "data-root". This flag was added
34 35
 	// before Docker 1.0, so won't be removed, only hidden, to discourage its usage.
... ...
@@ -56,6 +56,9 @@ func (cli *DaemonCli) getPlatformRemoteOptions() ([]libcontainerd.RemoteOption,
56 56
 	} else {
57 57
 		opts = append(opts, libcontainerd.WithStartDaemon(true))
58 58
 	}
59
+	if !cli.Config.CriContainerd {
60
+		opts = append(opts, libcontainerd.WithPlugin("cri", nil))
61
+	}
59 62
 
60 63
 	return opts, nil
61 64
 }
... ...
@@ -198,6 +198,11 @@ type CommonConfig struct {
198 198
 	// ContainerAddr is the address used to connect to containerd if we're
199 199
 	// not starting it ourselves
200 200
 	ContainerdAddr string `json:"containerd,omitempty"`
201
+
202
+	// CriContainerd determines whether a supervised containerd instance
203
+	// should be configured with the CRI plugin enabled. This allows using
204
+	// Docker's containerd instance directly with a Kubernetes kubelet.
205
+	CriContainerd bool `json:"cri-containerd,omitempty"`
201 206
 }
202 207
 
203 208
 // IsValueSet returns true if a configuration value
... ...
@@ -31,6 +31,14 @@ func (r *remote) setDefaults() {
31 31
 	if r.OOMScore == 0 {
32 32
 		r.OOMScore = -999
33 33
 	}
34
+
35
+	for key, conf := range r.pluginConfs.Plugins {
36
+		if conf == nil {
37
+			r.DisabledPlugins = append(r.DisabledPlugins, key)
38
+			delete(r.pluginConfs.Plugins, key)
39
+		}
40
+	}
41
+
34 42
 	if r.snapshotter == "" {
35 43
 		r.snapshotter = "overlay"
36 44
 	}
... ...
@@ -119,6 +119,7 @@ func (s snapshotter) Apply(r Remote) error {
119 119
 // WithPlugin allow configuring a containerd plugin
120 120
 // configuration values passed needs to be quoted if quotes are needed in
121 121
 // the toml format.
122
+// Setting the config to nil will disable a built-in plugin
122 123
 func WithPlugin(name string, conf interface{}) RemoteOption {
123 124
 	return pluginConf{
124 125
 		name: name,