From 52f845ec844e0ae8f5f1a145bef0e553ac0d6840 Mon Sep 17 00:00:00 2001 From: "haokang.ke" Date: Sat, 4 May 2019 01:36:12 +0800 Subject: [PATCH] Make pause image configurable (#345) --- pkg/agent/config/config.go | 1 + pkg/agent/templates/templates.go | 13 +++++++++---- pkg/cli/cmds/agent.go | 9 ++++++++- pkg/cli/cmds/server.go | 1 + pkg/daemons/config/types.go | 1 + 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/pkg/agent/config/config.go b/pkg/agent/config/config.go index d6b330407c..936ffb3021 100644 --- a/pkg/agent/config/config.go +++ b/pkg/agent/config/config.go @@ -304,6 +304,7 @@ func get(envInfo *cmds.Agent) (*config.Node, error) { nodeConfig.AgentConfig.ListenAddress = "0.0.0.0" nodeConfig.AgentConfig.KubeConfig = kubeConfig nodeConfig.AgentConfig.RootDir = filepath.Join(envInfo.DataDir, "kubelet") + nodeConfig.AgentConfig.PauseImage = envInfo.PauseImage nodeConfig.CACerts = info.CACerts nodeConfig.Containerd.Config = filepath.Join(envInfo.DataDir, "etc/containerd/config.toml") nodeConfig.Containerd.Root = filepath.Join(envInfo.DataDir, "containerd") diff --git a/pkg/agent/templates/templates.go b/pkg/agent/templates/templates.go index 5094c1d5ee..7853c3f11f 100644 --- a/pkg/agent/templates/templates.go +++ b/pkg/agent/templates/templates.go @@ -19,17 +19,22 @@ path = "{{ .NodeConfig.Containerd.Opt }}" [plugins.cri] stream_server_address = "{{ .NodeConfig.AgentConfig.NodeName }}" stream_server_port = "10010" -{{ if .IsRunningInUserNS }} + +{{- if .IsRunningInUserNS }} disable_cgroup = true disable_apparmor = true restrict_oom_score_adj = true -{{ end }} +{{ end -}} -{{ if not .NodeConfig.NoFlannel }} +{{- if .NodeConfig.AgentConfig.PauseImage }} +sandbox_image = "{{ .NodeConfig.AgentConfig.PauseImage }}" +{{ end -}} + +{{- if not .NodeConfig.NoFlannel }} [plugins.cri.cni] bin_dir = "{{ .NodeConfig.AgentConfig.CNIBinDir }}" conf_dir = "{{ .NodeConfig.AgentConfig.CNIConfDir }}" -{{ end }} +{{ end -}} ` func ParseTemplateFromConfig(templateBuffer string, config interface{}) (string, error) { diff --git a/pkg/cli/cmds/agent.go b/pkg/cli/cmds/agent.go index cc8b439187..966b084073 100644 --- a/pkg/cli/cmds/agent.go +++ b/pkg/cli/cmds/agent.go @@ -16,6 +16,7 @@ type Agent struct { NodeIP string NodeName string ClusterSecret string + PauseImage string Docker bool ContainerRuntimeEndpoint string NoFlannel bool @@ -65,9 +66,14 @@ var ( Usage: "(agent) Disable embedded containerd and use alternative CRI implementation", Destination: &AgentConfig.ContainerRuntimeEndpoint, } + PauseImageFlag = cli.StringFlag{ + Name: "pause-image", + Usage: "(agent) Customized pause image for containerd sandbox", + Destination: &AgentConfig.PauseImage, + } ResolvConfFlag = cli.StringFlag{ Name: "resolv-conf", - Usage: "Kubelet resolv.conf file", + Usage: "(agent) Kubelet resolv.conf file", EnvVar: "K3S_RESOLV_CONF", Destination: &AgentConfig.ResolvConf, } @@ -131,6 +137,7 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command { NodeNameFlag, NodeIPFlag, CRIEndpointFlag, + PauseImageFlag, ResolvConfFlag, ExtraKubeletArgs, ExtraKubeProxyArgs, diff --git a/pkg/cli/cmds/server.go b/pkg/cli/cmds/server.go index 95a421ad79..27e62f0c20 100644 --- a/pkg/cli/cmds/server.go +++ b/pkg/cli/cmds/server.go @@ -143,6 +143,7 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command { FlannelFlag, FlannelIfaceFlag, CRIEndpointFlag, + PauseImageFlag, ResolvConfFlag, ExtraKubeletArgs, ExtraKubeProxyArgs, diff --git a/pkg/daemons/config/types.go b/pkg/daemons/config/types.go index e53bb2c10a..48829ad48e 100644 --- a/pkg/daemons/config/types.go +++ b/pkg/daemons/config/types.go @@ -53,6 +53,7 @@ type Agent struct { CNIConfDir string ExtraKubeletArgs []string ExtraKubeProxyArgs []string + PauseImage string CNIPlugin bool }