Kubernetes
RBAC
rule verbs
cloud computing
container orchestration

List of Kubernetes RBAC rule verbs

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

Kubernetes Role-Based Access Control (RBAC) is an essential mechanism that governs how users, applications, or processes interact with the Kubernetes API server. It grants users permissions based on rules that define how they can interact with the resources within the cluster. Understanding RBAC verbs is crucial for efficiently defining access policies. These verbs specify the actions that can be performed on various Kubernetes resources.

Overview of Kubernetes RBAC

Kubernetes RBAC uses roles and role bindings to permit access to resources. Roles include a set of rules composed of verbs, resources, resource names, and namespaces. Role bindings assign these roles to users or groups, thus ensuring that only authorized entities can perform specified actions.

RBAC Rule Verbs

The verbs in RBAC define the operations that the subjects can perform. Here's a breakdown of the primary RBAC verbs:

1. get

The get verb allows users to retrieve information about a specific resource, such as Pods, Services, ConfigMaps, etc. When a user or service account is granted this permission, they can perform kubectl get <resource> to view the details of a resource.

Example:

yaml
1rules:
2- apiGroups: [""]
3  resources: ["pods"]
4  verbs: ["get"]

2. list

The list verb is used when you need to get a list of resources of a particular type. With this access, kubectl get <resource> can be used with or without additional filters.

Example:

yaml
1rules:
2- apiGroups: [""]
3  resources: ["pods"]
4  verbs: ["list"]

3. watch

The watch verb allows monitoring of changes to resources. This is useful for observing the state of resources over time without repeatedly polling.

Example:

yaml
1rules:
2- apiGroups: [""]
3  resources: ["pods"]
4  verbs: ["watch"]

4. create

The create verb permits the creation of new resources within the cluster. This enables operations like deploying a new Pod or Service.

Example:

yaml
1rules:
2- apiGroups: [""]
3  resources: ["pods"]
4  verbs: ["create"]

5. update

The update verb allows modifications to existing resources. This is necessary for changing configurations or updating items like Secrets and ConfigMaps.

Example:

yaml
1rules:
2- apiGroups: [""]
3  resources: ["pods"]
4  verbs: ["update"]

6. patch

The patch verb lets users apply partial updates to resources. Unlike update, patch can be used to modify only a subset of fields within a resource.

Example:

yaml
1rules:
2- apiGroups: [""]
3  resources: ["pods"]
4  verbs: ["patch"]

7. delete

The delete verb provides the ability to remove resources from the cluster. It's critical to use this permission judiciously as it impacts resource availability.

Example:

yaml
1rules:
2- apiGroups: [""]
3  resources: ["pods"]
4  verbs: ["delete"]

8. deletecollection

This is an extension of the delete verb, allowing the deletion of a collection of resources. Typically used to clear resources based on label selectors.

Example:

yaml
1rules:
2- apiGroups: [""]
3  resources: ["pods"]
4  verbs: ["deletecollection"]

9. impersonate

The impersonate verb allows a user to assume another user's credentials. This is often used for debugging or operational purposes and should be tightly controlled.

Example:

yaml
1rules:
2- apiGroups: [""]
3  resources: ["users"]
4  verbs: ["impersonate"]

Summary Table

To summarize the key functionalities of each verb, consider the following table:

VerbDescription
getRetrieve a specific resource's information.
listList all resources of a particular type.
watchObserve changes of resources over time.
createAdd new resources to the cluster.
updateModify existing resources completely.
patchPartially modify existing resources.
deleteRemove resources.
deletecollectionRemove a collection of resources.
impersonateAct as another user for access control purposes.

Conclusion

Kubernetes RBAC verbs offer a fine-grained way to define what actions can be performed on resources within a cluster. By structuring RBAC policies using these verbs, organizations can ensure that their Kubernetes environment adheres to security best practices. Remember, the principle of least privilege should guide the assignment of permissions, granting only what is necessary for users and services to function effectively.


Course illustration
Course illustration

All Rights Reserved.