mirror of
https://github.com/containers/podman.git
synced 2025-06-25 20:26:51 +08:00
fix play kube can't use infra_image in config file
Signed-off-by: Chen Zhiwei <zhiweik@gmail.com>
This commit is contained in:
@ -267,12 +267,9 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY
|
|||||||
}
|
}
|
||||||
|
|
||||||
if podOpt.Infra {
|
if podOpt.Infra {
|
||||||
imagePull := config.DefaultInfraImage
|
containerConfig := util.DefaultContainerConfig()
|
||||||
if podOpt.InfraImage != config.DefaultInfraImage && podOpt.InfraImage != "" {
|
|
||||||
imagePull = podOpt.InfraImage
|
|
||||||
}
|
|
||||||
|
|
||||||
pulledImages, err := pullImage(ic, writer, imagePull, options, config.PullPolicyNewer)
|
pulledImages, err := pullImage(ic, writer, containerConfig.Engine.InfraImage, options, config.PullPolicyNewer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"text/template"
|
"text/template"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/containers/common/pkg/config"
|
||||||
"github.com/containers/podman/v3/pkg/util"
|
"github.com/containers/podman/v3/pkg/util"
|
||||||
. "github.com/containers/podman/v3/test/utils"
|
. "github.com/containers/podman/v3/test/utils"
|
||||||
"github.com/containers/storage/pkg/stringid"
|
"github.com/containers/storage/pkg/stringid"
|
||||||
@ -30,6 +31,22 @@ metadata:
|
|||||||
spec:
|
spec:
|
||||||
hostname: unknown
|
hostname: unknown
|
||||||
`
|
`
|
||||||
|
var checkInfraImagePodYaml = `
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Pod
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: check-infra-image
|
||||||
|
name: check-infra-image
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: alpine
|
||||||
|
image: quay.io/libpod/alpine:latest
|
||||||
|
command:
|
||||||
|
- sleep
|
||||||
|
- 24h
|
||||||
|
status: {}
|
||||||
|
`
|
||||||
var sharedNamespacePodYaml = `
|
var sharedNamespacePodYaml = `
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Pod
|
kind: Pod
|
||||||
@ -1098,6 +1115,55 @@ var _ = Describe("Podman play kube", func() {
|
|||||||
Expect(label).To(ContainSubstring("unconfined_u:system_r:spc_t:s0"))
|
Expect(label).To(ContainSubstring("unconfined_u:system_r:spc_t:s0"))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman play kube should use default infra_image", func() {
|
||||||
|
err := writeYaml(checkInfraImagePodYaml, kubeYaml)
|
||||||
|
Expect(err).To(BeNil())
|
||||||
|
|
||||||
|
kube := podmanTest.Podman([]string{"play", "kube", kubeYaml})
|
||||||
|
kube.WaitWithDefaultTimeout()
|
||||||
|
Expect(kube).Should(Exit(0))
|
||||||
|
|
||||||
|
podInspect := podmanTest.Podman([]string{"inspect", "check-infra-image", "--format", "{{ .InfraContainerID }}"})
|
||||||
|
podInspect.WaitWithDefaultTimeout()
|
||||||
|
infraContainerID := podInspect.OutputToString()
|
||||||
|
|
||||||
|
conInspect := podmanTest.Podman([]string{"inspect", infraContainerID, "--format", "{{ .ImageName }}"})
|
||||||
|
conInspect.WaitWithDefaultTimeout()
|
||||||
|
infraContainerImage := conInspect.OutputToString()
|
||||||
|
Expect(infraContainerImage).To(Equal(config.DefaultInfraImage))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("podman play kube should use customized infra_image", func() {
|
||||||
|
conffile := filepath.Join(podmanTest.TempDir, "container.conf")
|
||||||
|
|
||||||
|
infraImage := "k8s.gcr.io/pause:3.2"
|
||||||
|
err := ioutil.WriteFile(conffile, []byte(fmt.Sprintf("[engine]\ninfra_image=\"%s\"\n", infraImage)), 0644)
|
||||||
|
Expect(err).To(BeNil())
|
||||||
|
|
||||||
|
os.Setenv("CONTAINERS_CONF", conffile)
|
||||||
|
defer os.Unsetenv("CONTAINERS_CONF")
|
||||||
|
|
||||||
|
if IsRemote() {
|
||||||
|
podmanTest.RestartRemoteService()
|
||||||
|
}
|
||||||
|
|
||||||
|
err = writeYaml(checkInfraImagePodYaml, kubeYaml)
|
||||||
|
Expect(err).To(BeNil())
|
||||||
|
|
||||||
|
kube := podmanTest.Podman([]string{"play", "kube", kubeYaml})
|
||||||
|
kube.WaitWithDefaultTimeout()
|
||||||
|
Expect(kube).Should(Exit(0))
|
||||||
|
|
||||||
|
podInspect := podmanTest.Podman([]string{"inspect", "check-infra-image", "--format", "{{ .InfraContainerID }}"})
|
||||||
|
podInspect.WaitWithDefaultTimeout()
|
||||||
|
infraContainerID := podInspect.OutputToString()
|
||||||
|
|
||||||
|
conInspect := podmanTest.Podman([]string{"inspect", infraContainerID, "--format", "{{ .ImageName }}"})
|
||||||
|
conInspect.WaitWithDefaultTimeout()
|
||||||
|
infraContainerImage := conInspect.OutputToString()
|
||||||
|
Expect(infraContainerImage).To(Equal(infraImage))
|
||||||
|
})
|
||||||
|
|
||||||
It("podman play kube should share ipc,net,uts when shareProcessNamespace is set", func() {
|
It("podman play kube should share ipc,net,uts when shareProcessNamespace is set", func() {
|
||||||
SkipIfRootless("Requires root privileges for sharing few namespaces")
|
SkipIfRootless("Requires root privileges for sharing few namespaces")
|
||||||
err := writeYaml(sharedNamespacePodYaml, kubeYaml)
|
err := writeYaml(sharedNamespacePodYaml, kubeYaml)
|
||||||
|
Reference in New Issue
Block a user