-
Notifications
You must be signed in to change notification settings - Fork 4.5k
fix(eks): throw error when kubectl subnets are isolated #37217
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
Changes from 1 commit
e3affa9
884df35
e2b9439
5b49d8d
ff5d68c
eeff970
28b830a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1868,6 +1868,23 @@ export class Cluster extends ClusterBase { | |
| throw new ValidationError('Private endpoint access requires the VPC to have DNS support and DNS hostnames enabled. Use `enableDnsHostnames: true` and `enableDnsSupport: true` when creating the VPC.', this); | ||
| } | ||
|
|
||
| // Validate that kubectl subnets are not isolated. Isolated subnets have no | ||
| // internet access by definition, so the kubectl Lambda will not be able to | ||
| // reach the EKS API, STS, or other AWS service endpoints required for | ||
| // kubectl operations (including the CoreDNS compute type patch). | ||
| // See https://github.com/aws/aws-cdk/issues/26613 | ||
| const isolatedSubnetIds = new Set(this.vpc.isolatedSubnets.map(s => s.subnetId)); | ||
| const hasIsolatedSubnets = privateSubnets.some(s => isolatedSubnetIds.has(s.subnetId)); | ||
| if (hasIsolatedSubnets) { | ||
| throw new ValidationError( | ||
| 'Isolated subnets cannot be used for kubectl private subnets. Isolated subnets have no internet access, ' | ||
| + 'which is required for the kubectl Lambda to reach the EKS API, STS, and other AWS service endpoints. ' | ||
| + 'Use PRIVATE_WITH_EGRESS subnets with a NAT Gateway instead, or configure VPC endpoints for STS, EKS, and ECR. ' | ||
| + 'See https://docs.aws.amazon.com/eks/latest/userguide/private-clusters.html', | ||
| this, | ||
|
||
| ); | ||
| } | ||
|
||
|
|
||
| this.kubectlPrivateSubnets = privateSubnets; | ||
|
|
||
| // the vpc must exist in order to properly delete the cluster (since we run `kubectl delete`). | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as the
aws-eksmodule — consider adding thethis.vpc instanceof ec2.Vpcguard here for consistency with the DNS validation at line 1384 and to avoid blocking users with VPC endpoints on imported VPCs.Per the AWS private clusters documentation, isolated subnets with VPC endpoints are a supported configuration.