diff --git a/pkg/kubelet/dockershim/docker_sandbox.go b/pkg/kubelet/dockershim/docker_sandbox.go index a0321a8b58..7c5298d0b6 100644 --- a/pkg/kubelet/dockershim/docker_sandbox.go +++ b/pkg/kubelet/dockershim/docker_sandbox.go @@ -298,6 +298,8 @@ func (ds *dockerService) PodSandboxStatus(podSandboxID string) (*runtimeapi.PodS Network: netNS, Options: &runtimeapi.NamespaceOption{ HostNetwork: hostNetwork, + HostPid: sharesHostPid(r), + HostIpc: sharesHostIpc(r), }, }, }, @@ -490,7 +492,7 @@ func (ds *dockerService) makeSandboxDockerConfig(c *runtimeapi.PodSandboxConfig, return createConfig, nil } -// sharesHostNetwork true if the given container is sharing the hosts's +// sharesHostNetwork returns true if the given container is sharing the host's // network namespace. func sharesHostNetwork(container *dockertypes.ContainerJSON) bool { if container != nil && container.HostConfig != nil { @@ -499,6 +501,24 @@ func sharesHostNetwork(container *dockertypes.ContainerJSON) bool { return false } +// sharesHostPid returns true if the given container is sharing the host's pid +// namespace. +func sharesHostPid(container *dockertypes.ContainerJSON) bool { + if container != nil && container.HostConfig != nil { + return string(container.HostConfig.PidMode) == namespaceModeHost + } + return false +} + +// sharesHostIpc returns true if the given container is sharing the host's ipc +// namespace. +func sharesHostIpc(container *dockertypes.ContainerJSON) bool { + if container != nil && container.HostConfig != nil { + return string(container.HostConfig.IpcMode) == namespaceModeHost + } + return false +} + func setSandboxResources(hc *dockercontainer.HostConfig) { hc.Resources = dockercontainer.Resources{ MemorySwap: dockertools.DefaultMemorySwap(),