-
Notifications
You must be signed in to change notification settings - Fork 320
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
[EKS] [request]: Better support for removing instance metadata endpoint access #1060
Comments
As an update here, we have updated our docs with a simpler option to disable IMDS for pods by using IMDSv2 and the hop limit https://docs.aws.amazon.com/eks/latest/userguide/best-practices-security.html We do plan to add this as a checkbox option to managed groups in the future |
Is there an example on how we can add this for managed groups for now during bootstrapping (especially using eksctl)? |
for EKS managed groups you may want to set eksctl CLI option |
Experience the same issue on cloudwatch agents for EKS when enabling IMDSv2 with token hop limit to 1 on the launch template as specified from the best practice documentation. We set this to token hop limit 2 for now, which feels like it goes against what it recommended. |
@sharkztex Did you also configure the iptables? I couldn't get it to work when using the iptables. |
@gfvirga No we didn't as we don't have a requirement to access IMDSv1. |
Any update on how to run the CloudWatch Agent with IMDS? We also have it disabled but want to run the CloudWatch Agent and are getting the same issue. |
is there any news about this issue? |
I've been finally able to fix this issue, i found the right configuration. Since i'm using terraform to provision the EKS cluster and the managed node groups, i had to add the following configuration for the aws_launch_template resource:
After that, in case you're using bottle rocket you have to set the right socket path on the cloud watch pods. |
@bersanf did you also configured iptables? |
@mikestef9 are there still plans to expose IMDS customization/restriction in the managed node groups API? I'm looking for a means to restrict down to best practice (tokens required, hop limit 1) without needing to define a custom launch template. |
Any updates? We blocked access to IMDS as per best practice: Restrict access to the instance profile assigned to the worker node But we bumped hop count to 2 because apparently some application needs IMDS: As a consequence, I assume, mkat complains that IMDSv2 is accessible:
How to improve?
|
It is my understanding (and documented) that it is a best practice to disable imds unless it is being used. Unfortunately, there seems to be a dependency within the eks control plane that necessitates the imds endpoint being available. We had the unfortunate mishap of our entire cluster going haywire when we disabled imds entirely (endpoint disabled). The nodes stopped responding properly, pods terminated but also failed to start, et cetera. This requires better and clearer documentation for real best practices FOR EKS specifically. Following best practices should never result in a service becoming unusable or unstable. |
@Daemoen These are the instructions for EKS: This strong recommendation to block access to IMDS also includes this caution:
and this caution:
Perhaps an improvement regarding the first caution would be to include steps to identify pods that are NOT using IRSA or EKS Pod Identities? Steps like the following, but specific to EKS? https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html By the way, I find the subtle distinction in the docs between disabling and blocking access to be confusing. The docs are also unclear as to when access to instance metadata refers to IMDS or IMDSv2 or either. As I reported above, we fell into a third category requiring a hop limit of 2, and you may be in that boat, too. There need to be better instructions for identifying this case, and for eventually decreasing hop limit to 1. |
@joebowbeer Hah! Thanks for that github link. I think that's the piece of what I was getting at, that this needs to be much clearer. I used the docs.aws guide re: IMDSv2 which does not say anything about those same cautions. I hadn't even thought to check the github doc site until a buddy and I found this thread/discussion after we hit the issue and started discussing it. (I landed in both of the cautions, sadly). TYVM! |
Community Note
Tell us about your request
Removing access to the instance metadata endpoint is documented as good security posture in your documentation: https://docs.aws.amazon.com/eks/latest/userguide/restrict-ec2-credential-access.html. However, there are a couple of improvements that could be made here:
I suspect the Cloudwatch Agent needs access to the instance metadata service. However it feels like it shouldn't, and should be able to collect the information it needs via other IRSA permissions, and possibly by looking at the labels on the node (if all it really needs is the instance id)
Which service(s) is this request for?
EKS
Tell us about the problem you're trying to solve. What are you trying to do, and why is it hard?
Trying to run the Cloudwatch Agent using IRSA, in a cluster with a strong security posture that has had the instance metadata endpoint disabled for use by pods.
Are you currently working around this issue?
You would need to use something else for network policy enforcement, such as Calico. However this comes with extra overhead of managing another cluster service, and deficiencies with the deployment of Calico resources (having to use calicoctl instead of kubectl for some resources).
The text was updated successfully, but these errors were encountered: