Skip to content
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

[Karpenter] Cannot configure node role policy in KarpenterAddOn #893

Closed
1 task
Shellmode opened this issue Dec 17, 2023 · 9 comments
Closed
1 task

[Karpenter] Cannot configure node role policy in KarpenterAddOn #893

Shellmode opened this issue Dec 17, 2023 · 9 comments
Assignees

Comments

@Shellmode
Copy link

Shellmode commented Dec 17, 2023

Describe the feature

Since the policies of node role and service account are hardcode, there is no way to configure the policy of nodes created by Karpenter in cdk-eks-blueprints.

I can only modify the policy in another way which is not so IaC.

Use Case

Define policy of nodes created by Karpenter as needed.

Proposed Solution

No response

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request

CDK version used

2.105.0

EKS Blueprints Version

No response

Node.js Version

v20.9.0

Environment details (OS name and version, etc.)

MacOS 14.1.2 (23B92)

@shapirov103
Copy link
Collaborator

@youngjeong46 please take a look when you get a chance and let me know on the LOE.

@youngjeong46
Copy link
Collaborator

@Shellmode I'm trying to understand this better.

  1. There are two roles in question - Node Role that gets attached to the Karpenter nodes, and the role for the controller that gets attached to the service account, and which the karpenter controller uses to provision instances. Are you trying to replace both with your custom roles? What would be the reasoning?
  2. Would your ideal feature here be to 1/ provide additional policy on top of what is being generated, or 2/ provide a new role all together (which you as a user would manage to make sure it has the minimal required policy to operate Karpenter functionally)?

@Shellmode
Copy link
Author

@Shellmode I'm trying to understand this better.

  1. There are two roles in question - Node Role that gets attached to the Karpenter nodes, and the role for the controller that gets attached to the service account, and which the karpenter controller uses to provision instances. Are you trying to replace both with your custom roles? What would be the reasoning?

  2. Would your ideal feature here be to 1/ provide additional policy on top of what is being generated, or 2/ provide a new role all together (which you as a user would manage to make sure it has the minimal required policy to operate Karpenter functionally)?

First question, the role of the nodes which are scaled in or scaled out by karpenter.

It's a common situation that worker nodes(karpenter scale them in or out) need various of permissions to finish tasks.

Second question, I think additional policy will be better, because developers always focus on the permissions and don't want to define another role resource.

@jsamuel1
Copy link
Contributor

+1. Hitting this now, when trying to configure CloudwatchInsightsAddon with Karpenter. No easy way to configure the extra permissions needed.
Ideally, I just want to either pass in the extra policies, or expose the role out from the addon, so that I can add to it after creation.

@yubingjiaocn
Copy link

yubingjiaocn commented Jun 12, 2024

private setUpNodeRole(cluster: Cluster, stackName: string, region: string): [iam.Role, iam.CfnInstanceProfile] {
// Set up Node Role
const karpenterNodeRole = new iam.Role(cluster, 'karpenter-node-role', {
assumedBy: new iam.ServicePrincipal(`ec2.${cluster.stack.urlSuffix}`),
managedPolicies: [
iam.ManagedPolicy.fromAwsManagedPolicyName("AmazonEKSWorkerNodePolicy"),
iam.ManagedPolicy.fromAwsManagedPolicyName("AmazonEKS_CNI_Policy"),
iam.ManagedPolicy.fromAwsManagedPolicyName("AmazonEC2ContainerRegistryReadOnly"),
iam.ManagedPolicy.fromAwsManagedPolicyName("AmazonSSMManagedInstanceCore"),
],
//roleName: `KarpenterNodeRole-${name}` // let role name to be generated as unique
});

Karpenter add-on creates node role with a fixed logical name karpenter-node-role. You can use clusterInfo.cluster.node.findChild('karpenter-node-role') as iam.IRole to refer to node IAM role created by Karpenter. After fetched the role you can add policy by attachInlinePolicy("your-policy") or add managed policy.

@jsamuel1
Copy link
Contributor

jsamuel1 commented Jun 13, 2024

Karpenter add-on creates node role with a fixed logical name karpenter-node-role. You can use clusterInfo.cluster.node.findChild('karpenter-node-role') as iam.IRole to refer to node IAM role created by Karpenter. After fetched the role you can add policy by attachInlinePolicy("your-policy") or add managed policy.

If this logical name is fixed, can we document the recommended way in the KarpenterAddon docs?

@Shellmode
Copy link
Author

@yubingjiaocn thanks for providing the walk around, I'll try that to make the system more IaC.

Copy link

This issue has been automatically marked as stale because it has been open 60 days
with no activity. Remove stale label or comment or this issue will be closed in 10 days

Copy link

Issue closed due to inactivity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants