Quiz Module 9 - Security and RBAC
Instructions
This quiz contains 30 multiple-choice questions.
Question 1
What does RBAC stand for in Kubernetes?
See explanation
Correct answer: Role-Based Access Control
Explanation: RBAC is the Kubernetes authorization mechanism that controls who can do what in the cluster through roles and bindings.
Question 2
What is a Role in RBAC?
See explanation
Correct answer: A collection of permissions that applies to a specific namespace
Explanation: A Role defines a set of permissions (verbs) on resources in a specific namespace. A ClusterRole applies to the entire cluster.
Question 3
What is a RoleBinding?
See explanation
Correct answer: A resource that binds a Role to a user, group, or ServiceAccount in a namespace
Explanation: A RoleBinding associates a Role (or ClusterRole) with subjects (users, groups, ServiceAccounts) in a specific namespace.
Question 4
What is the difference between a Role and a ClusterRole?
See explanation
Correct answer: A Role applies to a namespace, a ClusterRole applies to the entire cluster
Explanation: Roles are limited to a namespace, while ClusterRoles can define permissions on cluster-level resources (nodes, PVs, etc.).
Question 5
What is a ServiceAccount?
See explanation
Correct answer: An identity for Pods running in the cluster
Explanation: A ServiceAccount provides an identity for Pods, enabling authentication and authorization when accessing the API Server.
Question 6
What are the main verbs (actions) in RBAC?
See explanation
Correct answer: get, list, create, update, patch, delete, watch
Explanation: The main verbs in RBAC are get (read an object), list, create, update, patch (modify), delete, and watch (monitor changes).
Question 7
What is the command to view Roles?
See explanation
Correct answer: kubectl get roles
Explanation: kubectl get roles displays all Roles in the current namespace. Use -A for all namespaces.
Question 8
What is a ClusterRoleBinding?
See explanation
Correct answer: A resource that binds a ClusterRole to a user, group, or ServiceAccount at the cluster level
Explanation: A ClusterRoleBinding associates a ClusterRole with subjects at the cluster level, granting them permissions across the entire cluster.
Question 9
What is the command to test a user's permissions?
See explanation
Correct answer: kubectl auth can-i [verb] [resource] --as=[user] or kubectl auth can-i --list
Explanation: kubectl auth can-i allows you to check if a user can perform a specific action. --list displays all permissions.
Question 10
What is a Pod Security Standard (PSS)?
See explanation
Correct answer: Predefined security policies (privileged, baseline, restricted) for Pods
Explanation: Pod Security Standards define three levels of security for Pods: privileged (everything allowed), baseline (minimal restrictions), and restricted (maximum restrictions).
Question 11
What is the command to view ServiceAccounts?
See explanation
Correct answer: kubectl get serviceaccounts
Explanation: kubectl get serviceaccounts (or sa) displays all ServiceAccounts in the current namespace.
Question 12
What is a Network Policy?
See explanation
Correct answer: A resource that defines network communication rules between Pods
Explanation: Network Policies act as a cluster-level firewall, controlling inbound and outbound traffic to Pods based on selectors.
Question 13
What is the difference between a RoleBinding and a ClusterRoleBinding?
See explanation
Correct answer: RoleBinding binds a Role in a namespace, ClusterRoleBinding binds a ClusterRole at the cluster level
Explanation: RoleBindings are limited to a namespace, while ClusterRoleBindings apply to the entire cluster.
Question 14
What is an imagePullSecret?
See explanation
Correct answer: A Secret used by a Pod to authenticate to a private Docker registry
Explanation: imagePullSecrets allow Pods to pull images from private registries by providing authentication credentials.
Question 15
What is the command to view ClusterRoles?
See explanation
Correct answer: kubectl get clusterroles
Explanation: kubectl get clusterroles displays all ClusterRoles that apply to the entire cluster.
Question 16
What is the principle of least privilege in RBAC?
See explanation
Correct answer: Grant only the minimal permissions necessary to perform a task
Explanation: The principle of least privilege is a security best practice that involves granting only the strictly necessary permissions, reducing the attack surface.
Question 17
What is the command to view RoleBindings?
See explanation
Correct answer: kubectl get rolebindings
Explanation: kubectl get rolebindings (or rb) displays all RoleBindings in the current namespace.
Question 18
What is a Pod Security Admission (PSA)?
See explanation
Correct answer: An Admission Controller that enforces Pod Security Standards on Pods
Explanation: Pod Security Admission is a built-in Admission Controller that automatically enforces Pod Security Standards (privileged, baseline, restricted) on Pods.
Question 19
What is the difference between allow, audit, and warn in Pod Security Standards?
See explanation
Correct answer: allow permits, audit logs violations, warn warns but permits
Explanation: allow permits compliant Pods, audit logs violations in the logs, warn displays a warning but still permits.
Question 20
What is a Network Policy with policyTypes: Ingress?
See explanation
Correct answer: A Network Policy that controls only incoming traffic to selected Pods
Explanation: policyTypes defines which types of traffic are controlled: Ingress (incoming), Egress (outgoing), or both.
Question 21
What is the command to create a ServiceAccount?
See explanation
Correct answer: kubectl create serviceaccount [name]
Explanation: kubectl create serviceaccount creates a new ServiceAccount in the current namespace.
Question 22
What is a Role with resourceNames?
See explanation
Correct answer: A Role that limits permissions to specific resources by name
Explanation: resourceNames allows restricting permissions to specific resources by their name, offering granular control.
Question 23
What is the best practice for ServiceAccounts?
See explanation
Correct answer: Create a dedicated ServiceAccount for each application with minimal permissions
Explanation: Each application should have its own ServiceAccount with only the necessary permissions, following the principle of least privilege.
Question 24
What is a Network Policy with from and to?
See explanation
Correct answer: A Network Policy that specifies allowed sources (from) and destinations (to) for traffic
Explanation: from defines allowed sources for incoming traffic, to defines allowed destinations for outgoing traffic.
Question 25
What is the command to view ClusterRoleBindings?
See explanation
Correct answer: kubectl get clusterrolebindings
Explanation: kubectl get clusterrolebindings displays all ClusterRoleBindings that apply to the entire cluster.
Question 26
What is a Role with apiGroups?
See explanation
Correct answer: A Role that specifies the Kubernetes API groups to which the permissions apply
Explanation: apiGroups allows specifying which API groups are concerned (e.g., "", "apps", "networking.k8s.io").
Question 27
What is the difference between a Network Policy with and without rules?
See explanation
Correct answer: Without rules, all traffic is blocked. With rules, only specified traffic is allowed.
Explanation: By default, Network Policies block all traffic. Rules explicitly define which traffic is allowed (whitelist approach).
Question 28
What is a Role with verbs: ["*"]?
See explanation
Correct answer: A Role that grants all actions (get, list, create, update, patch, delete, watch)
Explanation: The wildcard "*" in verbs grants all possible actions on the specified resources, to be used with caution.
Question 29
What is the best practice for Network Policies?
See explanation
Correct answer: Apply the principle of least privilege, allowing only necessary traffic
Explanation: Network Policies should follow the principle of least privilege, allowing only strictly necessary traffic between Pods.
Question 30
What is the command to view a ServiceAccount's permissions?
See explanation
Correct answer: kubectl describe serviceaccount [name] and kubectl get rolebindings,clusterrolebindings to see the bindings
Explanation: To view a ServiceAccount's permissions, examine the RoleBindings and ClusterRoleBindings that reference it, then the associated Roles/ClusterRoles.
Quiz Result
Congratulations on completing the Module 9 quiz!
Score:
- 25-30 correct answers: Excellent! You master security and RBAC.
- 20-24 correct answers: Very good! Review the concepts where you had difficulties.
- 15-19 correct answers: Good! Review the chapters on RBAC and security.
- Less than 15: Recommended to review the module before continuing.
Quiz created on: December 2024