我在命名空間 xyz 中創建了一個服務帳戶“serviceacc”,并為其授予了所需的權限。但它無法列出豆莢。這是我遵循的步驟。
$kubectl create namespace xyz
$kubectl apply -f objects.yaml
objects.yaml 的內容在哪里
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: xyz
name: listpodser
rules:
- apiGroups: [""]
resources: ["pod"]
verbs: ["get", "list"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: xyz
name: service-listpodser
subjects:
- kind: ServiceAccount
name: serviceacc
apiGroup: ""
roleRef:
kind: Role
name: listpodser
apiGroup: ""
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: serviceacc
namespace: xyz
然后我檢查了服務帳戶是否有權列出 pod:
$ kubectl auth can-i get pods --namespace xyz --as system:serviceaccount:xyz:serviceacc
no
$ kubectl auth can-i list pods --namespace xyz --as system:serviceaccount:xyz:serviceacc
no
正如我們從上面命令的輸出中看到的,它無法獲取/列出 pod。
uj5u.com熱心網友回復:
簡單的命名混亂。在資源串列中使用pods而不是pod。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/347546.html
標籤:Kubernetes Kubernetes-pod 红细胞
