Thought leadership from the most innovative tech companies, all in one place.

Setting up Kubernetes RBAC in Amazon EKS

What Is Role-Based Access Control (RBAC)?

To understand Kubernetes RBAC, it's important to first understand the concept of Role-Based Access Control (RBAC). RBAC is a method used to restrict system access to authorized users.

In RBAC, access decisions are based on the roles that individual users assume in an organization. For instance, an IT manager might have different access rights compared to a software developer. RBAC eliminates the need to assign permissions to each user individually, thus simplifying the access control process.

When it comes to Kubernetes, RBAC is a crucial security feature. It enables administrators to dynamically configure policies through the Kubernetes API, allowing them to control who can access specific resources and how they can interact with them. Kubernetes RBAC ensures that only authorized users can perform certain actions, thereby enhancing the security of your Kubernetes environment.

Core Components of Kubernetes RBAC


In Kubernetes RBAC, a Role is an object that defines a set of permissions. These permissions specify the operations (like read, write, or update) that can be performed on various resources within a Namespace. For instance, a Role can be created to allow users to read Pods in a specific Namespace.

Roles are defined in YAML format and include information such as the API group, the resource type, and the operations that are permitted. They play a crucial role in defining the level of access a user has in a given Namespace.


While Roles are Namespace-specific, ClusterRoles are not confined to any specific Namespace. A ClusterRole is essentially a Role that applies to the entire cluster. This means that when you create a ClusterRole, it defines permissions on resources across all Namespaces in your Kubernetes cluster.

ClusterRoles are particularly useful for cluster-wide tasks. For instance, you can create a ClusterRole that allows users to read Nodes, a resource that is not confined to any Namespace.


RoleBindings is another critical component of Kubernetes RBAC. A RoleBinding is an object that grants the permissions defined in a Role to a user or a group of users. In other words, RoleBindings act as a bridge between Roles and users.

RoleBindings are also Namespace-specific. When you create a RoleBinding, you need to specify the Role that it refers to and the user (or users) that the Role's permissions are granted to.


ClusterRoleBindings function similarly to RoleBindings, but they are not confined to a specific Namespace. A ClusterRoleBinding grants the permissions defined in a ClusterRole to a user or a group of users across all Namespaces in the cluster.

ClusterRoleBindings streamline the process of granting cluster-wide permissions. For instance, you can create a ClusterRoleBinding that grants a user the authority to read the status of Nodes across the entire cluster.

What Is Amazon EKS?

Having understood the core components of Kubernetes RBAC, let's now shift our focus to Amazon EKS. Amazon Elastic Kubernetes Service (EKS) is a fully managed service that allows you to run Kubernetes on AWS without the need to install, operate, and maintain your own Kubernetes control plane.

Amazon EKS provides a high degree of flexibility and scalability. It lets you deploy, scale, and manage containerized applications easily and efficiently. Moreover, it seamlessly integrates with other AWS services, allowing you to leverage features like automated scaling, load balancing, and robust security.

In the context of Kubernetes RBAC, Amazon EKS provides an additional layer of access control. It allows you to manage access to your Kubernetes API server, ensuring that only authorized AWS IAM users and roles can interact with your Kubernetes resources.

EKS leverages Kubernetes RBAC to provide fine-grained access control. It allows you to create Roles and RoleBindings (or ClusterRoles and ClusterRoleBindings) to control who can access your Kubernetes resources and what actions they can perform. This way, you can ensure that your Kubernetes environment remains secure and well-managed.

How Amazon EKS Handles RBAC

The backbone of Kubernetes RBAC in EKS is the AWS Identity and Access Management (IAM). AWS IAM allows you to securely control access to your AWS services and resources. It helps you create and manage AWS users and groups and use permissions to allow and deny their access to AWS resources. EKS leverages these IAM roles and policies to manage access to the Kubernetes API server.

In EKS, Kubernetes RBAC is enabled by default, and users are authenticated through IAM. This means that when you create an EKS cluster, an IAM role is created that provides permissions for the Kubernetes control plane to make calls to AWS API operations on your behalf. This role is linked to the Kubernetes RBAC through a ConfigMap, allowing Kubernetes to assign roles and permissions to IAM users and roles.

Implementing Kubernetes RBAC in Amazon EKS

Implementing Kubernetes RBAC in Amazon EKS involves setting up an EKS cluster, defining Kubernetes Roles and ClusterRoles, defining RoleBindings and ClusterRoleBindings, and mapping IAM users and roles to Kubernetes RBAC roles.

1. Setting up an Amazon EKS Cluster

Setting up an Amazon EKS cluster is the first step towards implementing Kubernetes RBAC. To do this, you need to create a VPC, or virtual private cloud, to host your cluster. Once your VPC is set up, you can create an EKS cluster within it using the AWS Management Console, AWS CLI, or AWS SDKs.

Creating an EKS cluster involves specifying the Kubernetes version, defining the cluster's network configuration, and setting up the cluster's IAM role. This IAM role is vital as it provides the permissions necessary for the EKS service to manage resources on your behalf.

2. Defining Kubernetes Roles and ClusterRoles

Once your EKS cluster is up and running, the next step in implementing Kubernetes RBAC is to define Kubernetes Roles and ClusterRoles.

As explained earlier, a Role is a set of permissions that apply within a specific namespace. These permissions define what actions (like 'get', 'list', 'create', 'update') are allowed on which resources (like 'pods', 'services', 'deployments') within that namespace.

A ClusterRole, on the other hand, is a set of permissions that apply cluster-wide, across all namespaces. It defines what actions are allowed on which resources throughout the entire cluster.

3. Defining RoleBindings and ClusterRoleBindings

After defining Roles and ClusterRoles, the next step is to define RoleBindings and ClusterRoleBindings. These are the objects that link users to the Roles and ClusterRoles, effectively granting them the permissions defined in those roles.

A RoleBinding grants the permissions defined in a Role to a user or a group of users. It applies only within the specific namespace where it is defined.

A ClusterRoleBinding, similar to a ClusterRole, is a cluster-wide object. It grants the permissions defined in a ClusterRole to a user or a group of users. It applies across all namespaces in the cluster.

4. Mapping IAM Users and Roles to Kubernetes RBAC Roles

The final step in implementing Kubernetes RBAC in Amazon EKS is mapping IAM users and roles to Kubernetes RBAC roles. This is done through the aws-auth ConfigMap, which is stored in the kube-system namespace.

The aws-auth ConfigMap is the link between AWS IAM and Kubernetes RBAC. It allows you to specify which IAM users or roles can access the Kubernetes API server and what permissions they have.

To map an IAM user or role to a Kubernetes RBAC role, you need to add an entry to the mapRoles or mapUsers section of the aws-auth ConfigMap. This entry defines the IAM user or role and the corresponding Kubernetes user and groups.

In conclusion, Kubernetes RBAC in Amazon EKS provides a robust and flexible system for managing access to your Kubernetes clusters. Although it can seem complex at first, understanding the basics of how it works and how to implement it is critical to maintaining the security and integrity of your Kubernetes environment.

Continue Learning