gpt4 book ai didi

kubernetes - securityContext.privileged : Forbidden: disallowed by cluster policy

转载 作者:行者123 更新时间:2023-12-02 11:31:24 33 4
gpt4 key购买 nike

我无法启动需要特权安全上下文的 pod。Pod 安全策略:

apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
name: pod-security-policy
spec:
privileged: true
allowPrivilegeEscalation: true
readOnlyRootFilesystem: false
allowedCapabilities:
- '*'
allowedProcMountTypes:
- '*'
allowedUnsafeSysctls:
- '*'
volumes:
- '*'
hostPorts:
- min: 0
max: 65535
hostIPC: true
hostPID: true
hostNetwork: true
runAsUser:
rule: 'RunAsAny'
seLinux:
rule: 'RunAsAny'
supplementalGroups:
rule: 'RunAsAny'
fsGroup:
rule: 'RunAsAny'

集群角色:

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: privileged
rules:
- apiGroups:
- '*'
resourceNames:
- pod-security-policy
resources:
- '*'
verbs:
- '*'

集群角色绑定(bind):

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: privileged-role-binding
roleRef:
kind: ClusterRole
name: privileged
apiGroup: rbac.authorization.k8s.io
subjects:
# Authorize specific service accounts:
- kind: ServiceAccount
name: default
namespace: kube-system
- kind: ServiceAccount
name: default
namespace: default
- kind: Group
# apiGroup: rbac.authorization.k8s.io
name: system:authenticated
# Authorize specific users (not recommended):
- kind: User
apiGroup: rbac.authorization.k8s.io
name: admin
$ k auth can-i use psp/pod-security-policy
Warning: resource 'podsecuritypolicies' is not namespace scoped in group 'extensions'
yes
$ k apply -f daemonset.yml
The DaemonSet "daemonset" is invalid: spec.template.spec.containers[0].securityContext.privileged: Forbidden: disallowed by cluster policy

不确定是否需要,但我已将 PodSecurityContext 添加到 args/kube-apiserver --enable-admission-plugins

我们将不胜感激任何建议和见解。 WTF 是这样的:“看起来您的帖子主要是代码;请添加更多详细信息。” !?!

最佳答案

刚刚检查了您的 Pod 安全性 Policy我当前环境的配置:

kubeadm version: &version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.1"
Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.1"
Server Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.1"

我假设您已经包含了 Privileged securityContext在当前的 DaemonSet list 文件中。

securityContext:
privileged: true

为了允许 Kubernetes API 生成 Privileged您可能必须设置的容器 kube-apiserver标记 --allow-privilegedtrue 值。

--allow-privileged=true

因此,一旦我不允许使用 false 选项运行特权容器,我在我的 k8s 集群中就会面临同样的问题。

关于kubernetes - securityContext.privileged : Forbidden: disallowed by cluster policy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57156922/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com