I'm trying my hand on iam roles for services account to secure the autoscaller. But I seem to be missing something. Little precision I'm using terraform to create the cluster.
I followed these documentation:
- https://aws.amazon.com/blogs/opensource/introducing-fine-grained-iam-roles-service-accounts/
- https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html
So I've created a role other than the one for the nodes and applied the policy for the autoscaller to this new role. This part is basic, no issue there.
I also activated the openid provider in terraform:
resource "aws_iam_openid_connect_provider" "example" {
client_id_list = ["sts.amazonaws.com"]
thumbprint_list = []
url = aws_eks_cluster.eks.identity.0.oidc.0.issuer
}
No issue the cluster is creating itself with no issue.
No I added the annotation to service account for the autoscalling:
---
apiVersion: v1
kind: ServiceAccount
metadata:
annotations:
eks.amazonaws.com/role-arn: arn:aws:iam::ID:role/terraform-eks-autoscaller
labels:
k8s-addon: cluster-autoscaler.addons.k8s.io
k8s-app: cluster-autoscaler
name: cluster-autoscaler
namespace: kube-system
My problem is that it does not seems to works and the pod is still trying to use the new IAM role but still using the node role:
Failed to create AWS Manager: cannot autodiscover ASGs: AccessDenied: User: arn:aws:sts::ID:assumed-role/terraform-eks-node/i-ID is not authorized to perform: autoscaling:DescribeTags
Does someone know what step I'm missing here?
Thanks in advance for the help ;)