EKS Cluster: Part 10 – IRSA, Pod IDs, Karpenter, & App Sets.. You like that!?

Series of blog posts show progress of updating/adding to EKS Cluster, this post covers improving AWS Secrets Manager, External Secrets, EKS Pod Identity, & IRSA. Cuz who dont want some of that stuff? Queue Kirko Chainzz “you like data!?!?”

The Flow of Secrets Mgr, External Secrets, EKS Pod ID, & IRSA:

  1. Terraform creates an ephemeral password.
  2. Terraform writes it to AWS Secrets Manager without placing it in Terraform state.
  3. Terraform gives the External Secrets service account narrowly scoped AWS access through EKS Pod Identity.
  4. Argo CD installs External Secrets Operator.
  5. Argo CD creates a SecretStore and ExternalSecret.
  6. External Secrets reads the AWS secret and creates a Kubernetes Secret.
  7. The demo Deployment consumes the Kubernetes Secret.
  8. The demo application receives no AWS permissions.

Repos & Folder & Files Created:

RepositoryChanges
say_when_infraPod Identity Agent EKS add-on, IAM role and policy, Pod Identity association, Secrets Manager secret container
say_when_git_opsExternal Secrets Helm application, namespaced SecretStore, ExternalSecret, test workload

applications/
├── external-secrets.yaml
├── external-secrets-config.yaml
└── secret-demo.yaml

apps/
├── external-secrets/
│ └── values.yaml
├── external-secrets-config/
│ ├── external-secret.yaml
│ └── secret-store.yaml
└── secret-demo/
└── deployment.yaml

infra/
├── providers.tf
├── outputs.tf

LayerResponsibility
TerraformAWS secret, IAM, EKS add-on and Pod Identity
Operator ApplicationInstall ESO and its CRDs
Configuration ApplicationTell ESO what AWS secret to synchronize
Demo ApplicationConsume the resulting Kubernetes Secret

Below are links for details:

Infrastructure Repository:

providers.tf

outputs.tf:

  • Why:
    • Makes verification easier after terraform apply.
    • Outputs only resource identifiers, not the generated password.
    • Lets you confirm exactly which role and secret Terraform created.
  • Source:

external-secrets.tf:

  • Why:
    • Provides one location for names shared by the IAM role, Pod Identity association, and Kubernetes manifests.
    • Prevents repeated hard-coded values throughout the file.
  • Source:
==============
- aws_eks_addon_version
==============
- aws_eks_addon
==============
==============
- ephemeral "random_password"
==============
==============
- aws_secretsmanager_secret_version
==============
Pod Identity trust policy
==============
- Narrow Secrets Manager policy
==============
aws_eks_pod_identity_association

Gitops Repository:

applications/external-secrets.yaml:

apps/external-secrets/values.yaml

applications/external-secrets-config.yaml:

apps/external-secrets-config/secret-store.yaml:

apps/external-secrets-config/external-secret.yaml:

applications/secret-demo.yaml:

apps/secret-demo/deployment.yaml:

Confirm you can see it finale:

Secrets Manager EKS Pod ID:

==============
aws secretsmanager describe-secret \
--secret-id say-when/demo-app/credentials \
--region us-east-1 \
--output table
==============
aws secretsmanager get-secret-value \
--secret-id say-when/demo-app/credentials \
--region us-east-1 \
--query SecretString \
--output text |
jq
==============

EKS Pod Identity Agent:

==============
aws eks list-pod-identity-associations \
--cluster-name say-when-east \
--region us-east-1 \
--output table
==============

IAM role and policy:

==============
aws eks describe-addon \
--cluster-name say-when-east \
--addon-name eks-pod-identity-agent \
--region us-east-1 \
--query 'addon.{Name:addonName,Status:status,Version:addonVersion}' \
--output table
==============
aws iam get-role \
--role-name external-secrets-pod-identity-role \
--query 'Role.{RoleName:RoleName,Arn:Arn,TrustPolicy:AssumeRolePolicyDocument}' \
--output json
==============
aws iam list-attached-role-policies \
--role-name external-secrets-pod-identity-role \
--output table
==============

Kubernetes and Argo CD:

==============
kubectl get secretstore,externalsecret \
-n secret-demo
==============
kubectl get secret demo-app-credentials \
-n secret-demo \
-o json |
jq '{
name: .metadata.name,
type: .type,
keys: (.data | keys)
}'
==============

Other various AWS CLI Commands to try:

==============
aws eks describe-addon \
--cluster-name say-when-east \
--addon-name eks-pod-identity-agent \
--region us-east-1 \
--query 'addon.{Status:status,Version:addonVersion}' \
--output table
==============
aws eks list-pod-identity-associations \
--cluster-name say-when-east \
--region us-east-1 \
--output table
==============
ESO_ASSOCIATION_ID="$(
aws eks list-pod-identity-associations \
--cluster-name say-when-east \
--region us-east-1 \
--query 'associations[?namespace==`external-secrets` && serviceAccount==`external-secrets`].associationId | [0]' \
--output text
)"
aws eks describe-pod-identity-association \
--cluster-name say-when-east \
--association-id "$ESO_ASSOCIATION_ID" \
--region us-east-1 \
--query 'association.{Namespace:namespace,ServiceAccount:serviceAccount,RoleArn:roleArn}' \
--output table
==============
aws secretsmanager describe-secret \
--secret-id say-when/demo-app/credentials \
--region us-east-1 \
--query '{Name:Name,ARN:ARN,Description:Description}' \
--output table

Leave a Reply