Skip to content

Commit 77b2e63

Browse files
author
Kubernetes Submit Queue
authored
Merge pull request #45236 from verb/sharedpid-2-default
Automatic merge from submit-queue Enable shared PID namespace by default for docker pods **What this PR does / why we need it**: This PR enables PID namespace sharing for docker pods by default, bringing the behavior of docker in line with the other CRI runtimes when used with docker >= 1.13.1. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: ref #1615 **Special notes for your reviewer**: cc @dchen1107 @yujuhong **Release note**: ```release-note Kubernetes now shares a single PID namespace among all containers in a pod when running with docker >= 1.13.1. This means processes can now signal processes in other containers in a pod, but it also means that the `kubectl exec {pod} kill 1` pattern will cause the pod to be restarted rather than a single container. ```
2 parents 899f2f4 + b668371 commit 77b2e63

File tree

8 files changed

+12
-12
lines changed

8 files changed

+12
-12
lines changed

cmd/kubelet/app/options/options.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ func (c *kubeletConfiguration) addFlags(fs *pflag.FlagSet) {
314314

315315
fs.StringVar(&c.RemoteRuntimeEndpoint, "container-runtime-endpoint", c.RemoteRuntimeEndpoint, "[Experimental] The unix socket endpoint of remote runtime service. The endpoint is used only when CRI integration is enabled (--enable-cri)")
316316
fs.StringVar(&c.RemoteImageEndpoint, "image-service-endpoint", c.RemoteImageEndpoint, "[Experimental] The unix socket endpoint of remote image service. If not specified, it will be the same with container-runtime-endpoint by default. The endpoint is used only when CRI integration is enabled (--enable-cri)")
317-
fs.BoolVar(&c.DockerEnableSharedPID, "experimental-docker-enable-shared-pid", c.DockerEnableSharedPID, "[Experimental] The Container Runtime Interface (CRI) will eventually default to using a shared PID namespace for containers in a pod. Setting this flag allows previewing this behavior when running with the CRI enabled and Docker version 1.13.1 or higher.")
317+
fs.BoolVar(&c.DockerDisableSharedPID, "docker-disable-shared-pid", c.DockerDisableSharedPID, "The Container Runtime Interface (CRI) defaults to using a shared PID namespace for containers in a pod when running with Docker 1.13.1 or higher. Setting this flag reverts to the previous behavior of isolated PID namespaces. This ability will be removed in a future Kubernetes release.")
318318

319319
fs.BoolVar(&c.ExperimentalCheckNodeCapabilitiesBeforeMount, "experimental-check-node-capabilities-before-mount", c.ExperimentalCheckNodeCapabilitiesBeforeMount, "[Experimental] if set true, the kubelet will check the underlying node for required componenets (binaries, etc.) before performing the mount")
320320

cmd/kubelet/app/server.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,7 @@ func RunDockershim(c *componentconfig.KubeletConfiguration, dockershimRootDir st
968968

969969
ds, err := dockershim.NewDockerService(dockerClient, c.SeccompProfileRoot, c.PodInfraContainerImage,
970970
streamingConfig, &pluginSettings, c.RuntimeCgroups, c.CgroupDriver, c.DockerExecHandlerName, dockershimRootDir,
971-
!c.DockerEnableSharedPID)
971+
c.DockerDisableSharedPID)
972972
if err != nil {
973973
return err
974974
}

hack/verify-flags/known-flags.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ dns-provider
178178
dns-provider-config
179179
dns-zone-name
180180
dockercfg-path
181+
docker-disable-shared-pid
181182
docker-email
182183
docker-endpoint
183184
docker-exec-handler
@@ -245,7 +246,6 @@ experimental-check-node-capabilities-before-mount
245246
experimental-cri
246247
experimental-dockershim
247248
experimental-dockershim-root-directory
248-
experimental-docker-enable-shared-pid
249249
experimental-fail-swap-on
250250
experimental-kernel-memcg-notification
251251
experimental-keystone-ca-file

pkg/apis/componentconfig/types.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -524,11 +524,11 @@ type KubeletConfiguration struct {
524524
// This flag, if set, instructs the kubelet to keep volumes from terminated pods mounted to the node.
525525
// This can be useful for debugging volume related issues.
526526
KeepTerminatedPodVolumes bool
527-
// This flag, if set, enables use of a shared PID namespace for pods running in the docker CRI runtime.
527+
// This flag, if set, disables use of a shared PID namespace for pods running in the docker CRI runtime.
528528
// A shared PID namespace is the only option in non-docker runtimes and is required by the CRI. The ability to
529529
// disable it for docker will be removed unless a compelling use case is discovered with widespread use.
530530
// TODO: Remove once we no longer support disabling shared PID namespace (https://issues.k8s.io/41938)
531-
DockerEnableSharedPID bool
531+
DockerDisableSharedPID bool
532532

533533
/* following flags are meant for Node Allocatable */
534534

pkg/apis/componentconfig/v1alpha1/types.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,8 @@ type KubeletConfiguration struct {
579579
// This flag, if set, instructs the kubelet to keep volumes from terminated pods mounted to the node.
580580
// This can be useful for debugging volume related issues.
581581
KeepTerminatedPodVolumes bool `json:"keepTerminatedPodVolumes,omitempty"`
582-
// This flag, if set, enables use of a shared PID namespace for pods run by the docker CRI runtime.
583-
DockerEnableSharedPID *bool `json:"dockerEnableSharedPID,omitempty"`
582+
// This flag, if set, disables use of a shared PID namespace for pods run by the docker CRI runtime.
583+
DockerDisableSharedPID *bool `json:"dockerDisableSharedPID,omitempty"`
584584

585585
/* following flags are meant for Node Allocatable */
586586

pkg/apis/componentconfig/v1alpha1/zz_generated.conversion.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ func autoConvert_v1alpha1_KubeletConfiguration_To_componentconfig_KubeletConfigu
524524
out.ExperimentalFailSwapOn = in.ExperimentalFailSwapOn
525525
out.ExperimentalCheckNodeCapabilitiesBeforeMount = in.ExperimentalCheckNodeCapabilitiesBeforeMount
526526
out.KeepTerminatedPodVolumes = in.KeepTerminatedPodVolumes
527-
if err := v1.Convert_Pointer_bool_To_bool(&in.DockerEnableSharedPID, &out.DockerEnableSharedPID, s); err != nil {
527+
if err := v1.Convert_Pointer_bool_To_bool(&in.DockerDisableSharedPID, &out.DockerDisableSharedPID, s); err != nil {
528528
return err
529529
}
530530
out.SystemReserved = *(*componentconfig.ConfigurationMap)(unsafe.Pointer(&in.SystemReserved))
@@ -728,7 +728,7 @@ func autoConvert_componentconfig_KubeletConfiguration_To_v1alpha1_KubeletConfigu
728728
out.ExperimentalFailSwapOn = in.ExperimentalFailSwapOn
729729
out.ExperimentalCheckNodeCapabilitiesBeforeMount = in.ExperimentalCheckNodeCapabilitiesBeforeMount
730730
out.KeepTerminatedPodVolumes = in.KeepTerminatedPodVolumes
731-
if err := v1.Convert_bool_To_Pointer_bool(&in.DockerEnableSharedPID, &out.DockerEnableSharedPID, s); err != nil {
731+
if err := v1.Convert_bool_To_Pointer_bool(&in.DockerDisableSharedPID, &out.DockerDisableSharedPID, s); err != nil {
732732
return err
733733
}
734734
out.SystemReserved = *(*map[string]string)(unsafe.Pointer(&in.SystemReserved))

pkg/apis/componentconfig/v1alpha1/zz_generated.deepcopy.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,8 @@ func DeepCopy_v1alpha1_KubeletConfiguration(in interface{}, out interface{}, c *
336336
*out = new(bool)
337337
**out = **in
338338
}
339-
if in.DockerEnableSharedPID != nil {
340-
in, out := &in.DockerEnableSharedPID, &out.DockerEnableSharedPID
339+
if in.DockerDisableSharedPID != nil {
340+
in, out := &in.DockerDisableSharedPID, &out.DockerDisableSharedPID
341341
*out = new(bool)
342342
**out = **in
343343
}

pkg/kubelet/kubelet.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ func NewMainKubelet(kubeCfg *componentconfig.KubeletConfiguration, kubeDeps *Kub
548548
streamingConfig := getStreamingConfig(kubeCfg, kubeDeps)
549549
ds, err := dockershim.NewDockerService(klet.dockerClient, kubeCfg.SeccompProfileRoot, kubeCfg.PodInfraContainerImage,
550550
streamingConfig, &pluginSettings, kubeCfg.RuntimeCgroups, kubeCfg.CgroupDriver, kubeCfg.DockerExecHandlerName, dockershimRootDir,
551-
!kubeCfg.DockerEnableSharedPID)
551+
kubeCfg.DockerDisableSharedPID)
552552
if err != nil {
553553
return nil, err
554554
}

0 commit comments

Comments
 (0)