Change:
Kubernetes version (use ): 1, 1.6.0 (both run into this issue) Environment: Cloud provider or hardware configuration: VirtualBox 5.1.18 VM OS: 16.04.2 LTS (Xenial Xerus) Kernel: Install tools: kubeadm What happened: A pod scheduled using hostPID wasn't using the host's PID namespace. I've investigated this issue together with What you expected to happen: I expected in the Docker container's config. Instead, the scheduled pod's container had How to reproduce it: Use this config to get a pod running a Docker container: Use on the running container and check whether PidMode is set to host or not. Anything else we need to know*: This was working properly on Kubernetes 1.5.3.
doesn't look like you've specified Docker version, it may be crucial here.
I've tested this with Docker 17.03.1-ce and can confirm that it's the case for pods.
It was Docker 1.12.6 from what I know. I'll check again to be sure it was 1.12.6 and update the post.
Is this with the CRI? If you disable the CRI do you get the desired outcome?
I don't know if that's enabled by default. I've noticed that hostPID doesn't work as it should with Docker. I'm not familiar with CRI.
I'll test with .
With CRI disabled it doesn't work on Docker 17.03, simply because it doesn't like the new versioning scheme. it'd be really great if you can try setting in your , e.g. by modifying (will need to do , and after that you either reinitialise the cluster or kill all the pods).
Seems a bug of kuberuntime, will file a PR to fix this.
Filed for this.
Reoppened this issue to ensure we cherrypick the fix to the 1.6 branch
has been merged to the release-1.6 branch. From what has been discussed so far, this will make it to Kubernetes 1.6.2. I'll close this issue now.
Can anyone help how this issue is fixed? I tried with pidMode: host but it is failing. I am using i.11 version.
I found it --hostPID: true

Discussion:
hc.NetworkMode = dockercontainer.NetworkMode(sandboxNSMode) hc.IpcMode = dockercontainer.IpcMode(sandboxNSMode) hc.UTSMode = "" <del> hc.PidMode = "" </del> if hostNetwork { hc.UTSMode = namespaceModeHost

expected: &dockercontainer.HostConfig{ NetworkMode: dockercontainer.NetworkMode(sandboxNSMode), IpcMode:     dockercontainer.IpcMode(sandboxNSMode), <ins> PidMode:     namespaceModeHost, </ins> }, }, }

} // set namespace options and supplemental groups. <del> podSc := pod.Spec.SecurityContext if podSc == nil { return synthesized } </del> synthesized.NamespaceOptions = &runtimeapi.NamespaceOption{ HostNetwork: pod.Spec.HostNetwork, HostIpc:     pod.Spec.HostIPC, HostPid:     pod.Spec.HostPID, } <del> if podSc.FSGroup != nil { synthesized.SupplementalGroups = append(synthesized.SupplementalGroups, *podSc.FSGroup) </del> <ins> podSc := pod.Spec.SecurityContext if podSc != nil { if podSc.FSGroup != nil { synthesized.SupplementalGroups = append(synthesized.SupplementalGroups, *podSc.FSGroup) } if podSc.SupplementalGroups != nil { synthesized.SupplementalGroups = append(synthesized.SupplementalGroups, podSc.SupplementalGroups...) } </ins> } if groups := m.runtimeHelper.GetExtraSupplementalGroupsForPod(pod); len(groups) > 0 { synthesized.SupplementalGroups = append(synthesized.SupplementalGroups, groups...) } <del> if podSc.SupplementalGroups != nil { synthesized.SupplementalGroups = append(synthesized.SupplementalGroups, podSc.SupplementalGroups...) } </del> return synthesized }