[TOC]
### **Pod的SecurityContext**
Pod的SecurityContext主要有如下字段可以设置(v1.19)
```
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
securityContext:
fsGroup: integer
fsGroupChangePolicy: string
runAsGroup: integer
runAsNonRoot: boolean
runAsUser: integer
seLinuxOptions: seLinuxOptions
seccompProfile: seccompProfile
supplementalGroups: integer array
sysctls: sysctl array
windowsOptions: WindowsSecurityContextOptions
...
```
Container的SecurityContext比Pod的多了五个字段:allowPrivilegeEscalation、capabilities、privileged、procMount、readOnlyRootFilesystem
```
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
- name: nginx
securityContext:
fsGroup: integer
fsGroupChangePolicy: string
runAsGroup: integer
runAsNonRoot: boolean
runAsUser: integer
seLinuxOptions: seLinuxOptions
seccompProfile: seccompProfile
supplementalGroups: integer array
sysctls: sysctl array
windowsOptions: WindowsSecurityContextOptions
allowPrivilegeEscalation: boolean
capabilities: Capabilities
privileged: boolean
procMount: string
readOnlyRootFilesystem: boolean
...
```
### **设置Seccomp**
给Pod设置Seccomp的方法只有一种
1、就是在每个Pod或Container的SecurityContext字段进行配置
如下是一个示例:
```
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
securityContext:
seccompProfile:
type: LocalHost # Unconfined, RuntimeDefault
localhostProfile: profile/default.json
```
seccompProfile的type有三个值可选
* LocalHost:表示使用容器所在节点(主机)上的配置文件,localhostProfile字段表示文件在节点上的相对路径,可以通过kubelet的参数`--seccomp-profile-root`设置根路径(默认为`/var/lib/kubelet/seccomp`),那么上面的文件的绝对路径就是`/var/lib/kubelet/seccomp/profile/default.json`
* Unconfined:允许所有的系统调用,不做任何限制
* RuntimeDefault:使用容器运行时的默认配置。参考[docker的默认配置文件](https://github.com/moby/moby/blob/master/profiles/seccomp/default.json)
### **设置Capabilities**
Capabilities可以在两处进行配置:
1、在Pod或Container的SecurityContext中进行配置
2、在PSP中进行配置。在PSP中也有一个字段defaultAddCapabilities,可以给符合要求的Pod添加Capabilities
### 设置Selinux
### 设置AppArmor
- 常用命令
- 安装
- 安装Kubeadm
- 安装单Master集群
- 安装高可用集群(手动分发证书)
- 安装高可用集群(自动分发证书)
- 启动参数解析
- certificate-key
- ETCD相关参数
- Kubernetes端口汇总
- 安装IPv4-IPv6双栈集群
- 下载二进制文件
- 使用Kata容器
- 快速安装shell脚本
- 存储
- 实践
- Ceph-RBD实践
- CephFS实践
- 对象存储
- 阿里云CSI
- CSI
- 安全
- 认证与授权
- 认证
- 认证-实践
- 授权
- ServiceAccount
- NodeAuthorizor
- TLS bootstrapping
- Kubelet的认证
- 准入控制
- 准入控制示例
- Pod安全上下文
- Selinux-Seccomp-Capabilities
- 给容器配置安全上下文
- PodSecurityPolicy
- K8S-1.8手动开启认证与授权
- Helm
- Helm命令
- Chart
- 快速入门
- 内置对象
- 模板函数与管道
- 模板函数列表
- 流程控制
- Chart依赖
- Repository
- 开源的Chart包
- CRD
- CRD入门
- 工作负载
- Pod
- Pod的重启策略
- Container
- 探针
- 工作负载的状态
- 有状态服务
- 网络插件
- Multus
- Calico+Flannel
- 容器网络限速
- 自研网络插件
- 设计文档
- Cilium
- 安装Cilium
- Calico
- Calico-FAQ
- IPAM
- Whereabouts
- 控制平面与Pod网络分开
- 重新编译
- 编译kubeadm
- 编译kubeadm-1.23
- 资源预留
- 资源预留简介
- imagefs与nodefs
- 资源预留 vs 驱逐 vs OOM
- 负载均衡
- 灰度与蓝绿
- Ingress的TLS
- 多个NginxIngressController实例
- Service的会话亲和
- CNI实践
- CNI规范
- 使用cnitool模拟调用
- CNI快速入门
- 性能测试
- 性能测试简介
- 制作kubemark镜像
- 使用clusterloader2进行性能测试
- 编译clusterloader2二进制文件
- 搭建性能测试环境
- 运行density测试
- 运行load测试
- 参数调优
- Measurement
- TestMetrics
- EtcdMetrics
- SLOMeasurement
- PrometheusMeasurement
- APIResponsivenessPrometheus
- PodStartupLatency
- FAQ
- 调度
- 亲和性与反亲和性
- GPU
- HPA
- 命名规范
- 可信云认证
- 磁盘限速
- Virtual-kubelet
- VK思路整理
- Kubebuilder
- FAQ
- 阿里云日志服务SLS