Skip to content

Commit c5a17a1

Browse files
authored
Merge pull request #41554 from windsonsea/adoptcdn
modify heading levels in blog: efficient-selinux-relabeling-beta
2 parents bdcf995 + a3a5cc9 commit c5a17a1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

content/en/blog/_posts/2023-04-18-efficient-selinux-relabeling-beta.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ slug: kubernetes-1-27-efficient-selinux-relabeling-beta
77

88
**Author:** Jan Šafránek (Red Hat)
99

10-
# The problem
10+
## The problem
1111

1212
On Linux with Security-Enhanced Linux (SELinux) enabled, it's traditionally
1313
the container runtime that applies SELinux labels to a Pod and all its volumes.
@@ -30,7 +30,7 @@ escapes the container boundary cannot access data of any other container on the
3030
host. The container runtime still recursively relabels all pod volumes with this
3131
random SELinux label.
3232

33-
# Improvement using mount options
33+
## Improvement using mount options
3434

3535
If a Pod and its volume meet **all** of the following conditions, Kubernetes will
3636
_mount_ the volume directly with the right SELinux label. Such mount will happen
@@ -50,7 +50,9 @@ relabel any files on it.
5050
applied by the container runtime by a recursive walk through the volume
5151
(or its subPaths).
5252

53-
1. The Pod must have at least `seLinuxOptions.level` assigned in its [Pod Security Context](/docs/reference/kubernetes-api/workload-resources/pod-v1/#security-context) or all Pod containers must have it set in their [Security Contexts](/docs/reference/kubernetes-api/workload-resources/pod-v1/#security-context-1).
53+
1. The Pod must have at least `seLinuxOptions.level` assigned in its
54+
[Pod Security Context](/docs/reference/kubernetes-api/workload-resources/pod-v1/#security-context)
55+
or all Pod containers must have it set in their [Security Contexts](/docs/reference/kubernetes-api/workload-resources/pod-v1/#security-context-1).
5456
Kubernetes will read the default `user`, `role` and `type` from the operating
5557
system defaults (typically `system_u`, `system_r` and `container_t`).
5658

@@ -90,7 +92,7 @@ relabel any files on it.
9092
set `seLinuxMount: true` will be recursively relabelled by the container
9193
runtime.
9294

93-
## Mounting with SELinux context
95+
### Mounting with SELinux context
9496

9597
When all aforementioned conditions are met, kubelet will
9698
pass `-o context=<SELinux label>` mount option to the volume plugin or CSI
@@ -105,7 +107,8 @@ value. Similarly, CIFS may need `-o context=<SELinux label>,nosharesock`.
105107
It's up to the CSI driver vendor to test their CSI driver in a SELinux enabled
106108
environment before setting `seLinuxMount: true` in the CSIDriver instance.
107109

108-
# How can I learn more?
110+
## How can I learn more?
111+
109112
SELinux in containers: see excellent
110113
[visual SELinux guide](https://opensource.com/business/13/11/selinux-policy-guide)
111114
by Daniel J Walsh. Note that the guide is older than Kubernetes, it describes
@@ -114,6 +117,7 @@ however, a similar concept is used for containers.
114117

115118
See a series of blog posts for details how exactly SELinux is applied to
116119
containers by container runtimes:
120+
117121
* [How SELinux separates containers using Multi-Level Security](https://www.redhat.com/en/blog/how-selinux-separates-containers-using-multi-level-security)
118122
* [Why you should be using Multi-Category Security for your Linux containers](https://www.redhat.com/en/blog/why-you-should-be-using-multi-category-security-your-linux-containers)
119123

0 commit comments

Comments
 (0)