Skip to content

Commit 7ae88ef

Browse files
authored
Merge pull request #31630 from tengqm/fix-links
Fix links in security context page
2 parents 7dd728c + 52696d8 commit 7ae88ef

File tree

1 file changed

+54
-39
lines changed

1 file changed

+54
-39
lines changed

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

Lines changed: 54 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,31 @@ A security context defines privilege and access control settings for
1414
a Pod or Container. Security context settings include, but are not limited to:
1515

1616
* Discretionary Access Control: Permission to access an object, like a file, is based on
17-
[user ID (UID) and group ID (GID)](https://wiki.archlinux.org/index.php/users_and_groups).
17+
[user ID (UID) and group ID (GID)](https://wiki.archlinux.org/index.php/users_and_groups).
1818

19-
* [Security Enhanced Linux (SELinux)](https://en.wikipedia.org/wiki/Security-Enhanced_Linux): Objects are assigned security labels.
19+
* [Security Enhanced Linux (SELinux)](https://en.wikipedia.org/wiki/Security-Enhanced_Linux):
20+
Objects are assigned security labels.
2021

2122
* Running as privileged or unprivileged.
2223

23-
* [Linux Capabilities](https://linux-audit.com/linux-capabilities-hardening-linux-binaries-by-removing-setuid/): Give a process some privileges, but not all the privileges of the root user.
24+
* [Linux Capabilities](https://linux-audit.com/linux-capabilities-hardening-linux-binaries-by-removing-setuid/):
25+
Give a process some privileges, but not all the privileges of the root user.
2426

25-
* [AppArmor](/docs/tutorials/clusters/apparmor/): Use program profiles to restrict the capabilities of individual programs.
27+
* [AppArmor](/docs/tutorials/security/apparmor/):
28+
Use program profiles to restrict the capabilities of individual programs.
2629

27-
* [Seccomp](/docs/tutorials/clusters/seccomp/): Filter a process's system calls.
30+
* [Seccomp](/docs/tutorials/security/seccomp/): Filter a process's system calls.
2831

29-
* AllowPrivilegeEscalation: Controls whether a process can gain more privileges than its parent process. This bool directly controls whether the [`no_new_privs`](https://www.kernel.org/doc/Documentation/prctl/no_new_privs.txt) flag gets set on the container process. AllowPrivilegeEscalation is true always when the container is: 1) run as Privileged OR 2) has `CAP_SYS_ADMIN`.
32+
* `allowPrivilegeEscalation`: Controls whether a process can gain more privileges than
33+
its parent process. This bool directly controls whether the
34+
[`no_new_privs`](https://www.kernel.org/doc/Documentation/prctl/no_new_privs.txt)
35+
flag gets set on the container process.
36+
`allowPrivilegeEscalation` is always true when the container:
3037

31-
* readOnlyRootFilesystem: Mounts the container's root filesystem as read-only.
38+
- is run as privileged, or
39+
- has `CAP_SYS_ADMIN`
40+
41+
* `readOnlyRootFilesystem`: Mounts the container's root filesystem as read-only.
3242

3343
The above bullets are not a complete set of security context settings -- please see
3444
[SecurityContext](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#securitycontext-v1-core)
@@ -37,15 +47,10 @@ for a comprehensive list.
3747
For more information about security mechanisms in Linux, see
3848
[Overview of Linux Kernel Security Features](https://www.linux.com/learn/overview-linux-kernel-security-features)
3949

40-
41-
4250
## {{% heading "prerequisites" %}}
4351

44-
4552
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
4653

47-
48-
4954
<!-- steps -->
5055

5156
## Set the security context for a Pod
@@ -91,7 +96,7 @@ ps
9196

9297
The output shows that the processes are running as user 1000, which is the value of `runAsUser`:
9398

94-
```shell
99+
```none
95100
PID USER TIME COMMAND
96101
1 1000 0:00 sleep 1h
97102
6 1000 0:00 sh
@@ -108,7 +113,7 @@ ls -l
108113
The output shows that the `/data/demo` directory has group ID 2000, which is
109114
the value of `fsGroup`.
110115

111-
```shell
116+
```none
112117
drwxrwsrwx 2 root 2000 4096 Jun 6 20:08 demo
113118
```
114119

@@ -127,19 +132,26 @@ ls -l
127132

128133
The output shows that `testfile` has group ID 2000, which is the value of `fsGroup`.
129134

130-
```shell
135+
```none
131136
-rw-r--r-- 1 1000 2000 6 Jun 6 20:08 testfile
132137
```
133138

134139
Run the following command:
135140

136141
```shell
137-
$ id
142+
id
143+
```
144+
145+
The output is similar to this:
146+
147+
```none
138148
uid=1000 gid=3000 groups=2000
139149
```
140-
You will see that gid is 3000 which is same as `runAsGroup` field. If the `runAsGroup` was omitted the gid would
141-
remain as 0(root) and the process will be able to interact with files that are owned by root(0) group and that have
142-
the required group permissions for root(0) group.
150+
151+
From the output, you can see that `gid` is 3000 which is same as the `runAsGroup` field.
152+
If the `runAsGroup` was omitted, the `gid` would remain as 0 (root) and the process will
153+
be able to interact with files that are owned by the root(0) group and groups that have
154+
the required group permissions for the root (0) group.
143155

144156
Exit your shell:
145157

@@ -159,11 +171,14 @@ slowing Pod startup. You can use the `fsGroupChangePolicy` field inside a `secur
159171
to control the way that Kubernetes checks and manages ownership and permissions
160172
for a volume.
161173

162-
**fsGroupChangePolicy** - `fsGroupChangePolicy` defines behavior for changing ownership and permission of the volume
163-
before being exposed inside a Pod. This field only applies to volume types that support
164-
`fsGroup` controlled ownership and permissions. This field has two possible values:
174+
**fsGroupChangePolicy** - `fsGroupChangePolicy` defines behavior for changing ownership
175+
and permission of the volume before being exposed inside a Pod.
176+
This field only applies to volume types that support `fsGroup` controlled ownership and permissions.
177+
This field has two possible values:
165178

166-
* _OnRootMismatch_: Only change permissions and ownership if permission and ownership of root directory does not match with expected permissions of the volume. This could help shorten the time it takes to change ownership and permission of a volume.
179+
* _OnRootMismatch_: Only change permissions and ownership if permission and ownership of
180+
root directory does not match with expected permissions of the volume.
181+
This could help shorten the time it takes to change ownership and permission of a volume.
167182
* _Always_: Always change permission and ownership of the volume when volume is mounted.
168183

169184
For example:
@@ -176,7 +191,6 @@ securityContext:
176191
fsGroupChangePolicy: "OnRootMismatch"
177192
```
178193
179-
180194
{{< note >}}
181195
This field has no effect on ephemeral volume types such as
182196
[`secret`](/docs/concepts/storage/volumes/#secret),
@@ -238,7 +252,7 @@ kubectl exec -it security-context-demo-2 -- sh
238252

239253
In your shell, list the running processes:
240254

241-
```
255+
```shell
242256
ps aux
243257
```
244258

@@ -297,7 +311,7 @@ ps aux
297311

298312
The output shows the process IDs (PIDs) for the Container:
299313

300-
```shell
314+
```
301315
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
302316
root 1 0.0 0.0 4336 796 ? Ss 18:17 0:00 /bin/sh -c node server.js
303317
root 5 0.1 0.5 772124 22700 ? Sl 18:17 0:00 node server.js
@@ -354,7 +368,7 @@ cat status
354368

355369
The output shows capabilities bitmap for the process:
356370

357-
```shell
371+
```
358372
...
359373
CapPrm: 00000000aa0435fb
360374
CapEff: 00000000aa0435fb
@@ -374,7 +388,10 @@ See [capability.h](https://github.com/torvalds/linux/blob/master/include/uapi/li
374388
for definitions of the capability constants.
375389

376390
{{< note >}}
377-
Linux capability constants have the form `CAP_XXX`. But when you list capabilities in your Container manifest, you must omit the `CAP_` portion of the constant. For example, to add `CAP_SYS_TIME`, include `SYS_TIME` in your list of capabilities.
391+
Linux capability constants have the form `CAP_XXX`.
392+
But when you list capabilities in your container manifest, you must
393+
omit the `CAP_` portion of the constant.
394+
For example, to add `CAP_SYS_TIME`, include `SYS_TIME` in your list of capabilities.
378395
{{< /note >}}
379396

380397
## Set the Seccomp Profile for a Container
@@ -437,18 +454,19 @@ the Pod's Volumes when applicable. Specifically `fsGroup` and `seLinuxOptions` a
437454
applied to Volumes as follows:
438455

439456
* `fsGroup`: Volumes that support ownership management are modified to be owned
440-
and writable by the GID specified in `fsGroup`. See the
441-
[Ownership Management design document](https://git.k8s.io/community/contributors/design-proposals/storage/volume-ownership-management.md)
442-
for more details.
457+
and writable by the GID specified in `fsGroup`. See the
458+
[Ownership Management design document](https://git.k8s.io/community/contributors/design-proposals/storage/volume-ownership-management.md)
459+
for more details.
443460

444461
* `seLinuxOptions`: Volumes that support SELinux labeling are relabeled to be accessible
445-
by the label specified under `seLinuxOptions`. Usually you only
446-
need to set the `level` section. This sets the
447-
[Multi-Category Security (MCS)](https://selinuxproject.org/page/NB_MLS)
448-
label given to all Containers in the Pod as well as the Volumes.
462+
by the label specified under `seLinuxOptions`. Usually you only
463+
need to set the `level` section. This sets the
464+
[Multi-Category Security (MCS)](https://selinuxproject.org/page/NB_MLS)
465+
label given to all Containers in the Pod as well as the Volumes.
449466

450467
{{< warning >}}
451-
After you specify an MCS label for a Pod, all Pods with the same label can access the Volume. If you need inter-Pod protection, you must assign a unique MCS label to each Pod.
468+
After you specify an MCS label for a Pod, all Pods with the same label can access the Volume.
469+
If you need inter-Pod protection, you must assign a unique MCS label to each Pod.
452470
{{< /warning >}}
453471

454472
## Clean up
@@ -462,11 +480,8 @@ kubectl delete pod security-context-demo-3
462480
kubectl delete pod security-context-demo-4
463481
```
464482

465-
466-
467483
## {{% heading "whatsnext" %}}
468484

469-
470485
* [PodSecurityContext](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#podsecuritycontext-v1-core)
471486
* [SecurityContext](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#securitycontext-v1-core)
472487
* [Tuning Docker with the newest security enhancements](https://github.com/containerd/containerd/blob/main/docs/cri/config.md)

0 commit comments

Comments
 (0)