kubernetes 我不明白为什么没有创建

dzhpxtsq  于 2023-10-17  发布在  Kubernetes
关注(0)|答案(1)|浏览(173)

我在研究kubernetes集群的授权。
我现在用的是minikube集群,版本是v1.13.2。
我正在尝试创建具有聚合功能的CumberRole,以便子CumberRole可以接收父CumberRole的规则。
这是我的.yaml文件的内容。

  1. apiVersion: rbac.authorization.k8s.io/v1
  2. kind: ClusterRole
  3. metadata:
  4. name: parent-clusterrole
  5. labels:
  6. rbac.authorization.k8s.io/aggregate-to-child-clusterrole: "true"
  7. rules:
  8. - apiGroups: [""]
  9. resources: ["nodes"]
  10. verbs: ["get", "list"]
  11. ---
  12. apiVersion: rbac.authorization.k8s.io/v1
  13. kind: ClusterRole
  14. metadata:
  15. name: child-clusterrole
  16. aggregationRule:
  17. clusterRoleSelectors:
  18. - matchLabels:
  19. rbac.authorization.k8s.io/aggregate-to-child-clusterrole: "true"
  20. rules: []

当我尝试使用kubectl apply -f {file-name}创建资源时,我收到了下面的结果。

  1. clusterrole.rbac.authorization.k8s.io/parent-clusterrole created
  2. Error from server (BadRequest): error when creating "clusterrole-aggregation.yaml": ClusterRole in version "v1" cannot be handled as a ClusterRole: strict decoding error: unknown field "aggregationRule.clusterRoleSelectors[0].rbac.authorization.k8s.io/aggregate-to-child-clusterrole"

是不是有什么错误的东西我抓不到?

bwntbbo3

bwntbbo31#

试试看:

  1. ...
  2. aggregationRule:
  3. clusterRoleSelectors:
  4. - matchLabels:
  5. rbac.authorization.k8s.io/aggregate-to-child-clusterrole: "true" # <-- ident with 2 spaces required

相关问题