|
1 | 1 | // Module included in the following assemblies:
|
2 | 2 | //
|
3 |
| -// * scalability_and_performance/optimizing-cpu-usage |
| 3 | +// * scalability_and_performance/optimizing-cpu-usage.adoc |
| 4 | + |
4 | 5 | :_content-type: CONCEPT
|
5 | 6 | [id="optimizing-cpu-usage_{context}"]
|
6 | 7 | = Encapsulating mount namespaces
|
7 | 8 |
|
8 | 9 | Mount namespaces are used to isolate mount points so that processes in different namespaces cannot view each others' files. Encapsulation is the process of moving Kubernetes mount namespaces to an alternative location where they will not be constantly scanned by the host operating system.
|
9 | 10 |
|
10 |
| -The host operating system uses systemd to constantly scan all mount namespaces: both the standard Linux mounts and the numerous mounts that Kubernetes uses to operate. The current implementation of kubelet and CRI-O both use the top-level namespace for all container runtime and kubelet mountpoints. However, encapsulating these container-specific mountpoints in a private namespace reduces systemd overhead with no difference in functionality. Using a separate mount namespace for both CRI-O and kubelet can encapsulate container-specific mounts from any systemd or other host OS interaction. |
| 11 | +The host operating system uses systemd to constantly scan all mount namespaces: both the standard Linux mounts and the numerous mounts that Kubernetes uses to operate. The current implementation of kubelet and CRI-O both use the top-level namespace for all container runtime and kubelet mount points. However, encapsulating these container-specific mount points in a private namespace reduces systemd overhead with no difference in functionality. Using a separate mount namespace for both CRI-O and kubelet can encapsulate container-specific mounts from any systemd or other host operating system interaction. |
11 | 12 |
|
12 | 13 | This ability to potentially achieve major CPU optimization is now available to all {product-title} administrators. Encapsulation can also improve security by storing Kubernetes-specific mount points in a location safe from inspection by unprivileged users.
|
13 | 14 |
|
14 | 15 | The following diagrams illustrate a Kubernetes installation before and after encapsulation. Both scenarios show example containers which have mount propagation settings of bidirectional, host-to-container, and none.
|
15 | 16 |
|
16 | 17 | image::before-k8s-mount-propagation.png[Before encapsulation]
|
17 | 18 |
|
18 |
| -Here we see systemd, host OS processes, kubelet, and the container runtime sharing a single mount namespace. |
| 19 | +Here we see systemd, host operating system processes, kubelet, and the container runtime sharing a single mount namespace. |
19 | 20 |
|
20 |
| -* systemd, host OS processes, kubelet, and the container runtime each have access to and visibility of all mount points. |
| 21 | +* systemd, host operating system processes, kubelet, and the container runtime each have access to and visibility of all mount points. |
21 | 22 |
|
22 |
| -* Container 1, configured with bidirectional mount propagation, can access systemd and host mounts, kubelet and CRI-O mounts. A mount originating in Container 1, such as `/run/a` is visible to systemd, host OS processes, kubelet, container runtime, and other containers with host-to-container or bidirectional mount propagation configured (as in Container 2). |
| 23 | +* Container 1, configured with bidirectional mount propagation, can access systemd and host mounts, kubelet and CRI-O mounts. A mount originating in Container 1, such as `/run/a` is visible to systemd, host operating system processes, kubelet, container runtime, and other containers with host-to-container or bidirectional mount propagation configured (as in Container 2). |
23 | 24 |
|
24 | 25 | * Container 2, configured with host-to-container mount propagation, can access systemd and host mounts, kubelet and CRI-O mounts. A mount originating in Container 2, such as `/run/b`, is not visible to any other context.
|
25 | 26 |
|
26 | 27 | * Container 3, configured with no mount propagation, has no visibility of external mount points. A mount originating in Container 3, such as `/run/c`, is not visible to any other context.
|
27 | 28 |
|
28 |
| -
|
29 | 29 | The following diagram illustrates the system state after encapsulation.
|
30 | 30 |
|
31 | 31 | image::after-k8s-mount-propagation.png[After encapsulation]
|
32 | 32 |
|
33 |
| -* The main systemd process is no longer devoted to unnecessary scanning of Kubernetes-specific mount points. It only monitors systemd-specific and host mountpoints. |
| 33 | +* The main systemd process is no longer devoted to unnecessary scanning of Kubernetes-specific mount points. It only monitors systemd-specific and host mount points. |
34 | 34 |
|
35 |
| -* The host OS processes can access only the systemd and host mountpoints. |
| 35 | +* The host operating system processes can access only the systemd and host mount points. |
36 | 36 |
|
37 |
| -* Using a separate mount namespace for both CRI-O and kubelet completely separates all container-specific mounts away from any systemd or other host OS interaction whatsoever. |
| 37 | +* Using a separate mount namespace for both CRI-O and kubelet completely separates all container-specific mounts away from any systemd or other host operating system interaction whatsoever. |
38 | 38 |
|
39 |
| -* The behavior of Container 1 is unchanged, except a mount it creates such as `/run/a` is no longer visible to systemd or host OS processes. It is still visible to kubelet, CRI-O, and other containers with host-to-container or bidirectional mount propagation configured (like Container 2). |
| 39 | +* The behavior of Container 1 is unchanged, except a mount it creates such as `/run/a` is no longer visible to systemd or host operating system processes. It is still visible to kubelet, CRI-O, and other containers with host-to-container or bidirectional mount propagation configured (like Container 2). |
40 | 40 |
|
41 | 41 | * The behavior of Container 2 and Container 3 is unchanged.
|
0 commit comments