Aws-cdk: [aws-eks] eks.Cluster.fromAttributes: Allow adding k8s resources on imported clusters

Created on 12 Dec 2019  路  10Comments  路  Source: aws/aws-cdk

Currently I have an existing EKS cluster, is that possible to call addResource from another pipeline or someplace?

Use Case

I tried to use fromClusterAttributes, but it only returns a ImportedCluster which does not have any static method.

It will be good to have:

const cluster = new eks.Cluster.fromClusterAttributes(this, 'eks-cluster', {...});
cluster.addResource('ingress', {...});
cluster.addResource('service', {...});

Other

  • [ ] :wave: I may be able to implement this feature request
  • [ ] :warning: This feature might incur a breaking change

This is a :rocket: Feature Request

@aws-cdaws-eks efforsmall feature-request p2

Most helpful comment

In my case we have multiple repositories and each of them creates different part of infrastructure using CDK. Some repo needs to create an eks fargate profile o apply some manifest through addResource method to a same cluster. Is there any workarround for this since we can't import the cluster for every repo and use this kind of methods? (creating a cluster for every repo would be over dimensioned).
It would be a great feature.

All 10 comments

I am trying to achieve the same. Now I am sharing my eks cluster around stack code so I can call addResource from different stacks. However it seems like it all ends up in the same stack by doing this. What's the best way of achieving this for now?

Can you guys please describe your use case? What are you trying to achieve by doing this?

Well, for us, we created our EKS cluster using cloudformation before eksctl was a thing. Eksctl is pretty worthless to us because unless you start with it, you can never use it thereafter. It would be nice to be able to import a cluster in CDK and add autoscaling groups, for example, and have their roles automatically added to the cluster so that can just join, like it does today starting with the CDK.

Unfortunately I think it may be quite challenging to support this capability. I am wondering, is there a way to make it easier for you to recreate the EKS cluster through the CDK?

Yeah, I've thought about recreating the cluster, it would just require some careful planning.

It's a great feature to help customer operate everything through CDK.

In my case we have multiple repositories and each of them creates different part of infrastructure using CDK. Some repo needs to create an eks fargate profile o apply some manifest through addResource method to a same cluster. Is there any workarround for this since we can't import the cluster for every repo and use this kind of methods? (creating a cluster for every repo would be over dimensioned).
It would be a great feature.

Any workarround for this until a final implementation?

Another problem we have find out related to this issue is that using addResource method from different stacks in the same app (passing the cluster as argument to the stack that calls addResource) the cloudformation resource is actually created on the stack where the EKS Cluster was created instead of the stack where the addResource was called. This wouldn't be a problem itself if Cloudfromation didn't have the 200 resource limit per stack.
We have reached this limit because all the stacks are almost empty and all k8s resources are created on the stack where the cluster was created.
We don't know how to solve this problem unless every stack could import the cluster and call addResource and create the cloudformation resource separately.

Another purpose of having a fully capable ImportedCluster would solve the dreaded circular dependency issues. With the limited 200 objects per Cloudformation stack limit, we are forced to code separate into stacks. Having tried to code separate out the Kubernetes Resources (manifest/helmchart), they all inherently run into a circular dependency when you try to add relationship overlays between these resources. Say you need to create a Namespace before you run the Helm chart. The only way to overcome it is to have a copy of the cluster object in the Stack itself.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

artyom-melnikov picture artyom-melnikov  路  3Comments

eladb picture eladb  路  3Comments

pepastach picture pepastach  路  3Comments

eladb picture eladb  路  3Comments

NukaCody picture NukaCody  路  3Comments