Complete the code to create a RoleBinding that assigns the 'view' role to a user named 'alice' in the 'dev' namespace.
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: view-binding
namespace: dev
subjects:
- kind: User
name: alice
apiGroup: rbac.authorization.k8s.io
roleRef:
kind: [1]
name: view
apiGroup: rbac.authorization.k8s.ioThe RoleBinding must reference a Role in the same namespace. So, kind: Role is correct here.
Complete the code to create a ClusterRoleBinding that assigns the 'cluster-admin' ClusterRole to a group named 'admins'.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: admin-binding
subjects:
- kind: Group
name: admins
apiGroup: rbac.authorization.k8s.io
roleRef:
kind: [1]
name: cluster-admin
apiGroup: rbac.authorization.k8s.ioClusterRoleBindings must reference a ClusterRole because they grant permissions cluster-wide.
Fix the error in the RoleBinding that tries to assign a ClusterRole in a namespace.
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: edit-binding
namespace: test
subjects:
- kind: User
name: bob
apiGroup: rbac.authorization.k8s.io
roleRef:
kind: [1]
name: edit
apiGroup: rbac.authorization.k8s.ioRoleBindings in a namespace must reference a Role, not a ClusterRole. To assign a ClusterRole in a namespace, use a ClusterRoleBinding or a RoleBinding with proper roleRef.
Fill both blanks to create a RoleBinding that assigns the 'admin' Role to a ServiceAccount named 'deployer' in the 'prod' namespace.
apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: admin-binding namespace: prod subjects: - kind: [1] name: deployer namespace: prod apiGroup: rbac.authorization.k8s.io roleRef: kind: [2] name: admin apiGroup: rbac.authorization.k8s.io
The subject is a ServiceAccount and the roleRef kind is Role because this is a namespaced RoleBinding.
Fill all three blanks to create a ClusterRoleBinding that assigns the 'view' ClusterRole to a User named 'charlie' across the cluster.
apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: view-binding subjects: - kind: [1] name: charlie apiGroup: rbac.authorization.k8s.io roleRef: kind: [2] name: [3] apiGroup: rbac.authorization.k8s.io
The subject kind is User, the roleRef kind is ClusterRole, and the role name is view for a cluster-wide binding.