Skip to content
This repository has been archived by the owner on Jul 26, 2022. It is now read-only.

Integration with AWS IAM Roles for ServiceAccounts #200

Merged
merged 1 commit into from
Nov 7, 2019

Conversation

arruzk
Copy link
Contributor

@arruzk arruzk commented Nov 7, 2019

It is a second attempt to do it (first is #176). With recent changes it is easier.

  • AWS SDK version was updated
  • securityContext parameter in a helm chart was added

It should fix this issue #161

Sorry @farshad-hobsons if you are working on it now.
@Flydiverny @silasbw could you please review it?

- Update AWS SDK version
- securityContext in a helm chart
@Flydiverny Flydiverny merged commit 165662c into external-secrets:master Nov 7, 2019
@imaffe
Copy link

imaffe commented Nov 15, 2019

@arruzk Sorry for the late response, but I downloaded the latest helm version with 2.1.0 docker image, turned fsgroup to 65534 and annotation configured the service account annotation to the IAM role i want.
image
And the environment variable of this pod is
image
(Which is set by the EKS IRSA)
But the logs shows it is still using the EC2(nodes') iam role, and is not working . (Sorry I cannot post the logs cuz it might be sensitive)

Have you tested if it is really working with the IRSA ? Thanks so much

@arruzk
Copy link
Contributor Author

arruzk commented Nov 16, 2019

@imaffe just checked now. Everything is working for me.
my test values.yaml (helm chart version is kubernetes-external-secrets-2.2.0)

env:
  AWS_REGION: eu-west-1
# created in terraform
serviceAccount:
  name: secrets-manager
  create: false
image:
  tag: latest
  pullPolicy: Always
securityContext:
  fsGroup: 65534

From pod env:

    - name: AWS_ROLE_ARN
      value: arn:aws:iam::11111111111:role/staging-ir-1-sm-reader-role
    - name: AWS_WEB_IDENTITY_TOKEN_FILE
      value: /var/run/secrets/eks.amazonaws.com/serviceaccount/token

Try to log in into the pod (with exec) and do
cat /var/run/secrets/eks.amazonaws.com/serviceaccount/token

@dudicoco
Copy link

dudicoco commented Dec 3, 2019

@arruzk I am also experiencing the same issue as @imaffe.
I was able to exec into the container and cat the token.

Any ideas?

@dudicoco
Copy link

dudicoco commented Dec 3, 2019

@arruzk when testing this did you verify the role which is being assumed does not have the node in its trusted relationships? Is it possible the container was actually using the node's role + kiam in your tests?

@imaffe
Copy link

imaffe commented Dec 3, 2019

@arruzk I am also experiencing the same issue as @imaffe.
I was able to exec into the container and cat the token.

Any ideas?

I've fixed it, and I checked the trust relationship in the EKS cluster page, my problem was the serviceaccount name defined doesn't align with the trusted IAM role arn in the trusted relationships. The service account name is not the same as the app name, I think it's their helm chart didn't follow the conventions.

@Flydiverny
Copy link
Member

@Flydiverny
Copy link
Member

If there's specific steps to get it all working it would be great if someone wants to do a PR to update the docs :)

@dudicoco
Copy link

dudicoco commented Dec 3, 2019

Thanks @imaffe, turns out my namespace wasn't aligned in the trusted relationships of the IAM role.
@Flydiverny doesn't seem like there are special steps to get it working except for the usual steps needed to configure pod IAM role OIDC token, was user error on our part.
securityContext with fsGroup: 65534 is needed though, I'm not sure if it's documented?

Thanks for the help guys!

@mo-saeed
Copy link

mo-saeed commented Mar 6, 2020

Anybody tried it with EKS? the pod is always trying to use the node_group role although I have all configured right and this file /var/run/secrets/eks.amazonaws.com/serviceaccount/token exists in the pod

@dudicoco
Copy link

dudicoco commented Mar 8, 2020

@mo-saeed yes we are using it with EKS, take a look at my previous comments in this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants