0
0
Kubernetesdevops~10 mins

RoleBindings and ClusterRoleBindings in Kubernetes - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a RoleBinding that assigns the 'view' role to a user named 'alice' in the 'dev' namespace.

Kubernetes
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.io
Drag options to blanks, or click blank then click option'
AClusterRole
BRole
CServiceAccount
DUser
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ClusterRole' as kind in a namespaced RoleBinding without understanding scope.
Confusing 'User' or 'ServiceAccount' as roleRef kind.
2fill in blank
medium

Complete the code to create a ClusterRoleBinding that assigns the 'cluster-admin' ClusterRole to a group named 'admins'.

Kubernetes
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.io
Drag options to blanks, or click blank then click option'
AClusterRole
BRole
CUser
DServiceAccount
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Role' as kind in a ClusterRoleBinding.
Confusing subject kinds with roleRef kinds.
3fill in blank
hard

Fix the error in the RoleBinding that tries to assign a ClusterRole in a namespace.

Kubernetes
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.io
Drag options to blanks, or click blank then click option'
AUser
BClusterRole
CServiceAccount
DRole
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ClusterRole' as kind in a RoleBinding without understanding scope.
Confusing subject kind with roleRef kind.
4fill in blank
hard

Fill both blanks to create a RoleBinding that assigns the 'admin' Role to a ServiceAccount named 'deployer' in the 'prod' namespace.

Kubernetes
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
Drag options to blanks, or click blank then click option'
AServiceAccount
BUser
CRole
DClusterRole
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'User' as subject kind when the subject is a ServiceAccount.
Using 'ClusterRole' as roleRef kind in a RoleBinding.
5fill in blank
hard

Fill all three blanks to create a ClusterRoleBinding that assigns the 'view' ClusterRole to a User named 'charlie' across the cluster.

Kubernetes
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
Drag options to blanks, or click blank then click option'
AUser
BClusterRole
Cview
DRole
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Role' instead of 'ClusterRole' in roleRef kind.
Using 'Group' or 'ServiceAccount' instead of 'User' as subject kind.