Authentication Kubernetes:如何让另一个人使用edit clusterRole权限访问Kubernetes群集?
我这样做:Authentication Kubernetes:如何让另一个人使用edit clusterRole权限访问Kubernetes群集?,authentication,kubernetes,Authentication,Kubernetes,我这样做: 我创建了一个服务帐户 我将编辑的~/.kube/config发送给想要访问集群的人,现在他可以列出pod,但不能将exec放入其中: 错误 (Forbidden): pods "pod-xxxxx-xxxx" is forbidden: User "system:serviceaccount:default:myname" cannot create resource "pods/exec" in API group &qu
~/.kube/config
发送给想要访问集群的人,现在他可以列出pod,但不能将exec放入其中:(Forbidden): pods "pod-xxxxx-xxxx" is forbidden: User "system:serviceaccount:default:myname" cannot create resource "pods/exec" in API group "" in the namespace "my-ns"
我想从一台非主控机器上实现这一点,它将主控~/.kube/config
复制到其中
谢谢您拥有的
角色绑定
正在将集群角色
绑定到用户
,而不是服务帐户
。该错误清楚地显示了ServiceAccount系统:ServiceAccount:default:myuser
,因此角色绑定应如下所示
cat <<EOF | kubectl create -f -
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: dev-access
namespace: my-ns
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: edit
subjects:
- kind: ServiceAccount
name: myuser
namespace: default
EOF
要验证servicecomport
myuser
的pods/exec
的特定权限,请使用下面的命令
kubectl auth can-i --list --as=system:serviceaccount:default:myuser
kubectl auth can-i create pods/exec --as=system:serviceaccount:default:myuser
sa对pod的权限为:``pods[][[get list watch]``您是否正在尝试从pod执行某些操作?默认情况下,这将使用服务帐户,您需要按照我在回答中的方式为服务帐户提供角色绑定。谢谢。我将主题类型更改为ServiceAccount,并从主题中删除了apiGroup:rbac.authorization.k8s.io。此外,我还向主题添加了“namespace:default”我遇到了一个问题,我在进入pod后几秒钟内就断开了与它的连接,我的互联网连接是稳定的。
kubectl auth can-i --list --as=system:serviceaccount:default:myuser
kubectl auth can-i create pods/exec --as=system:serviceaccount:default:myuser