-
Notifications
You must be signed in to change notification settings - Fork 4k
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] private subnets from other Cluster or Vpc can't be used when importing cluster #10287
Comments
@iliapolo is there a chance it will be fixed anytime soon? We are hitting limit of resources in one CF stack and this issue is blocking us from splitting k8s resources into multiple stacks. |
@stefanolczak Can I ask why are you both creating and importing a cluster in the same CDK application? Mind sharing the full use-case? |
I’m splitting kubernetes manifests and helm charts into multiple stacks to avoid limit of 200 resources in one CF stack. Is there a better way to do it? @iliapolo |
You could just pass and use the cluster construct between stacks. const cluster = new eks.Cluster(clusterStack, ...);
const resource = new eks.KubernetesManifest(manifestsStack, 'Resource', {
cluster: cluster,
manifest: ...
}) Something like this? Same goes for charts. The part i'm struggling to understand in your code is: class ImportedEksStack(core.Stack):
def __init__(self, app: core.App, eks_cluster: aws_eks.Cluster) -> None:
super().__init__(app, 'imported-eks-stack')
aws_eks.Cluster.from_cluster_attributes(
scope=self,
id='eks',
cluster_name=eks_cluster.cluster_name,
kubectl_role_arn=eks_cluster.kubectl_role.role_arn,
kubectl_private_subnet_ids=[subnet.subnet_id for subnet in eks_cluster.kubectl_private_subnets],
kubectl_security_group_id=eks_cluster.kubectl_security_group.security_group_id,
vpc=eks_cluster.vpc
) Why do you need to instantiate an imported cluster when you already have a reference for a regular cluster? You can still use it even in cross-stack, CDK will create the necessary outputs and parameters. |
Oh I didn't realize that I can create manifests and helm charts this way and I was using the addManifest() and addChart() method always. That's why I was looking for a way to call the methods on imported cluster. The new approach you proposed is a lot easier. Thanks |
#9802 introduced a way to import EKS cluster and add k8s resources to it. It can be also used to split resources across multiple stacks when deploying EKS from CDK. This is very helpful because there is a limit of 200 CF resources per stack. But there is a bug in current implementation that requires that
kubectlPrivateSubnets
doesn't include subnet ids that are tokens created from other constructs. This blocks from importing EKS cluster from object created in CDK. To make it work VPC has to be imported from lookup which has it own drawbacks. I believe this bug is easy to fix by changing the way identifiers are generated and passed toec2.Subnet.fromSubnetId()
here:aws-cdk/packages/@aws-cdk/aws-eks/lib/cluster.ts
Line 1587 in 14c8a98
Not including the subnedId in identifier should fix the issue.
Reproduction Steps
kubectlPrivateSubnets
from created object.Code example:
What did you expect to happen?
Cluster can be imported from other cluster object by passing all required information from it.
Also it would be nice to have simpler way to import cluster from existing object. Like I said it supports common scenario of splitting k8s resources across multiple stacks to avoid CF limit of 200 resources per stack.
What actually happened?
Template was unable to synthesize and CDK throws an error:
Environment
Other
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: