diff options
author | cdoern <cdoern@redhat.com> | 2021-09-01 10:59:23 -0400 |
---|---|---|
committer | cdoern <cdoern@redhat.com> | 2021-09-14 08:32:07 -0400 |
commit | 84005330aa3d25cf6134fffc1bf20354d4a3dd85 (patch) | |
tree | aef148fafb73e36c3fed0fd7c0f2696f98a71c79 /pkg/specgen | |
parent | ad26684856551251100b945305f91246888ef153 (diff) | |
download | podman-84005330aa3d25cf6134fffc1bf20354d4a3dd85.tar.gz podman-84005330aa3d25cf6134fffc1bf20354d4a3dd85.tar.bz2 podman-84005330aa3d25cf6134fffc1bf20354d4a3dd85.zip |
Pod Volumes Support
added support for the --volume flag in pods using the new infra container design.
users can specify all volume options they can with regular containers
resolves #10379
Signed-off-by: cdoern <cdoern@redhat.com>
Diffstat (limited to 'pkg/specgen')
-rw-r--r-- | pkg/specgen/generate/container_create.go | 14 | ||||
-rw-r--r-- | pkg/specgen/podspecgen.go | 16 |
2 files changed, 29 insertions, 1 deletions
diff --git a/pkg/specgen/generate/container_create.go b/pkg/specgen/generate/container_create.go index f82b2a3c6..1c0c92f4f 100644 --- a/pkg/specgen/generate/container_create.go +++ b/pkg/specgen/generate/container_create.go @@ -28,15 +28,27 @@ func MakeContainer(ctx context.Context, rt *libpod.Runtime, s *specgen.SpecGener return nil, nil, nil, err } - // If joining a pod, retrieve the pod for use. + // If joining a pod, retrieve the pod for use, and its infra container var pod *libpod.Pod + var cont *libpod.Container + var config *libpod.ContainerConfig if s.Pod != "" { pod, err = rt.LookupPod(s.Pod) if err != nil { return nil, nil, nil, errors.Wrapf(err, "error retrieving pod %s", s.Pod) } + if pod.HasInfraContainer() { + cont, err = pod.InfraContainer() + if err != nil { + return nil, nil, nil, err + } + config = cont.Config() + } } + if config != nil && (len(config.NamedVolumes) > 0 || len(config.UserVolumes) > 0 || len(config.ImageVolumes) > 0 || len(config.OverlayVolumes) > 0) { + s.VolumesFrom = append(s.VolumesFrom, config.ID) + } // Set defaults for unset namespaces if s.PidNS.IsDefault() { defaultNS, err := GetDefaultNamespaceMode("pid", rtc, pod) diff --git a/pkg/specgen/podspecgen.go b/pkg/specgen/podspecgen.go index 8872a1321..5f72fc47d 100644 --- a/pkg/specgen/podspecgen.go +++ b/pkg/specgen/podspecgen.go @@ -72,6 +72,22 @@ type PodBasicConfig struct { // Any containers created within the pod will inherit the pod's userns settings. // Optional Userns Namespace `json:"userns,omitempty"` + // Mounts are mounts that will be added to the pod. + // These will supersede Image Volumes and VolumesFrom (WIP) volumes where + // there are conflicts. + // Optional. + Mounts []spec.Mount `json:"mounts,omitempty"` + // Volumes are named volumes that will be added to the pod. + // These will supersede Image Volumes and VolumesFrom (WIP) volumes where + // there are conflicts. + // Optional. + Volumes []*NamedVolume `json:"volumes,omitempty"` + // Overlay volumes are named volumes that will be added to the pod. + // Optional. + OverlayVolumes []*OverlayVolume `json:"overlay_volumes,omitempty"` + // Image volumes bind-mount a container-image mount into the pod's infra container. + // Optional. + ImageVolumes []*ImageVolume `json:"image_volumes,omitempty"` } // PodNetworkConfig contains networking configuration for a pod. |