In a ClusterRole Binding, the subjects and roleRef fields serve specific purposes:
subjects
- The
subjectsfield defines the entities (users, groups, or service accounts) that the ClusterRole is being granted to. - Each subject is specified with a
kind,name, and optionally anapiGroup. - Examples of
kindincludeUser,Group, orServiceAccount.
Example:
subjects:
- kind: User
name: cluster-admin
apiGroup: rbac.authorization.k8s.io
roleRef
- The
roleReffield specifies the ClusterRole that is being referenced by the ClusterRole Binding. - It includes the
kind(which should beClusterRole), thenameof the ClusterRole, and theapiGroupthat the role belongs to.
Example:
roleRef:
kind: ClusterRole
name: myapp-admin
apiGroup: rbac.authorization.k8s.io
Together, these fields define who has what permissions at the cluster level.
