Make sandbox container image configurable

Signed-off-by: Jamie Zhuang <lanchongyizu@gmail.com>
This commit is contained in:
Jamie Zhuang 2017-09-03 02:53:17 -04:00
parent 86e8a24977
commit 915f5b0aea
4 changed files with 8 additions and 4 deletions

View File

@ -54,6 +54,7 @@ func main() {
o.StreamServerAddress, o.StreamServerAddress,
o.StreamServerPort, o.StreamServerPort,
o.CgroupPath, o.CgroupPath,
o.SandboxImage,
) )
if err != nil { if err != nil {
glog.Exitf("Failed to create CRI containerd service %+v: %v", o, err) glog.Exitf("Failed to create CRI containerd service %+v: %v", o, err)

View File

@ -48,6 +48,8 @@ type CRIContainerdOptions struct {
CgroupPath string CgroupPath string
// EnableSelinux indicates to enable the selinux support // EnableSelinux indicates to enable the selinux support
EnableSelinux bool EnableSelinux bool
// SandboxImage is the image used by sandbox container.
SandboxImage string
} }
// NewCRIContainerdOptions returns a reference to CRIContainerdOptions // NewCRIContainerdOptions returns a reference to CRIContainerdOptions
@ -78,6 +80,8 @@ func (c *CRIContainerdOptions) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&c.CgroupPath, "cgroup-path", "", "The cgroup that cri-containerd is part of. By default cri-containerd is not placed in a cgroup") fs.StringVar(&c.CgroupPath, "cgroup-path", "", "The cgroup that cri-containerd is part of. By default cri-containerd is not placed in a cgroup")
fs.BoolVar(&c.EnableSelinux, "selinux-enabled", fs.BoolVar(&c.EnableSelinux, "selinux-enabled",
false, "Enable selinux support.") false, "Enable selinux support.")
fs.StringVar(&c.SandboxImage, "sandbox-image",
"gcr.io/google_containers/pause:3.0", "The image used by sandbox container.")
} }
// InitFlags must be called after adding all cli options flags are defined and // InitFlags must be called after adding all cli options flags are defined and

View File

@ -57,8 +57,6 @@ const (
) )
const ( const (
// defaultSandboxImage is the image used by sandbox container.
defaultSandboxImage = "gcr.io/google_containers/pause:3.0"
// defaultSandboxOOMAdj is default omm adj for sandbox container. (kubernetes#47938). // defaultSandboxOOMAdj is default omm adj for sandbox container. (kubernetes#47938).
defaultSandboxOOMAdj = -998 defaultSandboxOOMAdj = -998
// defaultSandboxCPUshares is default cpu shares for sandbox container. // defaultSandboxCPUshares is default cpu shares for sandbox container.

View File

@ -111,7 +111,8 @@ func NewCRIContainerdService(
networkPluginConfDir, networkPluginConfDir,
streamAddress, streamAddress,
streamPort string, streamPort string,
cgroupPath string) (CRIContainerdService, error) { cgroupPath string,
sandboxImage string) (CRIContainerdService, error) {
// TODO(random-liu): [P2] Recover from runtime state and checkpoint. // TODO(random-liu): [P2] Recover from runtime state and checkpoint.
client, err := containerd.New(containerdEndpoint, containerd.WithDefaultNamespace(k8sContainerdNamespace)) client, err := containerd.New(containerdEndpoint, containerd.WithDefaultNamespace(k8sContainerdNamespace))
@ -129,7 +130,7 @@ func NewCRIContainerdService(
serverAddress: serverAddress, serverAddress: serverAddress,
os: osinterface.RealOS{}, os: osinterface.RealOS{},
rootDir: rootDir, rootDir: rootDir,
sandboxImage: defaultSandboxImage, sandboxImage: sandboxImage,
snapshotter: containerdSnapshotter, snapshotter: containerdSnapshotter,
sandboxStore: sandboxstore.NewStore(), sandboxStore: sandboxstore.NewStore(),
containerStore: containerstore.NewStore(), containerStore: containerstore.NewStore(),