【发布时间】:2021-02-28 03:26:28
【问题描述】:
我正在尝试在 AWS EKS 集群中创建命名空间并不断收到错误消息。
我可以使用默认命名空间做任何我想做的事情,但是当我尝试创建一个新的命名空间名称时,我被禁止了。
这一定是我对用户“thera-eks”所做的错误。 也许是角色绑定?
看起来我给了角色访问所有内容的权限,因为在规则中我给了它 * 通配符。
我使用的命令是-
kubectl create namespace ernie
我得到的错误是 -
Error from server (Forbidden): namespaces is forbidden: User "thera-eks" cannot create resource "namespaces" in API group "" at the cluster scope
我的 role.yaml 是:
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: full_access
rules:
- apiGroups: ["*"]
resources: ["*"]
verbs: ["*"]
我的 rolebinding.yaml 是:
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: full_access_role_binding
subjects:
- kind: User
name: thera-eks
apiGroup: rbac.authorization.k8s.io
roleRef:
kind: Role
name: full_access
apiGroup: rbac.authorization.k8s.io
aws-auth 配置映射是:
data:
mapRoles: |
- groups:
- system:bootstrappers
- system:nodes
rolearn: arn:aws:iam::9967xxxxxxxx:role/eksctl-ops-nodegroup-linux-ng-sys-NodeInstanceRole-346VJPTOXI7L
username: system:node:{{EC2PrivateDNSName}}
- groups:
- eks-role
- system:master
rolearn: arn:aws:iam::9967xxxxxxxx:role/thera-eks
username: thera-eks
mapUsers: |
- userarn: arn:aws:iam::9967xxxxxxxx:user/test-ecr
username: test-ecr
groups:
- eks-role
角色“thera-eks”的 AWS IAM 权限 JSON 是 -
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ecr:BatchGetImage",
"ecr:BatchCheckLayerAvailability",
"ecr:CompleteLayerUpload",
"ecr:DescribeImages",
"ecr:DescribeRepositories",
"ecr:GetDownloadUrlForLayer",
"ecr:InitiateLayerUpload",
"ecr:ListImages",
"ecr:PutImage",
"ecr:UploadLayerPart",
"ecr:GetAuthorizationToken"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"eks:*",
"iam:ListRoles",
"sts:AssumeRole"
],
"Resource": "*"
}
]
}
【问题讨论】:
-
您创建了一个
Role,但Role仅适用于命名空间的上下文——ClusterRole是跨越命名空间的东西(因此将能够自己创建命名空间)
标签: kubernetes kubectl amazon-eks