提起 Security Context ,估计大家都很陌生,那么现在让我带大家走进 Security Context的世界。
Security Context(安全上下文)用来限制容器对宿主节点的可访问范围,以避免容器非法操作宿主节点的系统级别的内容,使得节点的系统或者节点上其他容器组受到影响。
Security Context可以按照如下几种方式设定:
- 访问权限控制:是否可以访问某个对象(例如文件)是基于 userID(UID)和 groupID(GID) (opens new window)的
- Security Enhanced Linux (SELinux) (opens new window):为对象分配Security标签
- 以 privileged(特权)模式运行
- Linux Capabilities (opens new window):为容器组(或容器)分配一部分特权,而不是 root 用户的所有特权
- AppArmor (opens new window):自 Kubernetes v1.4 以来,一直处于 beta 状态
- Seccomp (opens new window):过滤容器中进程的系统调用(system call)
- AllowPrivilegeEscalation(允许特权扩大):此项配置是一个布尔值,定义了一个进程是否可以比其父进程获得更多的特权,直接效果是,容器的进程上是否被设置 no_new_privs (opens new window)标记。当出现如下情况时,AllowPrivilegeEscalation 的值始终为 true:
- 容器以 privileged 模式运行
- 容器拥有 CAP_SYS_ADMIN 的 Linux Capability
如需要了解更多关于 Linux 安全机制方面的信息,请参考 Overview Of Linux Kernel Security Features