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] eks.Cluster.fromAttributes: Allow adding k8s resources on imported clusters #5383

Closed
2 tasks
tpai opened this issue Dec 12, 2019 · 10 comments · Fixed by #9802
Closed
2 tasks

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

tpai opened this issue Dec 12, 2019 · 10 comments · Fixed by #9802
Assignees
Labels
@aws-cdk/aws-eks Related to Amazon Elastic Kubernetes Service effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2

Comments

@tpai
Copy link

tpai commented Dec 12, 2019

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

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

This is a 🚀 Feature Request

@tpai tpai added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Dec 12, 2019
@SomayaB SomayaB added @aws-cdk/aws-eks Related to Amazon Elastic Kubernetes Service guidance Question that needs advice or information. labels Dec 13, 2019
@eladb eladb added effort/large Large work item – several weeks of effort effort/small Small work item – less than a day of effort and removed effort/large Large work item – several weeks of effort guidance Question that needs advice or information. labels Jan 22, 2020
@jargelo
Copy link

jargelo commented Mar 4, 2020

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?

@SomayaB SomayaB removed the needs-triage This issue or PR still needs to be triaged. label Mar 5, 2020
@eladb
Copy link
Contributor

eladb commented Mar 9, 2020

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

@eladb eladb added the p2 label Mar 9, 2020
@chrisdrobison
Copy link

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.

@eladb
Copy link
Contributor

eladb commented Apr 1, 2020

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?

@chrisdrobison
Copy link

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

@cc4i
Copy link

cc4i commented Apr 28, 2020

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

@adrialucena-seat
Copy link

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.

@eladb eladb added this to the EKS Developer Preview milestone Jun 24, 2020
@eladb eladb changed the title Call addResource from an existing EKS cluster [EKS Feature] Call addResource from an existing EKS cluster Jun 24, 2020
@eladb eladb changed the title [EKS Feature] Call addResource from an existing EKS cluster [EKS Feature] Allow adding k8s resources on imported EKS cluster Jun 24, 2020
@eladb eladb changed the title [EKS Feature] Allow adding k8s resources on imported EKS cluster [EKS Feature] Allow adding k8s resources on imported clusters Jun 24, 2020
@eladb eladb removed this from the EKS Developer Preview milestone Jun 24, 2020
@adrialucena-seat
Copy link

Any workarround for this until a final implementation?

@eladb eladb added this to the EKS Dev Preview milestone Jul 22, 2020
@eladb eladb changed the title [EKS Feature] Allow adding k8s resources on imported clusters [EKS Feature] eks.Cluster.fromAttributes: Allow adding k8s resources on imported clusters Aug 4, 2020
mergify bot pushed a commit that referenced this issue Aug 10, 2020
…9544)

Fixes #9542 
Related #5383 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
eladb pushed a commit that referenced this issue Aug 10, 2020
…9544)

Fixes #9542 
Related #5383 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@adrialucena-seat
Copy link

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.

@iliapolo iliapolo added the in-progress This issue is being actively worked on. label Aug 16, 2020
@iliapolo iliapolo changed the title [EKS Feature] eks.Cluster.fromAttributes: Allow adding k8s resources on imported clusters [aws-eks] eks.Cluster.fromAttributes: Allow adding k8s resources on imported clusters Aug 16, 2020
eladb pushed a commit that referenced this issue Aug 18, 2020
Allow adding Kubernetes resources such as manifests and Helm charts to imported clusters (`eks.Cluster.fromAttributes`).

To enable this behavior, when the cluster is imported, users will have to specify additional information:

 - `kubectlRole` - an IAM role that can issue kubectl commands against the cluster
 - `kubectlEnvironment` (optional) - environment variables for `kubectl`.
 - `kubectlPrivateSubnets` and `kubectlSecurityGroup` - required if the cluster's k8s endpoint is private

Resolves #5383
@ten-lac
Copy link

ten-lac commented Aug 25, 2020

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.

@mergify mergify bot closed this as completed in #9802 Sep 2, 2020
mergify bot pushed a commit that referenced this issue Sep 2, 2020
Allow adding Kubernetes resources such as manifests and Helm charts to imported clusters (`eks.Cluster.fromAttributes`).

To enable this behavior, when the cluster is imported, users will have to specify additional information:

 - `kubectlRole` - an IAM role that can issue kubectl commands against the cluster
 - `kubectlEnvironment` (optional) - environment variables for `kubectl`.
 - `kubectlPrivateSubnets` and `kubectlSecurityGroup` - required if the cluster's k8s endpoint is private

Resolves #5383

BREAKING CHANGE: when importing EKS clusters using `eks.Cluster.fromClusterAttributes`, the `clusterArn` attribute is not supported anymore, and will always be derived from `clusterName`.
* **eks**: Only a single `eks.Cluster` is allowed per CloudFormation stack.
* **eks**: The `securityGroups` attribute of `ClusterAttributes` is now `securityGroupIds`.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@iliapolo iliapolo removed the in-progress This issue is being actively worked on. label Sep 9, 2020
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/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants