summaryrefslogtreecommitdiff
path: root/libpod/runtime_pod_infra_linux.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2020-02-17 16:21:07 -0500
committerMatthew Heon <matthew.heon@pm.me>2020-02-17 16:21:07 -0500
commit666d8cf1deeba4113a9b03e0bc208b1a14122733 (patch)
tree36668d17c27e5a6b967fcfb5180e687cd9c297b8 /libpod/runtime_pod_infra_linux.go
parent640b11f0028057ca2090d61c4e460c1afadb226c (diff)
downloadpodman-666d8cf1deeba4113a9b03e0bc208b1a14122733.tar.gz
podman-666d8cf1deeba4113a9b03e0bc208b1a14122733.tar.bz2
podman-666d8cf1deeba4113a9b03e0bc208b1a14122733.zip
Add ability for pods to use the host network
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'libpod/runtime_pod_infra_linux.go')
-rw-r--r--libpod/runtime_pod_infra_linux.go18
1 files changed, 12 insertions, 6 deletions
diff --git a/libpod/runtime_pod_infra_linux.go b/libpod/runtime_pod_infra_linux.go
index 1b1421ca8..3aded61f2 100644
--- a/libpod/runtime_pod_infra_linux.go
+++ b/libpod/runtime_pod_infra_linux.go
@@ -94,13 +94,19 @@ func (r *Runtime) makeInfraContainer(ctx context.Context, p *Pod, imgName, imgID
options = append(options, withIsInfra())
// Since user namespace sharing is not implemented, we only need to check if it's rootless
- netmode := "bridge"
- if isRootless {
- netmode = "slirp4netns"
+ if !p.config.InfraContainer.HostNetwork {
+ netmode := "bridge"
+ if isRootless {
+ netmode = "slirp4netns"
+ }
+ // PostConfigureNetNS should not be set since user namespace sharing is not implemented
+ // and rootless networking no longer supports post configuration setup
+ options = append(options, WithNetNS(p.config.InfraContainer.PortBindings, false, netmode, p.config.InfraContainer.Networks))
+ } else {
+ if err := g.RemoveLinuxNamespace(string(spec.NetworkNamespace)); err != nil {
+ return nil, errors.Wrapf(err, "error removing network namespace from pod %s infra container", p.ID())
+ }
}
- // PostConfigureNetNS should not be set since user namespace sharing is not implemented
- // and rootless networking no longer supports post configuration setup
- options = append(options, WithNetNS(p.config.InfraContainer.PortBindings, false, netmode, p.config.InfraContainer.Networks))
if p.config.InfraContainer.StaticIP != nil {
options = append(options, WithStaticIP(p.config.InfraContainer.StaticIP))