1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

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>
This commit is contained in:
Derek McGowan 2018-06-19 15:53:40 -07:00
parent cc7cda1968
commit 8fb5f4d5c9
No known key found for this signature in database
GPG key ID: F58C5D0A4405ACDB
5 changed files with 18 additions and 0 deletions

View file

@ -29,6 +29,7 @@ func installCommonConfigFlags(conf *config.Config, flags *pflag.FlagSet) {
flags.StringVarP(&conf.Root, "graph", "g", defaultDataRoot, "Root of the Docker runtime") flags.StringVarP(&conf.Root, "graph", "g", defaultDataRoot, "Root of the Docker runtime")
flags.StringVar(&conf.ExecRoot, "exec-root", defaultExecRoot, "Root directory for execution state files") flags.StringVar(&conf.ExecRoot, "exec-root", defaultExecRoot, "Root directory for execution state files")
flags.StringVar(&conf.ContainerdAddr, "containerd", "", "containerd grpc address") flags.StringVar(&conf.ContainerdAddr, "containerd", "", "containerd grpc address")
flags.BoolVar(&conf.CriContainerd, "cri-containerd", false, "start containerd with cri")
// "--graph" is "soft-deprecated" in favor of "data-root". This flag was added // "--graph" is "soft-deprecated" in favor of "data-root". This flag was added
// before Docker 1.0, so won't be removed, only hidden, to discourage its usage. // before Docker 1.0, so won't be removed, only hidden, to discourage its usage.

View file

@ -56,6 +56,9 @@ func (cli *DaemonCli) getPlatformRemoteOptions() ([]libcontainerd.RemoteOption,
} else { } else {
opts = append(opts, libcontainerd.WithStartDaemon(true)) opts = append(opts, libcontainerd.WithStartDaemon(true))
} }
if !cli.Config.CriContainerd {
opts = append(opts, libcontainerd.WithPlugin("cri", nil))
}
return opts, nil return opts, nil
} }

View file

@ -198,6 +198,11 @@ type CommonConfig struct {
// ContainerAddr is the address used to connect to containerd if we're // ContainerAddr is the address used to connect to containerd if we're
// not starting it ourselves // not starting it ourselves
ContainerdAddr string `json:"containerd,omitempty"` ContainerdAddr string `json:"containerd,omitempty"`
// CriContainerd determines whether a supervised containerd instance
// should be configured with the CRI plugin enabled. This allows using
// Docker's containerd instance directly with a Kubernetes kubelet.
CriContainerd bool `json:"cri-containerd,omitempty"`
} }
// IsValueSet returns true if a configuration value // IsValueSet returns true if a configuration value

View file

@ -31,6 +31,14 @@ func (r *remote) setDefaults() {
if r.OOMScore == 0 { if r.OOMScore == 0 {
r.OOMScore = -999 r.OOMScore = -999
} }
for key, conf := range r.pluginConfs.Plugins {
if conf == nil {
r.DisabledPlugins = append(r.DisabledPlugins, key)
delete(r.pluginConfs.Plugins, key)
}
}
if r.snapshotter == "" { if r.snapshotter == "" {
r.snapshotter = "overlay" r.snapshotter = "overlay"
} }

View file

@ -119,6 +119,7 @@ func (s snapshotter) Apply(r Remote) error {
// WithPlugin allow configuring a containerd plugin // WithPlugin allow configuring a containerd plugin
// configuration values passed needs to be quoted if quotes are needed in // configuration values passed needs to be quoted if quotes are needed in
// the toml format. // the toml format.
// Setting the config to nil will disable a built-in plugin
func WithPlugin(name string, conf interface{}) RemoteOption { func WithPlugin(name string, conf interface{}) RemoteOption {
return pluginConf{ return pluginConf{
name: name, name: name,