Files
kuboard-press/learning/k8s-intermediate/config/sec-ctx/index.md
2020-12-24 13:57:19 +08:00

2.6 KiB
Raw Blame History

vssueId, titlePrefix, layout, description, meta
vssueId titlePrefix layout description meta
108 为Pod或Container配置Security Context LearningLayout Kubernetes教程_为Pod容器组或Container容器配置Security Context安全上下文
name content
keywords Kubernetes教程,K8S教程,Security Context,SecurityContext

概述

参考文档Kubernetes 文档 Configure a Security Context for a Pod or Container

Security Context安全上下文用来限制容器对宿主节点的可访问范围以避免容器非法操作宿主节点的系统级别的内容使得节点的系统或者节点上其他容器组受到影响。

Security Context可以按照如下几种方式设定

  • 访问权限控制:是否可以访问某个对象(例如文件)是基于 userIDUID和 groupIDGID

  • Security Enhanced Linux (SELinux)为对象分配Security标签

  • 以 privileged特权模式运行

  • Linux Capabilities:为容器组(或容器)分配一部分特权,而不是 root 用户的所有特权

  • AppArmor:自 Kubernetes v1.4 以来,一直处于 beta 状态

  • Seccomp过滤容器中进程的系统调用system call

  • AllowPrivilegeEscalation允许特权扩大此项配置是一个布尔值定义了一个进程是否可以比其父进程获得更多的特权直接效果是容器的进程上是否被设置 no_new_privs 标记。当出现如下情况时AllowPrivilegeEscalation 的值始终为 true

    • 容器以 privileged 模式运行
    • 容器拥有 CAP_SYS_ADMIN 的 Linux Capability

如需要了解更多关于 Linux 安全机制方面的信息,请参考 Overview Of Linux Kernel Security Features

本文从以下几个方面介绍如何在 Kubernetes 中配置 Security Context

详细信息请点击对应链接。