Mat*_*rix 7 kubernetes azure-aks podsecuritypolicy
我有带有 kubernetes 版本 1.23 的 AKS。我想通过通过AdmissionConfiguration进行设置来激活集群级别的podsecurity,如下所述:
https://kubernetes.io/docs/tasks/configure-pod-container/enforce-standards-admission-controller/
正如我所读到的,“PodSecurity 功能门”在 kubernetes 版本 1.23 上默认启用。我已经根据链接上显示的配置创建了一个 yaml 文件,但是当我应用它时,出现以下错误:
$ k create -f podsecurity.yaml
error: unable to recognize "podsecurity.yaml": no matches for kind "AdmissionConfiguration" in version "apiserver.config.k8s.io/v1"
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.5",
GitCommit:"c285e781331a3785a7f436042c65c5641ce8a9e9", GitTreeState:"clean", BuildDate:"2022-03-16T15:58:47Z", GoVersion:"go1.17.8", Compiler:"gc", Platform:"windows/amd64"}
Server Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.5",
GitCommit:"8211ae4d6757c3fedc53cd740d163ef65287276a", GitTreeState:"clean", BuildDate:"2022-03-31T20:28:03Z", GoVersion:"go1.17.8", Compiler:"gc", Platform:"linux/amd64"}
Run Code Online (Sandbox Code Playgroud)
我用谷歌搜索了很多,但找不到解决方案或它导致的原因。
如果有人可以提供帮助,我将不胜感激。
我可以在名称空间级别激活它,如下所示: https: //kubernetes.io/docs/tutorials/security/ns-level-pss/ 通过在名称空间下添加标签,但是我想在集群级别激活它但它不起作用。
这是因为管理配置不是要在 Kubernetes 集群内部应用的文件。
它是一个必须提供给 API 服务器的静态文件。
如果您的 Kubernetes 集群由 Clouder 管理,并且您无法直接访问 api 服务器,则可以在集群中使用pod 安全准入 Webhook 。
它的安装非常简单并且运行良好。
这样您就可以编辑包含集群范围配置的配置映射。
apiVersion: v1
kind: ConfigMap
metadata:
name: pod-security-webhook
namespace: pod-security-webhook
data:
podsecurityconfiguration.yaml: |
apiVersion: pod-security.admission.config.k8s.io/v1beta1
kind: PodSecurityConfiguration
defaults:
enforce: "restricted"
enforce-version: "latest"
audit: "restricted"
audit-version: "latest"
warn: "restricted"
warn-version: "latest"
exemptions:
# Array of authenticated usernames to exempt.
usernames: []
# Array of runtime class names to exempt.
runtimeClasses: []
# Array of namespaces to exempt.
namespaces: ["kube-system","policy-test1"]
Run Code Online (Sandbox Code Playgroud)
有关更多信息,我发现 EKS 文档非常有用:https://aws.github.io/aws-eks-best-practices/security/docs/pods/
您还应该注意,命名空间标签将优先于集群范围的配置。
| 归档时间: |
|
| 查看次数: |
1440 次 |
| 最近记录: |