iaq*_*obe 5 gitlab-ci kubernetes
我正在运行一个创建 kubernetes 命名空间的管道,但是当我运行它时,我得到:
Error from server (Forbidden): namespaces is forbidden: User "system:serviceaccount:gitlab-runner:default" cannot create resource "namespaces" in API group "" at the cluster scope
Run Code Online (Sandbox Code Playgroud)
我创建了 aClusterRole
和 a来允许命名空间中的ClusterRoleBinding
服务用户使用以下命令创建命名空间:default
gitlab-runner
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: modify-namespace
rules:
- apiGroups: [""]
resources:
- namespace
verbs:
- create
Run Code Online (Sandbox Code Playgroud)
和:
ind: ClusterRoleBinding
metadata:
name: modify-namespace-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: modify-namespace
subjects:
- kind: ServiceAccount
name: default
namespace: gitlab-runner
Run Code Online (Sandbox Code Playgroud)
但这给了我同样的错误。我究竟做错了什么?
""
. 因为 [""] 将是 apiGroups 需要字符串的数组。resources
它namespaces
不应该是namespace
因为:kubectl api-resources | grep 'namespace\|NAME'
NAME SHORTNAMES APIVERSION NAMESPACED KIND
namespaces ns v1 false Namespace
Run Code Online (Sandbox Code Playgroud)
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: modify-namespace
rules:
- apiGroups: ""
resources:
- namespaces
verbs:
- create
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
19709 次 |
最近记录: |