mirror of https://github.com/containers/podman.git
Kube Play - allow creating image based volumes
Add volume.podman.io/image annotation to allow setting the source image Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
This commit is contained in:
parent
97cd376e7f
commit
269149a9fd
|
@ -61,6 +61,7 @@ A Kubernetes PersistentVolumeClaim represents a Podman named volume. Only the Pe
|
||||||
- volume.podman.io/gid
|
- volume.podman.io/gid
|
||||||
- volume.podman.io/mount-options
|
- volume.podman.io/mount-options
|
||||||
- volume.podman.io/import-source
|
- volume.podman.io/import-source
|
||||||
|
- volume.podman.io/image
|
||||||
|
|
||||||
Use `volume.podman.io/import-source` to import the contents of the tarball (.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz) specified in the annotation's value into the created Podman volume
|
Use `volume.podman.io/import-source` to import the contents of the tarball (.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz) specified in the annotation's value into the created Podman volume
|
||||||
|
|
||||||
|
|
|
@ -1147,6 +1147,8 @@ func (ic *ContainerEngine) playKubePVC(ctx context.Context, mountLabel string, p
|
||||||
opts["o"] = v
|
opts["o"] = v
|
||||||
case util.VolumeImportSourceAnnotation:
|
case util.VolumeImportSourceAnnotation:
|
||||||
importFrom = v
|
importFrom = v
|
||||||
|
case util.VolumeImageAnnotation:
|
||||||
|
opts["image"] = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
volOptions = append(volOptions, libpod.WithVolumeOptions(opts))
|
volOptions = append(volOptions, libpod.WithVolumeOptions(opts))
|
||||||
|
|
|
@ -15,4 +15,6 @@ const (
|
||||||
VolumeMountOptsAnnotation = "volume.podman.io/mount-options"
|
VolumeMountOptsAnnotation = "volume.podman.io/mount-options"
|
||||||
// Kube annotation for podman volume import source.
|
// Kube annotation for podman volume import source.
|
||||||
VolumeImportSourceAnnotation = "volume.podman.io/import-source"
|
VolumeImportSourceAnnotation = "volume.podman.io/import-source"
|
||||||
|
// Kube annotation for podman volume image.
|
||||||
|
VolumeImageAnnotation = "volume.podman.io/image"
|
||||||
)
|
)
|
||||||
|
|
|
@ -4062,6 +4062,36 @@ o: {{ .Options.o }}`})
|
||||||
Expect(files[0].Name()).To(Equal(fileName))
|
Expect(files[0].Name()).To(Equal(fileName))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("persistentVolumeClaim - image based", func() {
|
||||||
|
volName := "myVolWithStorage"
|
||||||
|
imageName := "quay.io/libpod/alpine_nginx:latest"
|
||||||
|
pvc := getPVC(withPVCName(volName),
|
||||||
|
withPVCAnnotations(util.VolumeDriverAnnotation, "image"),
|
||||||
|
withPVCAnnotations(util.VolumeImageAnnotation, imageName),
|
||||||
|
)
|
||||||
|
err = generateKubeYaml("persistentVolumeClaim", pvc, kubeYaml)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
kube := podmanTest.Podman([]string{"kube", "play", kubeYaml})
|
||||||
|
kube.WaitWithDefaultTimeout()
|
||||||
|
Expect(kube).Should(ExitCleanly())
|
||||||
|
|
||||||
|
inspect := podmanTest.Podman([]string{"inspect", volName, "--format", `
|
||||||
|
{
|
||||||
|
"Name": "{{ .Name }}",
|
||||||
|
"Driver": "{{ .Driver }}",
|
||||||
|
"Image": "{{ .Options.image }}"
|
||||||
|
}`})
|
||||||
|
inspect.WaitWithDefaultTimeout()
|
||||||
|
Expect(inspect).Should(ExitCleanly())
|
||||||
|
mp := make(map[string]string)
|
||||||
|
err = json.Unmarshal([]byte(inspect.OutputToString()), &mp)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(mp["Name"]).To(Equal(volName))
|
||||||
|
Expect(mp["Driver"]).To(Equal("image"))
|
||||||
|
Expect(mp["Image"]).To(Equal(imageName))
|
||||||
|
})
|
||||||
|
|
||||||
// Multi doc related tests
|
// Multi doc related tests
|
||||||
It("multi doc yaml with persistentVolumeClaim, service and deployment", func() {
|
It("multi doc yaml with persistentVolumeClaim, service and deployment", func() {
|
||||||
yamlDocs := []string{}
|
yamlDocs := []string{}
|
||||||
|
|
Loading…
Reference in New Issue