From e3f87891142a38aa4e6194c76741f17f30911ee8 Mon Sep 17 00:00:00 2001 From: Jason Date: Sat, 18 Jul 2020 07:16:23 +0800 Subject: [PATCH] Add containerd snapshotter flag (#1991) * Add containerd snapshotter flag Signed-off-by: Jason-ZW * Fix CamelCase nit and option description Signed-off-by: Brad Davidson Signed-off-by: Jason-ZW Co-authored-by: Brad Davidson --- pkg/agent/config/config.go | 1 + pkg/agent/templates/templates.go | 5 +++++ pkg/cli/cmds/agent.go | 8 ++++++++ pkg/cli/cmds/server.go | 1 + pkg/daemons/config/types.go | 1 + 5 files changed, 16 insertions(+) diff --git a/pkg/agent/config/config.go b/pkg/agent/config/config.go index 93a943f2f5..3c953b584e 100644 --- a/pkg/agent/config/config.go +++ b/pkg/agent/config/config.go @@ -423,6 +423,7 @@ func get(envInfo *cmds.Agent, proxy proxy.Proxy) (*config.Node, error) { nodeConfig.AgentConfig.RootDir = filepath.Join(envInfo.DataDir, "kubelet") } nodeConfig.AgentConfig.PauseImage = envInfo.PauseImage + nodeConfig.AgentConfig.Snapshotter = envInfo.Snapshotter nodeConfig.AgentConfig.IPSECPSK = controlConfig.IPSECPSK nodeConfig.AgentConfig.StrongSwanDir = filepath.Join(envInfo.DataDir, "strongswan") nodeConfig.CACerts = info.CACerts diff --git a/pkg/agent/templates/templates.go b/pkg/agent/templates/templates.go index 4fedfa6911..cd3c0a2c3a 100644 --- a/pkg/agent/templates/templates.go +++ b/pkg/agent/templates/templates.go @@ -33,6 +33,11 @@ const ContainerdConfigTemplate = ` sandbox_image = "{{ .NodeConfig.AgentConfig.PauseImage }}" {{end}} +{{- if .NodeConfig.AgentConfig.Snapshotter }} +[plugins.cri.containerd] + snapshotter = "{{ .NodeConfig.AgentConfig.Snapshotter }}" +{{end}} + {{- if not .NodeConfig.NoFlannel }} [plugins.cri.cni] bin_dir = "{{ .NodeConfig.AgentConfig.CNIBinDir }}" diff --git a/pkg/cli/cmds/agent.go b/pkg/cli/cmds/agent.go index 2ffcfaf860..f53b991cc1 100644 --- a/pkg/cli/cmds/agent.go +++ b/pkg/cli/cmds/agent.go @@ -21,6 +21,7 @@ type Agent struct { NodeExternalIP string NodeName string PauseImage string + Snapshotter string Docker bool ContainerRuntimeEndpoint string NoFlannel bool @@ -90,6 +91,12 @@ var ( Destination: &AgentConfig.PauseImage, Value: "docker.io/rancher/pause:3.1", } + SnapshotterFlag = cli.StringFlag{ + Name: "snapshotter", + Usage: "(agent/runtime) Override default containerd snapshotter", + Destination: &AgentConfig.Snapshotter, + Value: "overlayfs", + } FlannelFlag = cli.BoolFlag{ Name: "no-flannel", Usage: "(deprecated) use --flannel-backend=none", @@ -190,6 +197,7 @@ func NewAgentCommand(action func(ctx *cli.Context) error) *cli.Command { &DisableSELinuxFlag, &CRIEndpointFlag, &PauseImageFlag, + &SnapshotterFlag, &PrivateRegistryFlag, &NodeIPFlag, &NodeExternalIPFlag, diff --git a/pkg/cli/cmds/server.go b/pkg/cli/cmds/server.go index bae6bc4889..97a8fcb803 100644 --- a/pkg/cli/cmds/server.go +++ b/pkg/cli/cmds/server.go @@ -238,6 +238,7 @@ func NewServerCommand(action func(*cli.Context) error) *cli.Command { &DisableSELinuxFlag, &CRIEndpointFlag, &PauseImageFlag, + &SnapshotterFlag, &PrivateRegistryFlag, &NodeIPFlag, &NodeExternalIPFlag, diff --git a/pkg/daemons/config/types.go b/pkg/daemons/config/types.go index bfa7700f78..ff259265ba 100644 --- a/pkg/daemons/config/types.go +++ b/pkg/daemons/config/types.go @@ -72,6 +72,7 @@ type Agent struct { ExtraKubeletArgs []string ExtraKubeProxyArgs []string PauseImage string + Snapshotter string CNIPlugin bool NodeTaints []string NodeLabels []string