@@ -154,7 +154,7 @@ The output shows that the processes are running as user 1000, which is the value
154
154
-->
155
155
输出显示进程以用户 1000 运行,即 ` runAsUser ` 所设置的值:
156
156
157
- ``` shell
157
+ ``` none
158
158
PID USER TIME COMMAND
159
159
1 1000 0:00 sleep 1h
160
160
6 1000 0:00 sh
@@ -177,7 +177,7 @@ the value of `fsGroup`.
177
177
-->
178
178
输出显示 ` /data/demo ` 目录的组 ID 为 2000,即 ` fsGroup ` 的设置值:
179
179
180
- ``` shell
180
+ ``` none
181
181
drwxrwsrwx 2 root 2000 4096 Jun 6 20:08 demo
182
182
```
183
183
@@ -205,7 +205,7 @@ The output shows that `testfile` has group ID 2000, which is the value of `fsGro
205
205
-->
206
206
输出显示 ` testfile ` 的组 ID 为 2000,也就是 ` fsGroup ` 所设置的值:
207
207
208
- ``` shell
208
+ ``` none
209
209
-rw-r--r-- 1 1000 2000 6 Jun 6 20:08 testfile
210
210
```
211
211
@@ -498,7 +498,7 @@ The output shows the process IDs (PIDs) for the Container:
498
498
-->
499
499
输出显示容器中进程 ID(PIDs):
500
500
501
- ``` shell
501
+ ```
502
502
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
503
503
root 1 0.0 0.0 4336 796 ? Ss 18:17 0:00 /bin/sh -c node server.js
504
504
root 5 0.1 0.5 772124 22700 ? Sl 18:17 0:00 node server.js
@@ -582,7 +582,7 @@ The output shows capabilities bitmap for the process:
582
582
-->
583
583
输出显示的是进程的权能位图:
584
584
585
- ``` shell
585
+ ```
586
586
...
587
587
CapPrm: 00000000aa0435fb
588
588
CapEff: 00000000aa0435fb
@@ -612,12 +612,12 @@ for definitions of the capability constants.
612
612
613
613
<!--
614
614
Linux capability constants have the form `CAP_XXX`.
615
- But when you list capabilities in your Container manifest, you must
615
+ But when you list capabilities in your container manifest, you must
616
616
omit the `CAP_` portion of the constant.
617
617
For example, to add `CAP_SYS_TIME`, include `SYS_TIME` in your list of capabilities.
618
618
-->
619
619
{{< note >}}
620
- Linux 权能常数定义的形式为 ` CAP_XXX ` 。但是你在 Container 清单中列举权能时,
620
+ Linux 权能常数定义的形式为 ` CAP_XXX ` 。但是你在 container 清单中列举权能时,
621
621
要将权能名称中的 ` CAP_ ` 部分去掉。例如,要添加 ` CAP_SYS_TIME ` ,
622
622
可在权能列表中添加 ` SYS_TIME ` 。
623
623
{{< /note >}}
@@ -633,7 +633,7 @@ in the `securityContext` section of your Pod or Container manifest. The
633
633
Valid options for `type` include `RuntimeDefault`, `Unconfined`, and
634
634
`Localhost`. `localhostProfile` must only be set if `type: Localhost`. It
635
635
indicates the path of the pre-configured profile on the node, relative to the
636
- kubelet's configured Seccomp profile location (configured with the `-root-dir`
636
+ kubelet's configured Seccomp profile location (configured with the `-- root-dir`
637
637
flag).
638
638
639
639
Here is an example that sets the Seccomp profile to the node's container runtime
@@ -706,6 +706,83 @@ To assign SELinux labels, the SELinux security module must be loaded on the host
706
706
要指定 SELinux,需要在宿主操作系统中装载 SELinux 安全性模块。
707
707
{{< /note >}}
708
708
709
+ <!--
710
+ # ## Efficient SELinux volume relabeling
711
+ -->
712
+ # ## 高效重打 SELinux 卷标签
713
+
714
+ {{< feature-state for_k8s_version="v1.25" state="alpha" >}}
715
+
716
+ <!--
717
+ By default, the contrainer runtime recursively assigns SELinux label to all
718
+ files on all Pod volumes. To speed up this process, Kubernetes can change the
719
+ SELinux label of a volume instantly by using a mount option
720
+ ` -o context=<label>` .
721
+ -->
722
+ 默认情况下,容器运行时递归地将 SELinux 标签赋予所有 Pod 卷上的所有文件。
723
+ 为了加快该过程,Kubernetes 使用挂载可选项 `-o context=<label>` 可以立即改变卷的 SELinux 标签。
724
+
725
+ <!--
726
+ To benefit from this speedup, all these conditions must be met :
727
+ -->
728
+ 要使用这项加速功能,必须满足下列条件:
729
+
730
+ <!--
731
+ * Alpha feature gates `ReadWriteOncePod` and `SELinuxMountReadWriteOncePod` must
732
+ be enabled.
733
+ -->
734
+ * 必须启用 Alpha 特性门控 `ReadWriteOncePod` 和 `SELinuxMountReadWriteOncePod`。
735
+
736
+ <!--
737
+ * Pod must use PersistentVolumeClaim with `accessModes: ["ReadWriteOncePod"]`.
738
+ -->
739
+ * Pod 必须以 `accessModes: ["ReadWriteOncePod"]` 模式使用 PersistentVolumeClaim。
740
+
741
+ <!--
742
+ * Pod (or all its Containers that use the PersistentVolumeClaim) must
743
+ have `seLinuxOptions` set.
744
+ -->
745
+ * Pod(或其中使用 PersistentVolumeClaim 的所有容器)必须设置 `seLinuxOptions`。
746
+
747
+ <!--
748
+ * The corresponding PersistentVolume must be either a volume that uses a
749
+ {{< glossary_tooltip text="CSI" term_id="csi" >}} driver, or a volume that uses the
750
+ legacy `iscsi` volume type.
751
+ * If you use a volume backed by a CSI driver, that CSI driver must announce that it
752
+ supports mounting with `-o context` by setting `spec.seLinuxMount : true` in
753
+ its CSIDriver instance.
754
+ -->
755
+ * 对应的 PersistentVolume 必须是使用 {< glossary_tooltip text="CSI" term_id="csi" >}}
756
+ 驱动程序的卷,或者是传统的 `iscsi` 卷类型的卷。
757
+ * 如果使用基于 CSI 驱动程序的卷,CSI 驱动程序必须能够通过在 CSIDriver
758
+ 实例中设置 `spec.seLinuxMount : true` 以支持 `-o context` 挂载。
759
+
760
+ <!--
761
+ For any other volume types, SELinux relabelling happens another way : the container
762
+ runtime recursively changes the SELinux label for all inodes (files and directories)
763
+ in the volume.
764
+ The more files and directories in the volume, the longer that relabelling takes.
765
+ -->
766
+ 对于所有其他卷类型,重打 SELinux 标签的方式有所不同:
767
+ 容器运行时为卷中的所有节点(文件和目录)递归地修改 SELinux 标签。
768
+ 卷中的文件和目录越多,重打标签需要耗费的时间就越长。
769
+
770
+ {{< note >}}
771
+ <!--
772
+ In Kubernetes 1.25, the kubelet loses track of volume labels after restart. In
773
+ other words, then kubelet may refuse to start Pods with errors similar to "conflicting
774
+ SELinux labels of volume", while there are no conflicting labels in Pods. Make sure
775
+ nodes are
776
+ [fully drained](https://kubernetes.io/docs/tasks/administer-cluster/safely-drain-node/)
777
+ before restarting kubelet.
778
+ -->
779
+ 在 Kubernetes 1.25 中,kubelet 在重启后会丢失对卷标签的追踪记录。
780
+ 换言之,kubelet 可能会拒绝启动 Pod,原因类似于 “conflicting
781
+ SELinux labels of volume”,
782
+ 但实际上 Pod 中并没有冲突的标签。在重启 kubelet
783
+ 之前确保节点已被[完全腾空](/zh-cn/docs/tasks/administer-cluster/safely-drain-node/)。
784
+ {{< /note >}}
785
+
709
786
<!--
710
787
# # Discussion
711
788
@@ -773,19 +850,19 @@ kubectl delete pod security-context-demo-4
773
850
* [Tuning Docker with the newest security enhancements](https://github.com/containerd/containerd/blob/main/docs/cri/config.md)
774
851
* [Security Contexts design document](https://git.k8s.io/design-proposals-archive/auth/security_context.md)
775
852
* [Ownership Management design document](https://git.k8s.io/design-proposals-archive/storage/volume-ownership-management.md)
776
- * [Pod Security Policies ](/docs/concepts/security/pod-security-policy /)
853
+ * [PodSecurity Admission ](/docs/concepts/security/pod-security-admission /)
777
854
* [AllowPrivilegeEscalation design
778
855
document](https://git.k8s.io/design-proposals-archive/auth/no-new-privs.md)
779
856
* For more information about security mechanisms in Linux, see
780
- [Overview of Linux Kernel Security Features](https://www.linux.com/learn/overview-linux-kernel-security-features)
857
+ [Overview of Linux Kernel Security Features](https://www.linux.com/learn/overview-linux-kernel-security-features) (Note : Some information is out of date)
781
858
-->
782
859
* [PodSecurityContext](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#podsecuritycontext-v1-core) API 定义
783
860
* [SecurityContext](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#securitycontext-v1-core) API 定义
784
861
* [使用最新的安全性增强来调优 Docker(英文)](https://github.com/containerd/containerd/blob/main/docs/cri/config.md)
785
862
* [安全上下文的设计文档(英文)](https://github.com/kubernetes/design-proposals-archive/blob/main/auth/security_context.md)
786
863
* [属主管理的设计文档(英文)](https://github.com/kubernetes/design-proposals-archive/blob/main/storage/volume-ownership-management.md)
787
- * [Pod 安全策略](/ zh-cn/docs/concepts/security/pod-security-policy /)
864
+ * [Pod 安全性准入]( zh-cn/docs/concepts/security/pod-security-admission /)
788
865
* [AllowPrivilegeEscalation 的设计文档(英文)](https://github.com/kubernetes/design-proposals-archive/blob/main/auth/no-new-privs.md)
789
866
* 关于在 Linux 系统中的安全机制的更多信息,可参阅
790
- [Linux 内核安全性能力概述](https://www.linux.com/learn/overview-linux-kernel-security-features)。
867
+ [Linux 内核安全性能力概述](https://www.linux.com/learn/overview-linux-kernel-security-features)(注意:部分信息已过时) 。
791
868
0 commit comments