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

eks: cannot deploy multiple EKS clusters within the same stack #31942

Open
1 task
badmintoncryer opened this issue Oct 29, 2024 · 2 comments
Open
1 task

eks: cannot deploy multiple EKS clusters within the same stack #31942

badmintoncryer opened this issue Oct 29, 2024 · 2 comments
Labels
@aws-cdk/aws-eks Related to Amazon Elastic Kubernetes Service bug This issue is a bug. effort/medium Medium work item – several days of effort p2

Comments

@badmintoncryer
Copy link
Contributor

Describe the bug

We cannot use multiple EKS clusters within the same stack.

It seems that the cause is the hardcoded ID of the KubectlLayer.

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

2.160.0

Expected Behavior

Deploys successfully.

Current Behavior

Fails to deploy.

Reproduction Steps

import * as eks from 'aws-cdk-lib/aws-eks';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import { getClusterVersionConfig } from './integ-tests-kubernetes-version';

class MultipleEksClusterStack extends Stack {
  constructor(scope: App, id: string) {
    super(scope, id);

    const vpc = new ec2.Vpc(this, 'Vpc', { natGateways: 1 });
    new eks.Cluster(this, 'EnabledCluster', {
      vpc,
      ...getClusterVersionConfig(this, eks.KubernetesVersion.V1_30),
      bootstrapSelfManagedAddons: true,
    });
    new eks.Cluster(this, 'DisabledCluster', {
      vpc,
      ...getClusterVersionConfig(this, eks.KubernetesVersion.V1_30),
      bootstrapSelfManagedAddons: false,
    });
  }
}

Results

/Users/kazuhoshinozuka/git/aws-cdk/node_modules/constructs/lib/construct.js:375
            throw new Error(`There is already a Construct with name '${childName}' in ${typeName}${name.length > 0 ? ' [' + name + ']' : ''}`);
            ^

Error: There is already a Construct with name 'KubectlLayer' in MultipleEksClusterStack [EksClusterStack]
    at Node.addChild (/Users/kazuhoshinozuka/git/aws-cdk/node_modules/constructs/lib/construct.js:375:19)
    at new Node (/Users/kazuhoshinozuka/git/aws-cdk/node_modules/constructs/lib/construct.js:38:21)
    at new Construct (/Users/kazuhoshinozuka/git/aws-cdk/node_modules/constructs/lib/construct.js:426:21)
    at new Resource (/Users/kazuhoshinozuka/git/aws-cdk/packages/aws-cdk-lib/core/lib/resource.js:32:9)
    at new LayerVersion (/Users/kazuhoshinozuka/git/aws-cdk/packages/aws-cdk-lib/aws-lambda/lib/layers.js:57:9)
    at new KubectlV30Layer (/Users/kazuhoshinozuka/git/aws-cdk/node_modules/@aws-cdk/lambda-layer-kubectl-v30/lib/kubectl-layer.js:13:9)
    at getClusterVersionConfig (/Users/kazuhoshinozuka/git/aws-cdk/packages/@aws-cdk-testing/framework-integ/test/aws-eks/test/integ-tests-kubernetes-version.js:27:23)
    at new EksClusterStack (/Users/kazuhoshinozuka/git/aws-cdk/packages/@aws-cdk-testing/framework-integ/test/aws-eks/test/integ.eks-bootstrap-self-managed-addons.js:19:77)
    at Object.<anonymous> (/Users/kazuhoshinozuka/git/aws-cdk/packages/@aws-cdk-testing/framework-integ/test/aws-eks/test/integ.eks-bootstrap-self-managed-addons.js:25:15)
    at Module._compile (node:internal/modules/cjs/loader:1546:14)

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.160.0

Framework Version

No response

Node.js Version

v22.9.0

OS

macOS

Language

TypeScript

Language Version

No response

Other information

No response

@badmintoncryer badmintoncryer added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 29, 2024
@github-actions github-actions bot added the @aws-cdk/aws-eks Related to Amazon Elastic Kubernetes Service label Oct 29, 2024
@xazhao
Copy link
Contributor

xazhao commented Oct 30, 2024

Hi @badmintoncryer thanks for raising this issue. It's one of current aws-eks limitations. See this for detail.

We are planning to address the issue in the new eksv2 though. This is the tracking RFC: aws/aws-cdk-rfcs#605

@badmintoncryer
Copy link
Contributor Author

@xazhao Thank you for your detail information!
I understand very well.

@pahud pahud added p2 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Oct 30, 2024
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 bug This issue is a bug. effort/medium Medium work item – several days of effort p2
Projects
None yet
Development

No branches or pull requests

3 participants