我正在尝试从一个监听 webhook 并运行 tkn 的 continer 中创建一个 PipeLineRun/PipeLineRun - 但我需要 RBAC 权限。我尝试将角色绑定角色:tekton-pipelines-controller 设置为默认服务帐户:
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: webhook
namespace: tekton-pipelines
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: tekton-pipelines-controller
subjects:
- kind: ServiceAccount
name: default
namespace: default
但我仍然不能这样做:
kubectl auth can-i create taskrun -n default --as=system:serviceaccount:default:default
no
我还尝试为资源创建角色:
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: webhook-create-taskrun
namespace: tekton-pipelines
rules:
- apiGroups: ["tekton.dev/v1beta1"]
resources: ["taskrun"]
verbs: ["get", "create", "list"]
# [ delete deletecollection get list patch create update watch ]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: webhook-create-taskrun
namespace: tekton-pipelines
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: webhook-create-taskrun
subjects:
- kind: ServiceAccount
name: default
namespace: default
不幸的是仍然无法访问
我还在 tekton-pipelines 的所有 RoleBindings 中查找了任何“taskrun”,但一无所获
ns := "tekton-pipelines"
rbacClientSet := clientSet.RbacV1()
rolebindings, _ := rbacClientSet.RoleBindings(ns).List(context.Background(), metav1.ListOptions{})
for _, element := range rolebindings.Items {
fmt.Println(element)
}