summaryrefslogtreecommitdiff
path: root/pkg/domain/infra/abi
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2021-06-29 14:18:46 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2021-06-30 13:32:27 -0400
commit092902b455551d7353163c1e6d322f3605b9a897 (patch)
tree40b067377bda67d7d4002100e7210547bf4317f5 /pkg/domain/infra/abi
parent61b7beaf8e595bdc1305a12b49e26a25bbc2bc42 (diff)
downloadpodman-092902b455551d7353163c1e6d322f3605b9a897.tar.gz
podman-092902b455551d7353163c1e6d322f3605b9a897.tar.bz2
podman-092902b455551d7353163c1e6d322f3605b9a897.zip
Handle advanced --network options in podman play kube
Since Podman create/run can support this, so should play. Fixes: https://github.com/containers/podman/issues/10807 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'pkg/domain/infra/abi')
-rw-r--r--pkg/domain/infra/abi/play.go24
1 files changed, 13 insertions, 11 deletions
diff --git a/pkg/domain/infra/abi/play.go b/pkg/domain/infra/abi/play.go
index 0ac9b5d8d..4782f0d01 100644
--- a/pkg/domain/infra/abi/play.go
+++ b/pkg/domain/infra/abi/play.go
@@ -182,20 +182,22 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY
return nil, err
}
if options.Network != "" {
- switch strings.ToLower(options.Network) {
- case "bridge", "host":
+ ns, cniNets, netOpts, err := specgen.ParseNetworkString(options.Network)
+ if err != nil {
+ return nil, err
+ }
+
+ if (ns.IsBridge() && len(cniNets) == 0) || ns.IsHost() {
return nil, errors.Errorf("invalid value passed to --network: bridge or host networking must be configured in YAML")
- case "":
- return nil, errors.Errorf("invalid value passed to --network: must provide a comma-separated list of CNI networks")
- default:
- // We'll assume this is a comma-separated list of CNI
- // networks.
- networks := strings.Split(options.Network, ",")
- logrus.Debugf("Pod joining CNI networks: %v", networks)
- p.NetNS.NSMode = specgen.Bridge
- p.CNINetworks = append(p.CNINetworks, networks...)
+ }
+ logrus.Debugf("Pod %q joining CNI networks: %v", podName, cniNets)
+ p.NetNS.NSMode = specgen.Bridge
+ p.CNINetworks = append(p.CNINetworks, cniNets...)
+ if len(netOpts) > 0 {
+ p.NetworkOptions = netOpts
}
}
+
if len(options.StaticIPs) > *ipIndex {
p.StaticIP = &options.StaticIPs[*ipIndex]
} else if len(options.StaticIPs) > 0 {