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

[AWS EKS]: L2 EKS constructs which use L1s instead of custom resources #24059

Open
2 tasks
jbhalla-godaddy opened this issue Feb 7, 2023 · 9 comments
Open
2 tasks
Labels
@aws-cdk/aws-eks Related to Amazon Elastic Kubernetes Service effort/large Large work item – several weeks of effort feature-request A feature should be added or improved. in-progress This issue is being actively worked on. p1

Comments

@jbhalla-godaddy
Copy link

Describe the feature

We created an EKS Cluster via CDK V2 (2.63.1) using the L2 Construct (code shown below) and noticed that the creation of the cluster created multiple resources including some custom resource lambdas.

Sample Code to create a test EKS Cluster using L2 Construct

import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';

export class TestingStack extends cdk.Stack {
    constructor(scope: Construct, id: string, props?: cdk.StackProps) {
        super(scope, id, props);

        const eksCluster = new cdk.aws_eks.Cluster(this, 'simple-eks-cluster', {
            version: cdk.aws_eks.KubernetesVersion.V1_21,
        });
        console.log(eksCluster)
    }
}

From a deeper investigation we understand that CDK's EKS L2 construct deploys some custom resource lambdas that use AWS SDK inside those lambdas to actually create the EKS cluster.

The objective of this ticket is to understand why did you choose to use AWS SDK to create the cluster (via custom resource lambda) and not used CloudFormation (AWS::EKS::Cluster) to create the EKS Cluster?

We are seeking to understand the design decision behind this implementation.

Use Case

We are using CloudFormation to deploy all our AWS Resources with CloudFormation Hooks to govern certain configurations for our customers.

Now, we want to restrict our customers to only create EKS clusters via CDK using CloudFormation, but because the current version of EKS L2 Construct doesn't use CloudFormation to create EKS Cluster, the CloudFormation Hooks doesn't get triggered when we use EKS L2 Construct which makes it harder for us to govern our customers.

Proposed Solution

Is it possible for AWS CDK to update the EKS L2 construct to create the EKS Cluster using CloudFormation (AWS::EKS::Cluster) instead of AWS SDK

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.62.0

Environment details (OS name and version, etc.)

MacOS

@jbhalla-godaddy jbhalla-godaddy added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Feb 7, 2023
@github-actions github-actions bot added the @aws-cdk/aws-eks Related to Amazon Elastic Kubernetes Service label Feb 7, 2023
@jbhalla-godaddy
Copy link
Author

CC'ing @shapirov103 @rameshv29 @dsilbergleithcu-godaddy on this one

@peterwoodworth
Copy link
Contributor

Our L2 EKS constructs use custom resources because we are able to achieve more functionality through custom resources than just through using what CloudFormation offers. I don't remember off the top of my head everything that CloudFormation doesn't support though

I think it would be unlikely we implement L2 EKS constructs that make use of the L1s, but we can leave this open to gather more feedback on this. If we were to start working on this, an RFC would have to be approved first, so I recommend creating an issue in the RFCs repo if you're interested in this.

I would overall recommend to drop to L1s if you need to use the resources CloudFormation offers instead of custom resources

@peterwoodworth peterwoodworth added p2 effort/large Large work item – several weeks of effort and removed needs-triage This issue or PR still needs to be triaged. labels Feb 8, 2023
@peterwoodworth peterwoodworth changed the title [AWS EKS]: Creation of EKS Custer using CloudFormation instead of AWS SDK via EKS L2 Construct [AWS EKS]: L2 EKS constructs which use L1s instead of custom resources Feb 8, 2023
@pahud
Copy link
Contributor

pahud commented Feb 8, 2023

@jbhalla-godaddy

As far as I know, if we deploy EKS with cloudformation CfnCluster L1 resource, the admin role of the cluster will be the CFN deploying role. With the admin role, we need a few follow up steps to complete the whole deployment including to update the aws-auth ConfigMap with kubectl CLI to add the nodegroup role into it, which is performed by a Lambda function as the cluster admin role.

With that being said, the lambda function running kubectl command would have to be the CFN deploying role which creates the cluster and this could be a concern if we need to separate the CFN deploying role and the EKS cluster role.

With current design, we create a new IAM admin role for cluster creation and allow this role to run kubectl against the cluster from lambda function so the cluster admin role will not be bound to the CFN deploying role.

I probably missed some other context but back to the early days when EKS was first launched there were a lot of restrictions and current design was one of the best alternatives for CDK to create a fully working EKS cluster. I agree there are some pros and cons with current design and I believe there's no reason for the team not to re-visit a new implementation for EKS cluster provisioning with the native CFN resources. Any comments or thoughts is highly welcome and appreciated here.

@gricey432
Copy link

I believe this is now possible thanks to the new eks feature "Access Entries". According to the docs [1] this is now the recommended option for granting access.

[1] https://docs.aws.amazon.com/eks/latest/userguide/access-entries.html

I've gone ahead and made a proof of concept for this which I've got deployed and successfully using kubectl to get a value out of a new cluster. https://github.com/gricey432/cdk-eks-poc

Extra Links:

@gricey432
Copy link

Looks like there's an RFC for this now aws/aws-cdk-rfcs#605

@pahud
Copy link
Contributor

pahud commented Apr 10, 2024

@gricey432

Yes we have the plan for the rewrite per the RFC aws/aws-cdk-rfcs#605

@pahud pahud added p1 and removed p2 labels Apr 10, 2024
@adamjkeller adamjkeller added the in-progress This issue is being actively worked on. label May 23, 2024
@adamjkeller
Copy link
Contributor

Hey y’all,

As part of our goal to improve service coverage with CDK constructs, we are actively working on this feature! While we can’t commit to specific dates, we’re making progress and will keep you updated along the way. Your feedback and support are helping us shape the roadmap, so thank you!

@xazhao
Copy link
Contributor

xazhao commented Oct 22, 2024

Hi all,

We have started the RFC process for the EKS L2 Re-write. Will post updates here and share the RFC in aws/aws-cdk-rfcs#605 once it's ready.

@xazhao
Copy link
Contributor

xazhao commented Nov 14, 2024

This is the RFC for EKS Re-write. Feel free to take a read and leave comments there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-eks Related to Amazon Elastic Kubernetes Service effort/large Large work item – several weeks of effort feature-request A feature should be added or improved. in-progress This issue is being actively worked on. p1
Projects
None yet
Development

No branches or pull requests

6 participants