-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Create an IAM Service Account role without creating/annotating the service account #3042
Comments
Thanks for opening the issue @Legion2 You are correct that this will not work. When you create the IAMServiceAccount the role is setup to only work with the specified serviceaccount. This is an intentional security feature, otherwise any service account could use the role created.
This is an interesting use case, you're essentially using the |
On solution would be, that eksctl can be configured to only create the IAM role, which is coupled to a specific service account namespace and name, and not manage that service account (create/delete it). Because the service account is managed using the git-ops approach.
This can be overcome by looking into the helm chart template, which is not optimal but then required for security reasons. |
If the service account already exists, you can use the |
When using git-ops you simply define manifest files which are applied to the cluster from a repository. You do not want to think about using different cli command to manage the state of the cluster. For git-ops it should not matter if the service account already exists or not. You just want to define that a service account has an iam role assigned. |
I see where your coming from @Legion2
A flag/field that introduces this behaviour sound reasonable to me. Would you be willing to work on a PR to introduce this functionality 😄 ? |
I will try. It's my first time implementing something in go. If I have any problems I will let you know. |
Fantastic 🎉 Happy to help |
We need to talk about the naming. How should the new option of the Also should we only allow this option in combination with When deleting the ClusterIAMServiceAccount, currently the service account is also delete (even when it was not created). It uses the |
So we need a flag for the cli and a field in the config that represent the intent that: "we are not going to create and/or annotate a service account during creation of this iamserviceaccount". I think
I think this functionality is best used when
I think adding the a new tag might be more complexity that needed. How about using the same field/flag |
When deleting an iam service account using |
@Legion2 not all features in eksctl are designed with GitOps in mind, and IRSA is one of them. The IAM role created by eksctl is not only tied to the ServiceAccount (via the The IRSA feature is designed to work as a whole, so disabling parts of it can be unintuitive to users (e.g., why does it allow skipping the SA creation but not the role creation?), and deletions and updates can get complicated as you've discovered. I'm leaning towards not adding this feature. As to your original issue:
Helm charts usually allow configuring resource names, so your chart may already support specifying |
I think I took @Legion2 feature request slightly different. I was imaging a setup in which:
The option to skip service account creation/annotation in combination with the existing
I don't think this is a reason not to implement this feature. The default behaviour will remain the same, so the command is still intuitive.
I think there are some workarounds that could reduce the complexity. For example before deleting a serviceaccount we could check to see who is the manager of the annotation by inspecting the
|
@cPu1 yes, I tried that, but when the service account is created by eksctl, the helm chart can not be deployed because the service account already exists: The problem is that both (eksctl and helm) claim to be the manager of the service account. It should be clearly defined who is the owner of the service account and can create and delete it. @aclevername the |
After rethinking the whole situation and considering that IRSA is not build for GitOps, I think there is no simple way to make it fully GitOps compatible. However, the IRSA feature is very important and should be usable with GitOps. Therefore, the relevant documentation should be updated to reflect how IRSA can be used in a GitOps setup. The pattern would be, to first deploy the service account with the GitOps approach and then use eksctl to create the IAM role and attach it to the service account. The documentation should state that IRSA is not built for GitOps and therefore the annotation is lost when the service account is recreated in the cluster. We should add an option to the cli ( |
I found #3037 which conceptually covers the GitOps use case and reconciliation much better that it would be possible here. So instead of trying to implement the GitOps use case here, it should be done with the |
What happened?
I used the IAM role name feature to give the iam role generated by eksctl a predictable name. Then I used the IAM role name in a GitOps setup and attached it with the
eks.amazonaws.com/role-arn
annotation to a service account which is provided by a helm chart.The service account is generated be the helm chart and only the annotation and the IAM role is provided by me. I don't know the name of the service account generated by the helm chart.
I don't know if this is a bug or feature request but from the description of the PR (#2863) that introduced the feature:
I thought that this is the intended use of the IAM role name feature.
What you expected to happen?
I created a IAM role using the following cluster config.
The config generates two things: the IAM role and a Service Account.
I don't need the service account, I only want to use the IAM role and attach it to the service account generated by the helm chart.
The helm chart is managed the
helm.fluxcd.io/v1
HelmRelease
crd.In the values section I added the following:
How to reproduce it?
eks.amazonaws.com/role-arn
annotation to a service account different than the one created by eksctlWebIdentityErr: failed to retrieve credentials caused by: AccessDenied: Not authorized to perform sts:AssumeRoleWithWebIdentity
in the application that uses the service accountAnything else we need to know?
#2863 (comment)
Versions
Please paste in the output of these commands:
The text was updated successfully, but these errors were encountered: