Merge pull request #1182 from erikwilson/docker-pause-image

Allow --pause-image to set docker sandbox image also
This commit is contained in:
Erik Wilson 2019-12-11 10:36:07 -07:00 committed by GitHub
commit d4959d53af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 9 deletions

View File

@ -452,11 +452,14 @@ func get(envInfo *cmds.Agent) (*config.Node, error) {
nodeConfig.AgentConfig.CNIBinDir = filepath.Dir(hostLocal) nodeConfig.AgentConfig.CNIBinDir = filepath.Dir(hostLocal)
nodeConfig.AgentConfig.CNIConfDir = filepath.Join(envInfo.DataDir, "etc/cni/net.d") nodeConfig.AgentConfig.CNIConfDir = filepath.Join(envInfo.DataDir, "etc/cni/net.d")
} }
if !nodeConfig.Docker && nodeConfig.ContainerRuntimeEndpoint == "" { if !nodeConfig.Docker && nodeConfig.ContainerRuntimeEndpoint == "" {
nodeConfig.AgentConfig.RuntimeSocket = "unix://" + nodeConfig.Containerd.Address nodeConfig.AgentConfig.RuntimeSocket = nodeConfig.Containerd.Address
} else { } else {
nodeConfig.AgentConfig.RuntimeSocket = "unix://" + nodeConfig.ContainerRuntimeEndpoint nodeConfig.AgentConfig.RuntimeSocket = nodeConfig.ContainerRuntimeEndpoint
nodeConfig.AgentConfig.CNIPlugin = true
} }
if controlConfig.ClusterIPRange != nil { if controlConfig.ClusterIPRange != nil {
nodeConfig.AgentConfig.ClusterCIDR = *controlConfig.ClusterIPRange nodeConfig.AgentConfig.ClusterCIDR = *controlConfig.ClusterIPRange
} }

View File

@ -47,10 +47,7 @@ func run(ctx context.Context, cfg cmds.Agent, lb *loadbalancer.LoadBalancer) err
} }
} }
if nodeConfig.Docker || nodeConfig.ContainerRuntimeEndpoint != "" { if !nodeConfig.Docker && nodeConfig.ContainerRuntimeEndpoint == "" {
nodeConfig.AgentConfig.RuntimeSocket = nodeConfig.ContainerRuntimeEndpoint
nodeConfig.AgentConfig.CNIPlugin = true
} else {
if err := containerd.Run(ctx, nodeConfig); err != nil { if err := containerd.Run(ctx, nodeConfig); err != nil {
return err return err
} }

View File

@ -29,8 +29,6 @@ const ContainerdConfigTemplate = `
{{- if .NodeConfig.AgentConfig.PauseImage }} {{- if .NodeConfig.AgentConfig.PauseImage }}
sandbox_image = "{{ .NodeConfig.AgentConfig.PauseImage }}" sandbox_image = "{{ .NodeConfig.AgentConfig.PauseImage }}"
{{else}}
sandbox_image = "docker.io/rancher/pause:3.1"
{{end}} {{end}}
{{- if not .NodeConfig.NoFlannel }} {{- if not .NodeConfig.NoFlannel }}

View File

@ -82,8 +82,9 @@ var (
} }
PauseImageFlag = cli.StringFlag{ PauseImageFlag = cli.StringFlag{
Name: "pause-image", 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, Destination: &AgentConfig.PauseImage,
Value: "docker.io/rancher/pause:3.1",
} }
FlannelFlag = cli.BoolFlag{ FlannelFlag = cli.BoolFlag{
Name: "no-flannel", Name: "no-flannel",

View File

@ -94,6 +94,8 @@ func startKubelet(cfg *config.Agent) {
argsMap["container-runtime"] = "remote" argsMap["container-runtime"] = "remote"
argsMap["container-runtime-endpoint"] = cfg.RuntimeSocket argsMap["container-runtime-endpoint"] = cfg.RuntimeSocket
argsMap["serialize-image-pulls"] = "false" argsMap["serialize-image-pulls"] = "false"
} else if cfg.PauseImage != "" {
argsMap["pod-infra-container-image"] = cfg.PauseImage
} }
if cfg.ListenAddress != "" { if cfg.ListenAddress != "" {
argsMap["address"] = cfg.ListenAddress argsMap["address"] = cfg.ListenAddress