Minikube v1.13.2中使用聚合功能创建ClusterRole失败,请求排查
问题原因及解决方法
你的错误出在YAML缩进格式上:在child-clusterrole的aggregationRule配置中,rbac.authorization.k8s.io/aggregate-to-child-clusterrole: "true"这个标签没有缩进,它应该是matchLabels的子属性,而非和matchLabels同级。
修正后的YAML文件如下:
apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: parent-clusterrole labels: rbac.authorization.k8s.io/aggregate-to-child-clusterrole: "true" rules: - apiGroups: [""] resources: ["nodes"] verbs: ["get", "list"] --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: child-clusterrole aggregationRule: clusterRoleSelectors: - matchLabels: rbac.authorization.k8s.io/aggregate-to-child-clusterrole: "true" rules: []
报错原因说明
Kubernetes对YAML格式的缩进要求严格,你原配置里的标签字段和matchLabels处于同一层级,被解析成了clusterRoleSelectors的直接属性,但Kubernetes的ClusterRole结构体中不存在该字段,因此触发了"unknown field"的解析错误。
内容的提问来源于stack exchange,提问作者diggervvv
相关产品推荐
相关产品推荐

