diff options
author | Urvashi Mohnani <umohnani@redhat.com> | 2021-11-28 19:32:10 -0500 |
---|---|---|
committer | Urvashi Mohnani <umohnani@redhat.com> | 2021-12-02 14:48:04 -0500 |
commit | 7d331d35ddf5e511bd474505b675191d3f949dc0 (patch) | |
tree | 36c0bc83bb0ff98aade05a9546d6a886843348dd /pkg/specgen/generate/kube/kube.go | |
parent | 7324d94648a9987b0de2dc95cf1b6fbc20592532 (diff) | |
download | podman-7d331d35ddf5e511bd474505b675191d3f949dc0.tar.gz podman-7d331d35ddf5e511bd474505b675191d3f949dc0.tar.bz2 podman-7d331d35ddf5e511bd474505b675191d3f949dc0.zip |
Add support for configmap volumes to play kube
If the k8s yaml has volumes from a configmap, play kube
will now create a volume based on the data from the
configmap and volume source and set it to the right path
in the container accordingly.
Add tests for this and update some test for ENV from configmap.
Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
Diffstat (limited to 'pkg/specgen/generate/kube/kube.go')
-rw-r--r-- | pkg/specgen/generate/kube/kube.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/pkg/specgen/generate/kube/kube.go b/pkg/specgen/generate/kube/kube.go index c502a6e62..6d9f598c9 100644 --- a/pkg/specgen/generate/kube/kube.go +++ b/pkg/specgen/generate/kube/kube.go @@ -310,6 +310,11 @@ func ToSpecGen(ctx context.Context, opts *CtrSpecGenOptions) (*specgen.SpecGener if !exists { return nil, errors.Errorf("Volume mount %s specified for container but not configured in volumes", volume.Name) } + // Skip if the volume is optional. This means that a configmap for a configmap volume was not found but it was + // optional so we can move on without throwing an error + if exists && volumeSource.Optional { + continue + } dest, options, err := parseMountPath(volume.MountPath, volume.ReadOnly) if err != nil { @@ -341,6 +346,13 @@ func ToSpecGen(ctx context.Context, opts *CtrSpecGenOptions) (*specgen.SpecGener Options: options, } s.Volumes = append(s.Volumes, &namedVolume) + case KubeVolumeTypeConfigMap: + cmVolume := specgen.NamedVolume{ + Dest: volume.MountPath, + Name: volumeSource.Source, + Options: options, + } + s.Volumes = append(s.Volumes, &cmVolume) default: return nil, errors.Errorf("Unsupported volume source type") } |