SuperAPI AI 工具集

implementing-kubernetes-pod-security-standards

部署与运维

查看项目

更新于 10-16 01:30

技能介绍

用途:帮助判断命名空间或工作负载应归属 Privileged、Baseline 还是 Restricted,审计现有工作负载在 Restricted 下是否会被拒绝,把“必须满足 Restricted”的要求转化为具体 securityContext 改动,规划 PodSecurityPolicy 迁移,并将 Pod 安全态势映射到合规控制(如 NIST PR.PS-01、CIS Kubernetes)。不负责配置执行这些档位的控制器本身(命名空间标签、AdmissionConfiguration、豁免或调试被 PSA 拒绝的 Pod),那属于 implementing-pod-security-admission-controller。

主要能力:PSS 由 Kubernetes 1.25+ 内置的 Pod Security Admission 控制器执行,提供三个档位——Privileged(无限制,系统工作负载)、Baseline(阻止已知提权,禁止 hostNetwork、hostPID、hostIPC、特权容器和危险 capabilities)、Restricted(强化最佳实践,要求非 root、drop ALL caps、seccomp,建议只读根文件系统);三种模式——enforce(拒绝违规 Pod)、audit(记录违规但放行)、warn(向用户返回警告但放行)。

使用方式:通过命名空间标签启用,如 pod-security.kubernetes.io/enforce、audit、warn 及对应 -version。可用 kubectl label namespace 命令为现有命名空间打标签,例如 kubectl label namespace production pod-security.kubernetes.io/enforce=restricted pod-security.kubernetes.io/audit=restricted pod-security.kubernetes.io/warn=restricted --overwrite。迁移可分阶段:先 audit/warn 发现违规,再 enforce baseline,最后 enforce restricted。可用 kubectl label --dry-run=server --overwrite namespace my-namespace pod-security.kubernetes.io/enforce=restricted 做干跑测试。验证命令包括 kubectl get ns --show-labels | grep pod-security、kubectl run test-pod --image=nginx --namespace=production --dry-run=server、kubectl get events --field-selector reason=FailedCreate -A,以及 kubescape scan framework nsa --namespace production。

适用场景:生产命名空间采用 Restricted,一般工作负载采用 Baseline,系统组件采用 Privileged;审计现有工作负载;将合规要求落地为 securityContext。

限制:需要 Kubernetes 1.25+ 集群和 cluster-admin 权限,并理解 Linux capabilities 与 security context。资料未提供具体收费、价格或平台信息。