I'm trying to create a ClusterRoleBinding for an exercise in a course with the YAML file below:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: nodes-admin
rules:
- apiGroups: [""]
resources:
- nodes
verbs:
- get
- list
- create
- delete
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: nodes-admin
subjects:
- apiGroup: rbac.authorization.k8s.io
kind: User
name: user1387
roleRef:
- apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: nodes-admin
Yet it keeps failing with:
Error from server (BadRequest): error when creating "clusterrole.yaml": ClusterRoleBinding in version "v1" cannot be handled as a ClusterRoleBinding: json: cannot unmarshal array into Go struct field ClusterRoleBinding.roleRef of type v1.RoleRef
I investigate for some time but couldn't really understand what is going on. What's the error?