AWS Identity and Access Management (IAM) is a service offered by Amazon Web Services (AWS) that provides a secure way to control access to AWS resources. IAM allows you to manage users, groups, and roles that can access and interact with your AWS infrastructure. Before we get started, lets do a quick overview of AWS IAM, or you can skip to the good stuff by clicking Implementing AWS EKS Pod Identity on the table of contents.
What is AWS Identity and Access Management?
Let’s go over some AWS terminology. AWS Identity and Access Management (AWS IAM) provides centralized identity management and access control for AWS resources. AWS IAM focuses on Role Based Access Control (RBAC), which allows you to create and manage AWS users, groups, and roles, and assign permissions to them.
Users are individuals who interact with AWS resources. They can be either humans or services that require access to your AWS environment. Users are identified by unique credentials, such as usernames and passwords, MFA and other forms of authentication. Regardless, all connected entities are establishing some sort of session which includes temporary access keys.
Groups are collections of users. They allow you to manage permissions for multiple users collectively. By assigning permissions to groups, you can grant or revoke access to a set of users simultaneously.
Roles, on the other hand, are similar to users but are not associated with a specific individual, however as best practice it is recommended to define the purpose of a role to a specific function/service. Roles are assumed by entities such as users or applications. They define the permissions an application or service can have while interacting with your AWS resources.
However, managing Identity and Access Management (IAM) permissions within Amazon Web Services’ Elastic Kubernetes Service (EKS) can be akin to navigating a labyrinth. In this article, we’ll will compare AWS EKS Pod Identity methodology to the OIDC from a practical viewpoint, as in what it actually takes to get started.But first, let's make clear what are AWS Identity and Access Management, AWS EKS POD Identity and OIDC.
What is AWS IRSA and why do you need it?
Regardless of the method of authentication, Kubernetes on AWS or any other service for that matter requires some form of recognition of the entity that uses them in order to assign it the correct permissions. In EKS specifically, the form of permission allocation is done by IAM roles for service accounts (IRSA), which creates a correlation, basically an abstraction, between the Kubernetes native terminology of “service accounts” and the AWS identity management center and its “IAM entities”. This connection allows an EKS administrator to assign IAM roles and permissions to Kubernetes native service identities.
As organizations embrace the scalability and flexibility offered by EKS for their containerized applications, the intricacies of IAM permissions often emerge as a significant challenge, in part due to AWS’s often clunky implementation of IAM roles for service accounts (IRSA), which requires setting up an OpenID Connect (OIDC) identity provider.
These moving components can cause a headache when it comes to implementing them in DevOps best practices such as DRY (Don’t Repeat Yourself), IaC (Infrastructure as Code), Code Reusability and Generic Templating.
Challenges of OpenID Connect (OIDC) identity provider
OpenID Connect (OIDC) is an open standard for user authentication and authorization. It allows web and mobile applications to verify the identity of the end-user based on their credentials. OIDC can be used as an identity provider for EKS clusters, allowing you to authenticate and authorize users to access Kubernetes resources.
However, as mentioned using OIDC as an identity provider introduces some challenges, the most obvious of which is the maintenance of yet another cloud resource such as the identity provider.
In attempts to remove some of the challenges that come with implementing IRSA and the complexity of OIDC, as aforementioned, one might think if there is a simpler way of creating this Kubernetes to IAM abstraction layer of permissions. Luckily, AWS has heard the complaints of many customers and issued a new method of providing permissions on Kubernetes using AWS IAM terminology, called “Pod Identities”.
What is AWS EKS Pod identity?
Amazon EKS Pod Identities, introduced at last year's AWS re:Invent conference has provided an interesting new way to help manage Kubernetes permissions. This feature enhances container orchestration by streamlining the process of managing access to resources.AWS EKS Pod Identity, an evolution from “IRSA”, simplifies IAM permission management for EKS clusters by removing OIDC limitations, shifting to a unified trust policy (pods.eks.amazonaws.com), supporting STS session tags for granular access control, and separating AWS and Kubernetes API concerns, meaning, for example, that you can use a single IAM role in multiple clusters.
Implementing AWS EKS Pod Identity
In the following section, we’ll implement Pod Identity from scratch on a simple vanilla EKS cluster. We’ll use common tools and practices on order to provide basic AWS IAM credentials to a basic Kubernetes native service account. Using this method, we’ll achieve this with some common tools and the least possible effort.
NOTE: The code examples for the below guide are available in our GitHub Repository.
Getting Started — Requirements
Before moving on to evaluation, we need the basic components that allow for the usage of this feature:
- An EKS Cluster, with an AWS Profile that has permissions for Read/Write into it.
- An IAM Role we’d Like to give to our Pods, Such as:
- A Kubernetes Workload, connected to a Kubernetes Service Account. You do not need direct access to Kubernetes if you have a deployment mechanism in place, such as ArgoCD or any API abstraction layer.
A Hands-on Comparison
In the following section, we will compare the two methodologies from a practical viewpoint, as in what it actually takes to get started. The main components are the Service Account, the Trust Policy, and the Authentication Mechanism behind it all. The following will provide examples of provisioning these resources through IaC using YAML, IAM Policy Syntax and Terraform respectively.
The IRSA Method:
The Pod-Identity Method:
Side-By-Side Comparison
- The Service Account
The service account stays the same in the two methodologies. It annotates a reference to an AWS IAM role.
Note: IRSA allows cross-account roles, but currently Pod-Identity does not support it.
- The Trust Policy
In IRSA, we had to explicitly provide the hard-coded value of the OIDC provider inside the trust policy.
However, the following is the main improvement in Pod-Identity. All we have to provide is a unified trust policy that allows an IAM to be used by an EKS cluster in general, which means ANY EKS cluster (in the same account).
The Authentication Mechanism
As we’ve previously noted, the mechanism behind the scenes is different. In IRSA, the external OIDC provider for IAM we create in AWS is the authority for allocating credentials between different Kubernetes service Roles. In the following example in Terraform, we assume that we have previously created an EKS cluster, and use its issuer certificate in order to authorize an OpenID Provider (OIDC), which we provide as an input to a Role we’d like to use in the cluster.
In the Pod-Identity method, because the components we use are managed by AWS, there are two major additions to the resource pool, but a reduction in what we called “hard-coded” resources:
The Bottom Line
The thing to note apart from Reusability and Ease of Setup, is that the Pod-Identity plugin for EKS automatically deploys a DaemonSet to each node in the EKS cluster. Each of these “agents” is essentially a central mechanism for authentication all pods in its node using AWS IAM API. This allows for a major advantage in Scalability, as described in the AWS documentation.
Pod-Identity Reduces load by having the EKS Auth service assume temporary credentials for EKS Pod Identity, lowering the load to once per node instead of duplicating it for each pod.
For further reading I suggest looking through the AWS Documentation. Here are some links to get you started with Pod-Identities:
- Pod Identity Association Terraform Resource
- AWS Feature Blog
Ready to streamline your Kubernetes resource management and optimize your AWS EKS environments? With PerfectScale, you can maximize cost savings and enhance performance by intelligently managing your Kubernetes resources. Our advanced algorithms and machine learning techniques ensure your workloads are optimally scaled, reducing waste and cutting costs without compromising performance. Join forward-thinking companies who have already optimized their Kubernetes environments with PerfectScale. Sign up and Book a demo to experience the immediate benefits of automated Kubernetes cost optimization and resource management. Ensure your EKS clusters are always perfectly scaled and cost-efficient, even when demand fluctuates.
Amitai G is a freelance DevOps consultant with an extensive background in DevOps practices and Kubernetes' ongoing maintenance and operations. As the author of the @elementtech.dev Medium channel, he specializes in writing articles that provide engineers with a deeper understanding and best practice guidance across the various aspects of the Cloud Native landscape.