Skip to content

Commit 3fb2925

Browse files
everpeacetengqm
andauthored
Apply suggestions for improvements from code review
Co-authored-by: Qiming Teng <[email protected]>
1 parent edd8ab3 commit 3fb2925

File tree

1 file changed

+30
-19
lines changed

1 file changed

+30
-19
lines changed

content/en/docs/tasks/configure-pod-container/security-context.md

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ all processes within any containers of the Pod. If this field is omitted, the pr
6666
will be root(0). Any files created will also be owned by user 1000 and group 3000 when `runAsGroup` is specified.
6767
Since `fsGroup` field is specified, all processes of the container are also part of the supplementary group ID 2000.
6868
The owner for volume `/data/demo` and any files created in that volume will be Group ID 2000.
69-
Additionally, since `supplementalGroups` field is specified, all processes of the container are also part of the
70-
specified group IDs. If this field is omitted, it means empty.
69+
Additionally, when the `supplementalGroups` field is specified, all processes of the container are also part of the
70+
specified groups. If this field is omitted, it means empty.
7171

7272
Create the Pod:
7373

@@ -150,9 +150,9 @@ uid=1000 gid=3000 groups=2000,3000,4000
150150
From the output, you can see that `gid` is 3000 which is same as the `runAsGroup` field.
151151
If the `runAsGroup` was omitted, the `gid` would remain as 0 (root) and the process will
152152
be able to interact with files that are owned by the root(0) group and groups that have
153-
the required group permissions for the root (0) group. You can also see `groups`
154-
contains the group IDs which are specified by `fsGroup` and `supplementalGroups` other
155-
than `gid`.
153+
the required group permissions for the root (0) group. You can also see that `groups`
154+
contains the group IDs which are specified by `fsGroup` and `supplementalGroups`,
155+
in addition to `gid`.
156156

157157
Exit your shell:
158158

@@ -166,7 +166,7 @@ By default, kubernetes merges group information from the Pod with information de
166166

167167
{{% code_sample file="pods/security/security-context-5.yaml" %}}
168168

169-
In this configuration, it just specifies `runAsUser`, `runAsGroup` and `supplementalGroups`.
169+
This Pod security context contains `runAsUser`, `runAsGroup` and `supplementalGroups`.
170170
However, you can see that the actual supplementary groups attached to the container process
171171
will include group IDs which come from `/etc/group` in the container image.
172172

@@ -200,7 +200,9 @@ The output is similar to this:
200200
uid=1000 gid=3000 groups=3000,4000,50000
201201
```
202202

203-
You can see `groups` includes group ID `50000`. This is because the user (`uid=1000`), which is defined in the image, belongs to the group (`gid=50000`), which is defined in `/etc/group` inside the container image.
203+
You can see that `groups` includes group ID `50000`. This is because the user (`uid=1000`),
204+
which is defined in the image, belongs to the group (`gid=50000`), which is defined in `/etc/group`
205+
inside the container image.
204206

205207
Check the `/etc/group` in the container image:
206208

@@ -223,7 +225,7 @@ exit
223225
```
224226

225227
{{<note>}}
226-
Implicitly _merged_ supplementary groups may cause security concerns particularly in accessing
228+
_Implicitly merged_ supplementary groups may cause security problems particularly when accessing
227229
the volumes (see [kubernetes/kubernetes#112879](https://issue.k8s.io/112879) for details).
228230
If you want to avoid this. Please see the below section.
229231
{{</note>}}
@@ -236,19 +238,25 @@ This feature can be enabled by setting the `SupplementalGroupsPolicy`
236238
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/) for kubelet and
237239
kube-apiserver, and setting the `.spec.securityContext.supplementalGroupsPolicy` field for a pod.
238240

239-
**supplementalGroupsPolicy** - `supplementalGroupsPolicy` defines behavior for calculating
240-
supplementary groups for the container processes in a pod.
241+
The `supplementalGroupsPolicy` field defines the policy for calculating the
242+
supplementary groups for the container processes in a pod. There are two valid
243+
values for this field:
241244

242-
* _Merge_: The group membership defined in `/etc/group` for the container's primary user will be merged. If not specified, this policy will be applied.
245+
* `Merge`: The group membership defined in `/etc/group` for the container's primary user will be merged.
246+
This is the default policy if not specified.
243247

244-
* _Strict_: it only attaches group IDs in `fsGroup`, `supplementalGroups`, or `runAsGroup` fields as the supplementary groups of the container processess. This means no group membership defined in `/etc/group` for the container's primary user will be merged.
248+
* `Strict`: Only group IDs in `fsGroup`, `supplementalGroups`, or `runAsGroup` fields
249+
are attached as the supplementary groups of the container processes.
250+
This means no group membership from `/etc/group` for the container's primary user will be merged.
245251

246-
When the feature is enabled, it also exposes the process identity attached to the first container process of the container
247-
in `.status.containerStatuses[].user.linux` field. It would be helpful to detect if implicit group ID's are attached.
252+
When the feature is enabled, it also exposes the process identity attached to the first container process
253+
in `.status.containerStatuses[].user.linux` field. It would be useful for detecting if
254+
implicit group ID's are attached.
248255

249256
{{% code_sample file="pods/security/security-context-6.yaml" %}}
250257

251-
This pod manifest defines `supplementalGroupsPolicy=Strict`. You can see no group membership defined in `/etc/group` will be merged to the supplementary groups for container processes.
258+
This pod manifest defines `supplementalGroupsPolicy=Strict`. You can see that no group memberships
259+
defined in `/etc/group` are merged to the supplementary groups for container processes.
252260

253261
Create the Pod:
254262

@@ -280,7 +288,7 @@ See the Pod's status:
280288
kubectl get pod security-context-demo -o yaml
281289
```
282290

283-
You can see `status.containerStatuses[].user.linux` field exposes the process identitiy
291+
You can see that the `status.containerStatuses[].user.linux` field exposes the process identitiy
284292
attached to the first container process.
285293

286294
```none
@@ -299,9 +307,12 @@ status:
299307
```
300308

301309
{{<note>}}
302-
Please note that the values in `status.containerStatuses[].user.linux` field is _the firstly attached_
310+
Please note that the values in the `status.containerStatuses[].user.linux` field is _the first attached_
303311
process identity to the first container process in the container. If the container has sufficient privilege
304-
to call system calls related to process identity (e.g. [`setuid(2)`](https://man7.org/linux/man-pages/man2/setuid.2.html), [`setgid(2)`](https://man7.org/linux/man-pages/man2/setgid.2.html) or [`setgroups(2)`](https://man7.org/linux/man-pages/man2/setgroups.2.html), etc.),
312+
to make system calls related to process identity
313+
(e.g. [`setuid(2)`](https://man7.org/linux/man-pages/man2/setuid.2.html),
314+
[`setgid(2)`](https://man7.org/linux/man-pages/man2/setgid.2.html) or
315+
[`setgroups(2)`](https://man7.org/linux/man-pages/man2/setgroups.2.html), etc.),
305316
the container process can change its identity. Thus, the _actual_ process identity will be dynamic.
306317
{{</note>}}
307318

@@ -315,7 +326,7 @@ CRI-level:
315326
- [containerd](https://containerd.io/), since v2.0
316327
- [CRI-O](https://cri-o.io/), since v1.31
317328

318-
You can see if the feature is supported in the node status.
329+
You can see if the feature is supported in the Node status.
319330

320331
```yaml
321332
apiVersion: v1

0 commit comments

Comments
 (0)