Skip to main content
This guide explains how to implement IAM Roles for Service Accounts (IRSA) for a Kubernetes cluster on Talos Linux. This allows Pods to access AWS services using temporary IAM credentials, similar to how EKS clusters in AWS function. While this example uses AWS S3 and Terraform, the general principles can be applied to any S3-compatible object store and adapted for other infrastructure-as-code tools or a manual setup. For the purpose of this guide, we will create a generic, read-only IRSA Role to test access to S3 from Talos Linux after the IRSA setup is complete. Administrators will need to create their own IAM Roles that target the specific AWS services they need to access from their Kubernetes Pods.

Prerequisites

Before you begin, you will need:
  • A Kubernetes cluster running on Talos Linux.
  • An AWS account with permissions to create S3 buckets, IAM roles, and OIDC providers.
  • Terraform (optional, for the examples provided).
  • kubectl and helm installed locally for testing
This guide is based on the official instructions for setting up the Amazon EKS Pod Identity Webhook in a self-hosted environment. In summary, this is what is needed to accomplish IRSA:
  1. Create a keypair, populate an S3 bucket with publicly-accessible OIDC discovery documents, and register the S3 bucket endpoint as an Identity Provider with AWS IAM.
  2. Pass the private key to the Kubernetes API server. Your Kubernetes API server is now an OIDC issuer!
  3. Run amazon-eks-pod-identity-webhook, which mutates pods based on the annotations to inject environment variables like AWS_WEB_IDENTITY_TOKEN_FILE (and cert-manager, since this webhook per Kubernetes requirements needs to serve HTTPS)
The Kubernetes API server can now sign projected service account tokens using the private key, which gets passed to AWS IAM with the role the pod wishes to assume. IAM then confirms the signature using the registered IdP, ensures the role assumption is allowed, and returns credentials.

Step 1: Create OIDC serving infrastructure

The following Terraform module creates all the AWS infrastructure needed. You can instantiate this module in your terraform using source, or apply it using a .tfvars file or command-line flags.

Step 2: Configure Talos machineconfig

Patch your Talos machineconfig to use the new Service Account issuer and signing key.
  1. Create the patch file, machineconfig-patch.yaml, fetching BASE64_ENCODED_PRIVATE_KEY from AWS SecretsManager as populated by the above module:
  2. Apply the patch to your Talos configuration and update your cluster, and wait for the server to come back up with the new config. For example, using talosctl:

Step 3: Install required Kubernetes components

Two components are required on the cluster: cert-manager and amazon-eks-pod-identity-webhook.

Install cert-manager

  1. Add the Jetstack Helm repository:
  2. Install the cert-manager Helm chart:
Next, install the amazon-eks-pod-identity-webhook.

Install amazon-eks-pod-identity-webhook

  1. Add the jkroepke Helm repository:
  2. Install the amazon-eks-pod-identity-webhook Helm chart:

Step 4: Test

  1. Apply this terraform (or do manually) to create an AWS role for a test service account to assume that has S3 read access.
  2. Create a manifest for the ServiceAccount and a test Pod. The command below uses a heredoc to create test-pod.yaml and substitute the shell variables.
  3. Apply the manifest:
  4. Exec into the aws-cli Pod.and test access by listing S3 buckets:
    This command should list the S3 buckets in your AWS account, confirming that IRSA is correctly configured.