Podcast
Questions and Answers
Which of the following flags can be used to enable RBAC in the Kubernetes API server?
Which of the following flags can be used to enable RBAC in the Kubernetes API server?
RBAC allows you to define 'deny' rules for access control.
RBAC allows you to define 'deny' rules for access control.
False (B)
What are the four kinds of Kubernetes objects declared by the RBAC API?
What are the four kinds of Kubernetes objects declared by the RBAC API?
Role, ClusterRole, RoleBinding, ClusterRoleBinding
A ______ always sets permissions within a particular namespace, while a ______ is a non-namespaced resource.
A ______ always sets permissions within a particular namespace, while a ______ is a non-namespaced resource.
Signup and view all the answers
Match the following RBAC objects with their primary function:
Match the following RBAC objects with their primary function:
Signup and view all the answers
You can use kubectl to create and manage RBAC objects.
You can use kubectl to create and manage RBAC objects.
Signup and view all the answers
What is the purpose of a RoleBinding?
What is the purpose of a RoleBinding?
Signup and view all the answers
Which of these resources can be read by default in the 'core' API group?
Which of these resources can be read by default in the 'core' API group?
Signup and view all the answers
A RoleBinding can bind a role to groups, users, or ServiceAccounts.
A RoleBinding can bind a role to groups, users, or ServiceAccounts.
Signup and view all the answers
What is the prefix reserved for group names in Kubernetes?
What is the prefix reserved for group names in Kubernetes?
Signup and view all the answers
The API server automatically updates default ______ and ______ with any missing permissions and subjects.
The API server automatically updates default ______ and ______ with any missing permissions and subjects.
Signup and view all the answers
The command kubectl auth reconcile
is used to create and manage role bindings.
The command kubectl auth reconcile
is used to create and manage role bindings.
Signup and view all the answers
Which of the following commands would grant the permissions in the "view" ClusterRole to a service account named "myapp" in the namespace "acme" across the entire cluster?
Which of the following commands would grant the permissions in the "view" ClusterRole to a service account named "myapp" in the namespace "acme" across the entire cluster?
Signup and view all the answers
What is the purpose of bootstrapping initial roles and role bindings?
What is the purpose of bootstrapping initial roles and role bindings?
Signup and view all the answers
Default RBAC policies in Kubernetes v1.22 or later grant no permissions to service accounts outside the ______ namespace.
Default RBAC policies in Kubernetes v1.22 or later grant no permissions to service accounts outside the ______ namespace.
Signup and view all the answers
Which of the following is considered the most secure way to grant permissions to an application in Kubernetes?
Which of the following is considered the most secure way to grant permissions to an application in Kubernetes?
Signup and view all the answers
When running Kubernetes with both RBAC and ABAC authorizers, if RBAC denies a request, the ABAC authorizer will then be consulted.
When running Kubernetes with both RBAC and ABAC authorizers, if RBAC denies a request, the ABAC authorizer will then be consulted.
Signup and view all the answers
Which of the following is NOT a common way to grant permissions to ServiceAccounts?
Which of the following is NOT a common way to grant permissions to ServiceAccounts?
Signup and view all the answers
What is the purpose of the command kubectl create rolebinding myappnamespace-myapp-view-binding --clusterrole view --serviceaccount myappnamespace:myapp
?
What is the purpose of the command kubectl create rolebinding myappnamespace-myapp-view-binding --clusterrole view --serviceaccount myappnamespace:myapp
?
Signup and view all the answers
Match the following Kubernetes terms with their definitions:
Match the following Kubernetes terms with their definitions:
Signup and view all the answers
In order from most secure to least secure, the approaches to granting permissions to ServiceAccounts are: ______, grant a role to all service accounts in a namespace, grant a cluster-wide role to all service accounts, and grant super-user access to all service accounts.
In order from most secure to least secure, the approaches to granting permissions to ServiceAccounts are: ______, grant a role to all service accounts in a namespace, grant a cluster-wide role to all service accounts, and grant super-user access to all service accounts.
Signup and view all the answers
Kubernetes clusters created with Kubernetes v1.22 or later include write access to Endpoints in the aggregated "edit" and "admin" roles by default.
Kubernetes clusters created with Kubernetes v1.22 or later include write access to Endpoints in the aggregated "edit" and "admin" roles by default.
Signup and view all the answers
What is the primary benefit of using fine-grained role bindings?
What is the primary benefit of using fine-grained role bindings?
Signup and view all the answers
Which of the following is NOT a typical method for managing the transition from permissive ABAC policies to RBAC policies?
Which of the following is NOT a typical method for managing the transition from permissive ABAC policies to RBAC policies?
Signup and view all the answers
The command kubectl create rolebinding myappnamespace-myapp-view-binding --clusterrole view --serviceaccount myappnamespace:______
would grant the "view" ClusterRole permissions across the entire cluster to the service account "myapp" in the namespace "myappnamespace".
The command kubectl create rolebinding myappnamespace-myapp-view-binding --clusterrole view --serviceaccount myappnamespace:______
would grant the "view" ClusterRole permissions across the entire cluster to the service account "myapp" in the namespace "myappnamespace".
Signup and view all the answers
Kubernetes clusters created before v1.22 included write access to EndpointSlices in the aggregated "edit" and "admin" roles.
Kubernetes clusters created before v1.22 included write access to EndpointSlices in the aggregated "edit" and "admin" roles.
Signup and view all the answers
What is the significance of running the kube-apiserver with a log level of 5 or higher for the RBAC component?
What is the significance of running the kube-apiserver with a log level of 5 or higher for the RBAC component?
Signup and view all the answers
What is the prefix for group names in Kubernetes?
What is the prefix for group names in Kubernetes?
Signup and view all the answers
ServiceAccounts belong to groups with names prefixed with 'system:serviceaccounts:'.
ServiceAccounts belong to groups with names prefixed with 'system:serviceaccounts:'.
Signup and view all the answers
What are the two types of RBAC objects that bind a role to subjects?
What are the two types of RBAC objects that bind a role to subjects?
Signup and view all the answers
To prevent accidental modifications, the API server automatically updates default ______ and ______ with any missing permissions and subjects.
To prevent accidental modifications, the API server automatically updates default ______ and ______ with any missing permissions and subjects.
Signup and view all the answers
What flag can be used in the API server configuration to disable anonymous unauthenticated access?
What flag can be used in the API server configuration to disable anonymous unauthenticated access?
Signup and view all the answers
The 'system:node' role is essential for kubelet API access and should be used in modern Kubernetes deployments.
The 'system:node' role is essential for kubelet API access and should be used in modern Kubernetes deployments.
Signup and view all the answers
Name a system: prefixed ClusterRole that is specifically designed for the Kubernetes controller manager.
Name a system: prefixed ClusterRole that is specifically designed for the Kubernetes controller manager.
Signup and view all the answers
When the kube-controller-manager is started with the flag ______, each controller runs using a separate ServiceAccount.
When the kube-controller-manager is started with the flag ______, each controller runs using a separate ServiceAccount.
Signup and view all the answers
Which of the following labels is used to identify a ClusterRole that can be added to the 'admin', 'edit', or 'view' roles?
Which of the following labels is used to identify a ClusterRole that can be added to the 'admin', 'edit', or 'view' roles?
Signup and view all the answers
The 'edit' role in Kubernetes allows for read/write access to all resources, including the ability to create Roles and RoleBindings.
The 'edit' role in Kubernetes allows for read/write access to all resources, including the ability to create Roles and RoleBindings.
Signup and view all the answers
What resource does the 'admin' role NOT grant write access to?
What resource does the 'admin' role NOT grant write access to?
Signup and view all the answers
The 'view' role does not allow reading ______ as it enables access to secrets and ServiceAccount credentials.
The 'view' role does not allow reading ______ as it enables access to secrets and ServiceAccount credentials.
Signup and view all the answers
Match the following roles with their primary function:
Match the following roles with their primary function:
Signup and view all the answers
Which of the following statements regarding RoleBinding and ClusterRoleBinding is true?
Which of the following statements regarding RoleBinding and ClusterRoleBinding is true?
Signup and view all the answers
A RoleBinding can reference a ClusterRole and bind that ClusterRole to the namespace of the RoleBinding.
A RoleBinding can reference a ClusterRole and bind that ClusterRole to the namespace of the RoleBinding.
Signup and view all the answers
What is the purpose of the kubectl auth reconcile
command-line utility?
What is the purpose of the kubectl auth reconcile
command-line utility?
Signup and view all the answers
In Kubernetes, most resources are represented and accessed using a ______ representation of their object name.
In Kubernetes, most resources are represented and accessed using a ______ representation of their object name.
Signup and view all the answers
Match the following RBAC concepts with their definitions:
Match the following RBAC concepts with their definitions:
Signup and view all the answers
Which of the following is NOT a valid way to represent resources in an RBAC role?
Which of the following is NOT a valid way to represent resources in an RBAC role?
Signup and view all the answers
The resourceNames
list in an RBAC role can be used to restrict access to specific instances of a resource.
The resourceNames
list in an RBAC role can be used to restrict access to specific instances of a resource.
Signup and view all the answers
What is the purpose of the wildcard (*) symbol in RBAC roles?
What is the purpose of the wildcard (*) symbol in RBAC roles?
Signup and view all the answers
Which of the following statements regarding ClusterRole aggregation is true?
Which of the following statements regarding ClusterRole aggregation is true?
Signup and view all the answers
After creating a binding, its roleRef can be changed to reference a different role.
After creating a binding, its roleRef can be changed to reference a different role.
Signup and view all the answers
The ______ defines a label selector that a controller uses to match other ClusterRole objects that should be combined into the rules field of this one.
The ______ defines a label selector that a controller uses to match other ClusterRole objects that should be combined into the rules field of this one.
Signup and view all the answers
What is the principle of least privilege in the context of RBAC?
What is the principle of least privilege in the context of RBAC?
Signup and view all the answers
What is the purpose of the rules
section in a Role or ClusterRole object?
What is the purpose of the rules
section in a Role or ClusterRole object?
Signup and view all the answers
A RoleBinding with a namespace of "development" can grant cluster-wide read access for Secrets.
A RoleBinding with a namespace of "development" can grant cluster-wide read access for Secrets.
Signup and view all the answers
A ______ can be used to grant cluster-wide access, while a ______ is used to grant access within a specific namespace.
A ______ can be used to grant cluster-wide access, while a ______ is used to grant access within a specific namespace.
Signup and view all the answers
Which of the following statements accurately describes the difference between a RoleBinding and a ClusterRoleBinding?
Which of the following statements accurately describes the difference between a RoleBinding and a ClusterRoleBinding?
Signup and view all the answers
A RoleBinding can reference a ClusterRole, and bind that ClusterRole's permissions to the namespace of the RoleBinding.
A RoleBinding can reference a ClusterRole, and bind that ClusterRole's permissions to the namespace of the RoleBinding.
Signup and view all the answers
The name of a [BLANK] or [BLANK] object must be a valid path segment name.
The name of a [BLANK] or [BLANK] object must be a valid path segment name.
Signup and view all the answers
What is the primary purpose of the 'kubectl auth reconcile' command-line utility?
What is the primary purpose of the 'kubectl auth reconcile' command-line utility?
Signup and view all the answers
Match each Kubernetes resource with its corresponding subresource:
Match each Kubernetes resource with its corresponding subresource:
Signup and view all the answers
You can use the wildcard symbol '*' to refer to all current and future resources in a specific API group.
You can use the wildcard symbol '*' to refer to all current and future resources in a specific API group.
Signup and view all the answers
Which of the following statements BEST describes the principle of least privilege when applied to RBAC?
Which of the following statements BEST describes the principle of least privilege when applied to RBAC?
Signup and view all the answers
What is the mechanism used to aggregate several ClusterRoles into one combined ClusterRole?
What is the mechanism used to aggregate several ClusterRoles into one combined ClusterRole?
Signup and view all the answers
The default user-facing roles in Kubernetes leverage ClusterRole aggregation.
The default user-facing roles in Kubernetes leverage ClusterRole aggregation.
Signup and view all the answers
To allow a subject to read pods and also access the [BLANK] subresource for each of those pods, you write: rules: - apiGroups: [''] - resources: ['pods', 'pods/______'] - verbs: ['get', 'list', 'watch']
To allow a subject to read pods and also access the [BLANK] subresource for each of those pods, you write: rules: - apiGroups: [''] - resources: ['pods', 'pods/______'] - verbs: ['get', 'list', 'watch']
Signup and view all the answers
How can you create a new ClusterRole that adds rules to an existing aggregated ClusterRole, like 'monitoring'?
How can you create a new ClusterRole that adds rules to an existing aggregated ClusterRole, like 'monitoring'?
Signup and view all the answers
Explain the purpose of the 'resourceNames' list in an RBAC role.
Explain the purpose of the 'resourceNames' list in an RBAC role.
Signup and view all the answers
You can use a wildcard (*) symbol to refer to all current and future resources in a specific API group, but this approach can lead to overly permissive access to sensitive resources.
You can use a wildcard (*) symbol to refer to all current and future resources in a specific API group, but this approach can lead to overly permissive access to sensitive resources.
Signup and view all the answers
The [BLANK] principle should be employed while defining RBAC roles, ensuring only the necessary permissions are granted for workloads to function correctly.
The [BLANK] principle should be employed while defining RBAC roles, ensuring only the necessary permissions are granted for workloads to function correctly.
Signup and view all the answers
When using RBAC, which approach is generally considered the MOST secure way to grant permissions to an application running in Kubernetes?
When using RBAC, which approach is generally considered the MOST secure way to grant permissions to an application running in Kubernetes?
Signup and view all the answers
Describe a situation where ClusterRole aggregation would be useful for managing RBAC in a Kubernetes cluster.
Describe a situation where ClusterRole aggregation would be useful for managing RBAC in a Kubernetes cluster.
Signup and view all the answers
Flashcards
RBAC
RBAC
Role-based access control (RBAC) regulates access based on user roles.
Authorization Config
Authorization Config
Starts the API server with roles and permissions defined in RBAC.
RBAC Objects
RBAC Objects
Includes Role, ClusterRole, RoleBinding, and ClusterRoleBinding in Kubernetes.
Role vs ClusterRole
Role vs ClusterRole
Signup and view all the flashcards
RoleBinding
RoleBinding
Signup and view all the flashcards
ClusterRoleBinding
ClusterRoleBinding
Signup and view all the flashcards
Permission Model
Permission Model
Signup and view all the flashcards
Role Example
Role Example
Signup and view all the flashcards
Deployments in apps API
Deployments in apps API
Signup and view all the flashcards
Roles in Kubernetes
Roles in Kubernetes
Signup and view all the flashcards
ServiceAccount
ServiceAccount
Signup and view all the flashcards
Default ClusterRoles
Default ClusterRoles
Signup and view all the flashcards
Auto-reconciliation
Auto-reconciliation
Signup and view all the flashcards
ClusterRole
ClusterRole
Signup and view all the flashcards
API Server Configuration
API Server Configuration
Signup and view all the flashcards
Node authorizer
Node authorizer
Signup and view all the flashcards
RBAC API
RBAC API
Signup and view all the flashcards
Creating roles
Creating roles
Signup and view all the flashcards
NodeRestriction admission plugin
NodeRestriction admission plugin
Signup and view all the flashcards
Viewing permissions
Viewing permissions
Signup and view all the flashcards
RoleReference
RoleReference
Signup and view all the flashcards
Namespaces
Namespaces
Signup and view all the flashcards
pod-reader Role
pod-reader Role
Signup and view all the flashcards
Subject
Subject
Signup and view all the flashcards
Wildcard (*)
Wildcard (*)
Signup and view all the flashcards
AggregationRule
AggregationRule
Signup and view all the flashcards
NonResourceURLs
NonResourceURLs
Signup and view all the flashcards
RoleRef
RoleRef
Signup and view all the flashcards
ResourceNames
ResourceNames
Signup and view all the flashcards
Least Privilege Principle
Least Privilege Principle
Signup and view all the flashcards
Subresource
Subresource
Signup and view all the flashcards
Admin Role
Admin Role
Signup and view all the flashcards
View Role
View Role
Signup and view all the flashcards
Bootstrap Permissions
Bootstrap Permissions
Signup and view all the flashcards
Fine-Grained Role Bindings
Fine-Grained Role Bindings
Signup and view all the flashcards
Cluster-Wide Role
Cluster-Wide Role
Signup and view all the flashcards
Super-User Access
Super-User Access
Signup and view all the flashcards
Remove Extra Permissions
Remove Extra Permissions
Signup and view all the flashcards
Authorization Layers
Authorization Layers
Signup and view all the flashcards
ABAC Policies
ABAC Policies
Signup and view all the flashcards
Kubernetes v1.22 Change
Kubernetes v1.22 Change
Signup and view all the flashcards
Study Notes
Role-Based Access Control (RBAC) in Kubernetes
- RBAC is a method for controlling access to Kubernetes resources based on user roles.
- Authorization decisions are driven by the
rbac.authorization.k8s.io
API group. - RBAC policies are dynamically configurable via the Kubernetes API.
- Enabling RBAC involves starting the API server with the
--authorization-config
or--authorization-mode
flags, specifying a RBAC authorizer.
RBAC Objects
-
RBAC declares four object types:
- Role: Namespaced permissions
- ClusterRole: Cluster-wide permissions
- RoleBinding: Grants a role to a subject within a namespace
- ClusterRoleBinding: Grants a role to a subject cluster-wide
-
Roles and ClusterRoles contain permissions (additive).
-
Role permissions are namespace-specific, while ClusterRoles are cluster-wide.
-
Object names must be valid path segment names.
RoleBindings and ClusterRoleBindings
- RoleBindings grant roles to subjects within a namespace.
- They can reference Roles or ClusterRoles.
- RoleBindings specify subjects (users, groups, service accounts).
- ClusterRoleBindings grant roles to subjects cluster-wide.
- Cannot change the referenced Role/ClusterRole after creation; removal and recreation required.
Resource and Subresource References
- RBAC uses the same resource names as API endpoints.
- Subresources (e.g., Pod logs) are delimited with a slash.
- ResourceNames can be used to restrict access to individual resource instances.
- Wildcards (
*
) can be used for all resources, verbs, or API groups (use cautiously, least privilege principle).
ClusterRole Aggregation
- ClusterRoles can be aggregated to combine multiple ClusterRoles into one.
- Aggregation is triggered by an
aggregationRule
that uses a label selector. - Aggregated ClusterRoles dynamically incorporate new, matching ClusterRoles.
Default RBAC Policies
- Kubernetes includes default ClusterRoles and ClusterRoleBindings for core functionalities.
- Many are prefixed with
system:
. - These default objects are dynamically updated by the API server to account for missing permissions/subjects and newly released permissions.
- The update process can be disabled using an annotation.
- Some roles (e.g.,
cluster-admin
,admin
,edit
,view
) are user-facing.- Can be extended via ClusterRole aggregation for custom resource.
RBAC Principles and Considerations
- RBAC prevents privilege escalation by controlling role/binding changes.
- Only create/update roles if permissions are already granted or bind permission is granted.
- Auto-reconciliation adjusts default roles for API changes.
- Disabling auto-reconciliation prevents overwriting of manually updated roles.
Service Accounts and Permissions
- Service Accounts represent processes and applications.
- They often inherit from a default service account in the
kube-system
namespace. - Best practice for controlling access to applications/controllers.
- Fine-grained control is possible, but increased administration is required for multiple service accounts and roles.
Transitioning to RBAC
- Clusters using ABAC (Attribute-Based Access Control) can be transitioned.
- Running both RBAC and ABAC, then removing ABAC when RBAC works correctly is one method.
Important Notes
- Permissions are purely additive and there are no deny rules
- Permissions can be written to the core level in HTTP.
- Resources, and other components, must reference the exact name that appears on the relevant API endpoint URL.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
This quiz covers Role-Based Access Control (RBAC) in Kubernetes, focusing on its components such as Roles, ClusterRoles, RoleBindings, and ClusterRoleBindings. Learn how these elements manage access to resources based on user roles and understand the API configurations necessary for RBAC implementation.