Merge pull request #33488 from resouer/infra-image

Automatic merge from submit-queue

CRI: Enable custom infra container image

A minor fix to enable custom infra container image ref #29478 

- Need to address: 
Not sure how do deal with infra image credential, leave it as it is today. Should we allow user to specify credentials in pod yaml?
This commit is contained in:
Kubernetes Submit Queue 2016-10-04 11:11:29 -07:00 committed by GitHub
commit d26b4ca285
3 changed files with 11 additions and 4 deletions

View File

@ -45,9 +45,14 @@ const (
// Note: docker doesn't use LogDirectory (yet).
func (ds *dockerService) RunPodSandbox(config *runtimeApi.PodSandboxConfig) (string, error) {
// Step 1: Pull the image for the sandbox.
// TODO: How should we handle pulling custom pod infra container image
// (with credentials)?
image := defaultSandboxImage
podSandboxImage := ds.podSandboxImage
if len(podSandboxImage) != 0 {
image = podSandboxImage
}
// NOTE: To use a custom sandbox image in a private repository, users need to configure the nodes with credentials properly.
// see: http://kubernetes.io/docs/user-guide/images/#configuring-nodes-to-authenticate-to-a-private-repository
if err := ds.client.PullImage(image, dockertypes.AuthConfig{}, dockertypes.ImagePullOptions{}); err != nil {
return "", fmt.Errorf("unable to pull image for the sandbox container: %v", err)
}

View File

@ -54,10 +54,11 @@ const (
var internalLabelKeys []string = []string{containerTypeLabelKey, sandboxIDLabelKey}
// NOTE: Anything passed to DockerService should be eventually handled in another way when we switch to running the shim as a different process.
func NewDockerService(client dockertools.DockerInterface, seccompProfileRoot string) DockerLegacyService {
func NewDockerService(client dockertools.DockerInterface, seccompProfileRoot string, podSandboxImage string) DockerLegacyService {
return &dockerService{
seccompProfileRoot: seccompProfileRoot,
client: dockertools.NewInstrumentedDockerInterface(client),
podSandboxImage: podSandboxImage,
}
}
@ -80,6 +81,7 @@ type DockerLegacyService interface {
type dockerService struct {
seccompProfileRoot string
client dockertools.DockerInterface
podSandboxImage string
}
// Version returns the runtime name, runtime version and runtime API version

View File

@ -507,7 +507,7 @@ func NewMainKubelet(kubeCfg *componentconfig.KubeletConfiguration, kubeDeps *Kub
case "cri":
// Use the new CRI shim for docker. This is need for testing the
// docker integration through CRI, and may be removed in the future.
dockerService := dockershim.NewDockerService(klet.dockerClient, kubeCfg.SeccompProfileRoot)
dockerService := dockershim.NewDockerService(klet.dockerClient, kubeCfg.SeccompProfileRoot, kubeCfg.PodInfraContainerImage)
klet.containerRuntime, err = kuberuntime.NewKubeGenericRuntimeManager(
kubecontainer.FilterEventRecorder(kubeDeps.Recorder),
klet.livenessManager,