我有两个k8s集群,一个使用码头,另一个直接使用容器,这两个集群都启用了selinux。但是我发现selinux实际上并没有运行在容器1上,尽管这两个集群具有相同版本的containerd和runc。
我错过了集装箱的设置吗?
docker:文件标签为container_file_t,,进程运行为container_t,selinux运行良好
K8s version: 1.17
Docker version: 19.03.6
Containerd version: 1.2.10
selinux enable by adding ["selinux-enabled": true] to /etc/docker/daemon.json
// create pod using tomcat official image then check the process and file label
# kubectl exec tomcat -it -- ps -eZ
LABEL PID TTY TIME CMD
system_u:system_r:container_t:s0:c655,c743 1 ? 00:00:00 java
# ls -Z /usr/local/openjdk-8/bin/java
system_u:object_r:container_file_t:s0:c655,c743 /usr/local/openjdk-8/bin/java文件标签是container_var_lib_t,,进程运行为spc_t,selinux没有任何意义。
K8s version: 1.15
Containerd version: 1.2.10
selinux enable by setting [enable_selinux = true] in /etc/containerd/config.toml
// create pod using tomcat official image then check the process and file label
# kubectl exec tomcat -it -- ps -eZ
LABEL PID TTY TIME CMD
system_u:system_r:spc_t:s0 1 ? 00:00:00 java
# ls -Z /usr/local/openjdk-8/bin/java
system_u:object_r:container_var_lib_t:s0 /usr/local/openjdk-8/bin/java
// seems run as spc_t is correct
# sesearch -T -t container_var_lib_t | grep spc_t
type_transition container_runtime_t container_var_lib_t : process spc_t;发布于 2020-04-14 13:34:27
从这个问题中我们可以读到:
Containerd包含对SELinux的最小支持。更准确地说,它包含了对使用SELinux在系统上运行的支持,但它没有使用SELinux来提高容器安全性。 所有容器都使用
system_u:system_r:container_runtime_t:s0标签运行,但不进行进一步的分段。
对您使用Containerd所做的操作没有完全的支持。您的方法是正确的,但问题是缺乏对此功能的支持。
https://stackoverflow.com/questions/61153399
复制相似问题