diff --git a/api/swagger-spec/v1.json b/api/swagger-spec/v1.json index f8d3c7724c..8d4ababd17 100644 --- a/api/swagger-spec/v1.json +++ b/api/swagger-spec/v1.json @@ -13188,18 +13188,11 @@ }, "v1.PodSecurityContext": { "id": "v1.PodSecurityContext", - "description": "PodSecurityContext holds pod-level security attributes and common container settings.", + "description": "PodSecurityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext. Field values of container.securityContext take precedence over field values of PodSecurityContext.", "properties": { - "supplementalGroups": { - "type": "array", - "items": { - "$ref": "integer" - }, - "description": "SupplementalGroups can be used to specify a list of additional groups which the main container process will run as. This will be applied to all containers in the pod in addition to the primary group of the container." - }, "seLinuxOptions": { "$ref": "v1.SELinuxOptions", - "description": "SELinuxOptions is the SELinux context to be applied to all containers If unspecified, the container runtime will allocate a random SELinux context for each container. May also be set in SecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence for that container." + "description": "The SELinux context to be applied to all containers. If unspecified, the container runtime will allocate a random SELinux context for each container. May also be set in SecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence for that container." }, "runAsUser": { "type": "integer", @@ -13209,6 +13202,18 @@ "runAsNonRoot": { "type": "boolean", "description": "Indicates that the container must run as a non-root user. If true, the Kubelet will validate the image at runtime to ensure that it does not run as UID 0 (root) and fail to start the container if it does. If unset or false, no such validation will be performed. May also be set in SecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence." + }, + "supplementalGroups": { + "type": "array", + "items": { + "$ref": "integer" + }, + "description": "A list of groups applied to the first process run in each container, in addition to the container's primary GID. If unspecified, no groups will be added to any container." + }, + "fsGroup": { + "type": "integer", + "format": "int64", + "description": "A special supplemental group that applies to all containers in a pod. Some volume types allow the Kubelet to change the ownership of that volume to be owned by the pod:\n\n1. The owning GID will be the FSGroup 2. The setgid bit is set (new files created in the volume will be owned by FSGroup) 3. The permission bits are OR'd with rw-rw " } } }, diff --git a/api/swagger-spec/v1beta1.json b/api/swagger-spec/v1beta1.json index 69530ee25a..1221d5eac7 100644 --- a/api/swagger-spec/v1beta1.json +++ b/api/swagger-spec/v1beta1.json @@ -3836,18 +3836,11 @@ }, "v1.PodSecurityContext": { "id": "v1.PodSecurityContext", - "description": "PodSecurityContext holds pod-level security attributes and common container settings.", + "description": "PodSecurityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext. Field values of container.securityContext take precedence over field values of PodSecurityContext.", "properties": { - "supplementalGroups": { - "type": "array", - "items": { - "$ref": "integer" - }, - "description": "SupplementalGroups can be used to specify a list of additional groups which the main container process will run as. This will be applied to all containers in the pod in addition to the primary group of the container." - }, "seLinuxOptions": { "$ref": "v1.SELinuxOptions", - "description": "SELinuxOptions is the SELinux context to be applied to all containers If unspecified, the container runtime will allocate a random SELinux context for each container. May also be set in SecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence for that container." + "description": "The SELinux context to be applied to all containers. If unspecified, the container runtime will allocate a random SELinux context for each container. May also be set in SecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence for that container." }, "runAsUser": { "type": "integer", @@ -3857,6 +3850,18 @@ "runAsNonRoot": { "type": "boolean", "description": "Indicates that the container must run as a non-root user. If true, the Kubelet will validate the image at runtime to ensure that it does not run as UID 0 (root) and fail to start the container if it does. If unset or false, no such validation will be performed. May also be set in SecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence." + }, + "supplementalGroups": { + "type": "array", + "items": { + "$ref": "integer" + }, + "description": "A list of groups applied to the first process run in each container, in addition to the container's primary GID. If unspecified, no groups will be added to any container." + }, + "fsGroup": { + "type": "integer", + "format": "int64", + "description": "A special supplemental group that applies to all containers in a pod. Some volume types allow the Kubelet to change the ownership of that volume to be owned by the pod:\n\n1. The owning GID will be the FSGroup 2. The setgid bit is set (new files created in the volume will be owned by FSGroup) 3. The permission bits are OR'd with rw-rw " } } }, diff --git a/cmd/kubelet/app/server.go b/cmd/kubelet/app/server.go index 405ce99ecd..599b2176c7 100644 --- a/cmd/kubelet/app/server.go +++ b/cmd/kubelet/app/server.go @@ -52,6 +52,8 @@ import ( kubetypes "k8s.io/kubernetes/pkg/kubelet/types" "k8s.io/kubernetes/pkg/master/ports" "k8s.io/kubernetes/pkg/util" + "k8s.io/kubernetes/pkg/util/chmod" + "k8s.io/kubernetes/pkg/util/chown" "k8s.io/kubernetes/pkg/util/io" "k8s.io/kubernetes/pkg/util/mount" nodeutil "k8s.io/kubernetes/pkg/util/node" @@ -320,6 +322,9 @@ func (s *KubeletServer) UnsecuredKubeletConfig() (*KubeletConfig, error) { writer = &io.NsenterWriter{} } + chmodRunner := chmod.New() + chownRunner := chown.New() + tlsOptions, err := s.InitializeTLS() if err != nil { return nil, err @@ -393,6 +398,8 @@ func (s *KubeletServer) UnsecuredKubeletConfig() (*KubeletConfig, error) { MaxPods: s.MaxPods, MinimumGCAge: s.MinimumGCAge, Mounter: mounter, + ChownRunner: chownRunner, + ChmodRunner: chmodRunner, NetworkPluginName: s.NetworkPluginName, NetworkPlugins: ProbeNetworkPlugins(s.NetworkPluginDir), NodeStatusUpdateFrequency: s.NodeStatusUpdateFrequency, @@ -661,6 +668,8 @@ func SimpleKubelet(client *client.Client, MaxPods: maxPods, MinimumGCAge: minimumGCAge, Mounter: mount.New(), + ChownRunner: chown.New(), + ChmodRunner: chmod.New(), NodeStatusUpdateFrequency: nodeStatusUpdateFrequency, OOMAdjuster: oom.NewFakeOOMAdjuster(), OSInterface: osInterface, @@ -843,6 +852,8 @@ type KubeletConfig struct { MaxPods int MinimumGCAge time.Duration Mounter mount.Interface + ChownRunner chown.Interface + ChmodRunner chmod.Interface NetworkPluginName string NetworkPlugins []network.NetworkPlugin NodeName string @@ -938,6 +949,8 @@ func CreateAndInitKubelet(kc *KubeletConfig) (k KubeletBootstrap, pc *config.Pod kc.RktStage1Image, kc.Mounter, kc.Writer, + kc.ChownRunner, + kc.ChmodRunner, kc.DockerDaemonContainer, kc.SystemContainer, kc.ConfigureCBR0, diff --git a/docs/api-reference/extensions/v1beta1/definitions.html b/docs/api-reference/extensions/v1beta1/definitions.html index 5888e3b085..f4a7668a35 100644 --- a/docs/api-reference/extensions/v1beta1/definitions.html +++ b/docs/api-reference/extensions/v1beta1/definitions.html @@ -1864,7 +1864,7 @@ Both these may change in the future. Incoming requests are matched against the h
PodSecurityContext holds pod-level security attributes and common container settings.
+PodSecurityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext. Field values of container.securityContext take precedence over field values of PodSecurityContext.
supplementalGroups |
-SupplementalGroups can be used to specify a list of additional groups which the main container process will run as. This will be applied to all containers in the pod in addition to the primary group of the container. |
-false |
-[integer] array |
-- | |||
seLinuxOptions |
-SELinuxOptions is the SELinux context to be applied to all containers If unspecified, the container runtime will allocate a random SELinux context for each container. May also be set in SecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence for that container. |
+The SELinux context to be applied to all containers. If unspecified, the container runtime will allocate a random SELinux context for each container. May also be set in SecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence for that container. |
false |
@@ -1912,6 +1905,22 @@ Both these may change in the future. Incoming requests are matched against the h | boolean |
false |
|
supplementalGroups |
+A list of groups applied to the first process run in each container, in addition to the container’s primary GID. If unspecified, no groups will be added to any container. |
+false |
+[integer] array |
++ | |||
fsGroup |
+A special supplemental group that applies to all containers in a pod. Some volume types allow the Kubelet to change the ownership of that volume to be owned by the pod: |
+false |
+integer (int64) |
++ |