-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Helm deployment on Amazon EKS: values.yml server.serviceaccount.annotations AWS IAM Role not working as expected for KMS auto-unseal #9576
Comments
Are you using the Unrelated Quality of Life Improvement Tip: You can use a KMS alias instead of putting the Key ID in your config:
|
I tested using the 1.5.0 and 1.4.3 images specifically. Thanks for the tip on the QOL key alias. I did test the same role on a service account on the same cluster and was able to get the intended role
|
Are there some steps missing in your setup? I ask because following these instructions works for me with 1.5 and 1.4.3 (w/setting AWS_ROLE_SESSION_NAME): https://aws.amazon.com/blogs/opensource/introducing-fine-grained-iam-roles-service-accounts/ Specifically I think the eksctl command for adding an iam oidc provider and using eksctl to create the iam role might be setting up the missing pieces. For instance, I wasn't able to run
|
So annoyed. Seriously this role switch does not work whatever i tried. Spent whole day did exactly what ever told and more than that. |
Hi, I have all the setup already including the the OIDC provider and role setup. Using awscli in the cluster with a service account configured in the same fashion allows me to make use of the intended role as mentioned in my previous response. eg:
As you can see the Expected role is used and not the underlying instance role. Again this is on the same EKS cluster and EKS nodes. This is the same role as you can see in the "server.serviceAccount.annotations" passed into the values.yaml and you can see the appropriate values are set on the "stateful set" pod. From the information I posted above in the pod manifest:
The error in the pod logs is:
As you can see the underlying instance role is being used ... not the role specified in the annotations. Is there further detailed information I should explore that can help pinpoint this issue?
|
Hi there, so I don't believe I've also noticed that when I create an iamserviceaccount with eksctl, the role that is created has specific trust relationships setup such that using the role's ARN only works for auth when it's used with the k8s serviceaccount with the same name and namespace that I entered as parameters. So if I annotate a k8s service account with a different name or namespace, an eks token is still projected into the pod, and the AWS_ROLE_ARN and AWS_WEB_IDENTITY_TOKEN_FILE vars are set correctly, and And yes, the error coming back from vault only mentions the node role, but in this case I believe the AWS auth code in vault tries AssumeRoleWithWebIdentity first, and then eventually falls back to auth'ing with the node role before giving up. I've verified this by adding some tracing to the AWS client setup, but haven't been able to get more info logged from vault in this part of the process. |
Hi I am using the following to test this now:
I believe my mistake was the trust policy on the IAM Role.
Before I only had the "booter-script-vault" service account mapped as I was running a kubernetes job to automate some of the Vault bootstrapping tasks. I have now added an additional IAM role with a trust policy for the "vault" service account in the trust policy.
I was testing with the "booter-script-vault" service account which worked and I presumed since I had annotated the same IAM Role in the Helm chart that it should just work. I think the lack of an error from the vault image around the failed "AssumeRoleWithWebIdentity" led me to believe the credential logic never fired somehow. |
Thanks a lot @gargana, finally it worked.! |
Describe the bug
Deploying Vault using the Helm chart and Helm v3
In order to allow vault to access the AWS KMS key required for auto-unseal I provide the service account an IAM role via annotations in the values.yml.
eg:
This appears on the vault pods:
The vault-X pods fail with the following:
What is happening here is that Vault is using the Instance Profile IAM Role and NOT the one provided to the serviceaccount via the values.yaml.
When looking at the code for vault here:
vault/sdk/helper/awsutil/generate_credentials.go
Lines 62 to 74 in 95e05e5
It appears that it should add this credential to the Credential Chain.
To isolate the issue further I removed access to the metadata of the underlying instance so the instance role could not be reached by following the instructions here: https://docs.aws.amazon.com/eks/latest/userguide/restrict-ec2-credential-access.html
This resulted in an error stating that no credentials could be loaded.
To Reproduce
Expected behavior
Vault should use the IAM Role provided by the annotation to perform the KMS auto-unseal and not use the Instance IAM Role
Environment
Chart values:
Note: I tested with 1.4.3 and 1.5.0 images, I included the AWS_ROLE_SESSION_NAME: some_name so as not to run afoul of this issue: #8844
kubectl get pods vault-0 -o yaml
Additional context
Please let me know if there is more info you would like me to present
The text was updated successfully, but these errors were encountered: