Skip to content

Fix missing permission setup for IPv6 cluster #8387

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

Merged
merged 1 commit into from
May 29, 2025

Conversation

guessi
Copy link
Contributor

@guessi guessi commented May 24, 2025

Description

While useDefaultPodIdentityAssociations: true set, eksctl will only attached AmazonEKS_CNI_Policy to the IAM role for the CNI, however AmazonEKS_CNI_Policy is not designed for IPv6 cluster (missing ec2:AssignIpv6Addresses permission). Ref: IAM requirements for IPv6 cluster.

image

Additionally, to support IPv6 cluster, the ClusterConfig need to configure vpc-cni with IRSA mode but not PodIdentity, since the current design, attachPolicy association currently not compatible with useDefaultPodIdentityAssociations: true.

Error: cannot specify serviceAccountRoleARN, wellKnownPolicies, attachPolicy or attachPolicyARNs when addon.useDefaultPodIdentityAssociations is set (addon: vpc-cni)

The PR here attempts to do a quick fix of IPv6 cluster with simplest way, the doc fix only.

To made attachPolicy works with useDefaultPodIdentityAssociations: true may requires tons of code work, so, let's first keep it simple with doc changes only.

Before Fix:
image

After Fix:
image

Checklist

  • Added tests that cover your change (if possible)
  • Added/modified documentation as required (such as the README.md, or the userdocs directory)
  • Manually tested
  • Made sure the title of the PR is a good description that can go into the release notes
  • (Core team) Added labels for change area (e.g. area/nodegroup) and kind (e.g. kind/improvement)

BONUS POINTS checklist: complete for good vibes and maybe prizes?! 🤯

  • Backfilled missing tests for code in same general area 🎉
  • Refactored something and made the world a better place 🌟

Copy link
Member

@naclonts naclonts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the CR and issue report! The functionality looks good -- tested on my machine and it seems to be working great. Just left a couple small suggestions/questions on the docs.

Comment on lines +17 to +18
# "ec2:AssignIpv6Addresses" would be required for IPv6 cluster
# - https://github.com/aws/amazon-vpc-cni-k8s/blob/master/docs/iam-policy.md#ipv6-mode
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the other policies required as well? The comment makes it sound a bit like "ec2:AssignIpv6Addresses" might be the only required action.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I have traced the code, IPv4/IPv4 have different IAM policy set, so they are completely different. For example, IPv6 mode does not required AssignIPv4/UnadsignIPv4 permission (and by current design, it doesn't need UnassignIPv6 as well).

Copy link
Contributor Author

@guessi guessi May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just search around the code once again, I found it already had makeIPv6VPCCNIPolicyDocument()...

Umm... 🤔

func makeIPv6VPCCNIPolicyDocument(partition string) map[string]interface{} {
return map[string]interface{}{
"Version": "2012-10-17",
"Statement": []map[string]interface{}{
{
"Effect": "Allow",
"Action": []string{
"ec2:AssignIpv6Addresses",
"ec2:DescribeInstances",
"ec2:DescribeTags",
"ec2:DescribeNetworkInterfaces",
"ec2:DescribeInstanceTypes",
},
"Resource": "*",
},
{
"Effect": "Allow",
"Action": []string{
"ec2:CreateTags",
},
"Resource": fmt.Sprintf("arn:%s:ec2:*:*:network-interface/*", partition),
},
},
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's a logic error so that makeIPv6VPCCNIPolicyDocument() not being called?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting -- looks like that's only applied if the cluster config has either autoApplyPodIdentityAssociations or useDefaultPodIdentityAssociations set (code).

Here are the docs:

EKS Add-ons also support receiving IAM permissions via EKS Pod Identity Associations. The config file exposes three fields that allow configuring these: addon.podIdentityAssociations, addonsConfig.autoApplyPodIdentityAssociations and addon.useDefaultPodIdentityAssociations. You can either explicitly configure the desired pod identity associations, using addon.podIdentityAssociations, or have eksctl automatically resolve (and apply) the recommended pod identity configuration, using either addonsConfig.autoApplyPodIdentityAssociations or addon.useDefaultPodIdentityAssociations.

That being said, I think your docs change is still correct -- the example you're changing is for a cluster with IPv6, and not using pod identity, right?

We could also change the code logic to auto-apply these permissions, but I think updating the docs here is good for now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, should be still valid ClusterConfig.

Actually, I've created an issue before the PR here. Maybe we could track issue there, and merge the PR here first ( to avoid incoming issue report for the missing permission issue ).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer to have another PR to fix the code logic issue, as it might need more test cases for CloudFormation Template generate.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good! I'll go ahead and approve/merge this PR then. Thanks for the contribution!

@guessi guessi force-pushed the fix-ipv6-documentation branch from 41355da to a0cd646 Compare May 28, 2025 23:44
@naclonts naclonts added the kind/docs User documentation label May 29, 2025
@naclonts naclonts merged commit c4de784 into eksctl-io:main May 29, 2025
10 checks passed
@guessi guessi deleted the fix-ipv6-documentation branch May 29, 2025 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants