From 2de93d70cf02ccf4016ad15c6813e48f74dd0f4c Mon Sep 17 00:00:00 2001 From: Erik Wilson Date: Tue, 10 Dec 2019 16:16:26 -0700 Subject: [PATCH] Allow --pause-image to set docker sandbox image also --- pkg/agent/config/config.go | 7 +++++-- pkg/agent/run.go | 5 +---- pkg/agent/templates/templates.go | 2 -- pkg/cli/cmds/agent.go | 3 ++- pkg/daemons/agent/agent.go | 2 ++ 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/pkg/agent/config/config.go b/pkg/agent/config/config.go index c9669d37f2..2ab0299328 100644 --- a/pkg/agent/config/config.go +++ b/pkg/agent/config/config.go @@ -452,11 +452,14 @@ func get(envInfo *cmds.Agent) (*config.Node, error) { nodeConfig.AgentConfig.CNIBinDir = filepath.Dir(hostLocal) nodeConfig.AgentConfig.CNIConfDir = filepath.Join(envInfo.DataDir, "etc/cni/net.d") } + if !nodeConfig.Docker && nodeConfig.ContainerRuntimeEndpoint == "" { - nodeConfig.AgentConfig.RuntimeSocket = "unix://" + nodeConfig.Containerd.Address + nodeConfig.AgentConfig.RuntimeSocket = nodeConfig.Containerd.Address } else { - nodeConfig.AgentConfig.RuntimeSocket = "unix://" + nodeConfig.ContainerRuntimeEndpoint + nodeConfig.AgentConfig.RuntimeSocket = nodeConfig.ContainerRuntimeEndpoint + nodeConfig.AgentConfig.CNIPlugin = true } + if controlConfig.ClusterIPRange != nil { nodeConfig.AgentConfig.ClusterCIDR = *controlConfig.ClusterIPRange } diff --git a/pkg/agent/run.go b/pkg/agent/run.go index b1206cd926..461f98b0af 100644 --- a/pkg/agent/run.go +++ b/pkg/agent/run.go @@ -45,10 +45,7 @@ func run(ctx context.Context, cfg cmds.Agent, lb *loadbalancer.LoadBalancer) err } } - if nodeConfig.Docker || nodeConfig.ContainerRuntimeEndpoint != "" { - nodeConfig.AgentConfig.RuntimeSocket = nodeConfig.ContainerRuntimeEndpoint - nodeConfig.AgentConfig.CNIPlugin = true - } else { + if !nodeConfig.Docker && nodeConfig.ContainerRuntimeEndpoint == "" { if err := containerd.Run(ctx, nodeConfig); err != nil { return err } diff --git a/pkg/agent/templates/templates.go b/pkg/agent/templates/templates.go index 37e53d8351..866be18ff2 100644 --- a/pkg/agent/templates/templates.go +++ b/pkg/agent/templates/templates.go @@ -29,8 +29,6 @@ const ContainerdConfigTemplate = ` {{- if .NodeConfig.AgentConfig.PauseImage }} sandbox_image = "{{ .NodeConfig.AgentConfig.PauseImage }}" -{{else}} - sandbox_image = "docker.io/rancher/pause:3.1" {{end}} {{- if not .NodeConfig.NoFlannel }} diff --git a/pkg/cli/cmds/agent.go b/pkg/cli/cmds/agent.go index 0644a1a962..604d81ddb2 100644 --- a/pkg/cli/cmds/agent.go +++ b/pkg/cli/cmds/agent.go @@ -82,8 +82,9 @@ var ( } PauseImageFlag = cli.StringFlag{ Name: "pause-image", - Usage: "(agent/runtime) Customized pause image for containerd sandbox", + Usage: "(agent/runtime) Customized pause image for containerd or docker sandbox", Destination: &AgentConfig.PauseImage, + Value: "docker.io/rancher/pause:3.1", } FlannelFlag = cli.BoolFlag{ Name: "no-flannel", diff --git a/pkg/daemons/agent/agent.go b/pkg/daemons/agent/agent.go index 165616ed21..72b8d23a68 100644 --- a/pkg/daemons/agent/agent.go +++ b/pkg/daemons/agent/agent.go @@ -94,6 +94,8 @@ func startKubelet(cfg *config.Agent) { argsMap["container-runtime"] = "remote" argsMap["container-runtime-endpoint"] = cfg.RuntimeSocket argsMap["serialize-image-pulls"] = "false" + } else if cfg.PauseImage != "" { + argsMap["pod-infra-container-image"] = cfg.PauseImage } if cfg.ListenAddress != "" { argsMap["address"] = cfg.ListenAddress