Skip to content

Commit 4e858f2

Browse files
authored
feat(eks): support for Kubernetes version 1.23 (#22638)
Add support for Kubernetes Version 1.23. In order to use this version, customers must pass in a `KubectlLayer` object from `@aws-cdk/lambda-layer-kubectl-v23` to the `kubectlLayer` construct prop of `Cluster`. ---- ### All Submissions: * [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 66d1ed3 commit 4e858f2

File tree

63 files changed

+220
-164
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+220
-164
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@
9191
"@aws-cdk/aws-cognito/punycode/**",
9292
"@aws-cdk/aws-ecr-assets/minimatch",
9393
"@aws-cdk/aws-ecr-assets/minimatch/**",
94+
"@aws-cdk/aws-eks/semver",
95+
"@aws-cdk/aws-eks/semver/**",
9496
"@aws-cdk/aws-eks/yaml",
9597
"@aws-cdk/aws-eks/yaml/**",
9698
"@aws-cdk/aws-events-targets/aws-sdk",

packages/@aws-cdk/aws-eks/lib/cluster.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as lambda from '@aws-cdk/aws-lambda';
88
import * as ssm from '@aws-cdk/aws-ssm';
99
import { Annotations, CfnOutput, CfnResource, IResource, Resource, Stack, Tags, Token, Duration, Size } from '@aws-cdk/core';
1010
import { Construct, Node } from 'constructs';
11+
import * as semver from 'semver';
1112
import * as YAML from 'yaml';
1213
import { AlbController, AlbControllerOptions } from './alb-controller';
1314
import { AwsAuth } from './aws-auth';
@@ -853,6 +854,15 @@ export class KubernetesVersion {
853854
*/
854855
public static readonly V1_22 = KubernetesVersion.of('1.22');
855856

857+
/**
858+
* Kubernetes version 1.23
859+
*
860+
* When creating a `Cluster` with this version, you need to also specify the
861+
* `kubectlLayer` property with a `KubectlV23Layer` from
862+
* `@aws-cdk/lambda-layer-kubectl-v23`.
863+
*/
864+
public static readonly V1_23 = KubernetesVersion.of('1.23');
865+
856866
/**
857867
* Custom cluster version
858868
* @param version custom version number
@@ -1372,8 +1382,9 @@ export class Cluster extends ClusterBase {
13721382
this.prune = props.prune ?? true;
13731383
this.vpc = props.vpc || new ec2.Vpc(this, 'DefaultVpc');
13741384

1375-
if (props.version === KubernetesVersion.V1_22 && !props.kubectlLayer) {
1376-
Annotations.of(this).addWarning(`You created a cluster with Kubernetes Version ${props.version} without specifying the kubectlLayer property. This may cause failures as the kubectl version provided with aws-cdk-lib is 1.20, which is only guaranteed to be compatible with Kubernetes versions 1.19-1.21. Please provide a kubectlLayer from @aws-cdk/lambda-layer-kubectl-v22.`);
1385+
const kubectlVersion = new semver.SemVer(`${props.version.version}.0`);
1386+
if (semver.gte(kubectlVersion, '1.22.0') && !props.kubectlLayer) {
1387+
Annotations.of(this).addWarning(`You created a cluster with Kubernetes Version ${props.version.version} without specifying the kubectlLayer property. This may cause failures as the kubectl version provided with aws-cdk-lib is 1.20, which is only guaranteed to be compatible with Kubernetes versions 1.19-1.21. Please provide a kubectlLayer from @aws-cdk/lambda-layer-kubectl-v${kubectlVersion.minor}.`);
13771388
};
13781389
this.version = props.version;
13791390
this.kubectlLambdaRole = props.kubectlLambdaRole ? props.kubectlLambdaRole : undefined;

packages/@aws-cdk/aws-eks/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@
8080
},
8181
"license": "Apache-2.0",
8282
"devDependencies": {
83-
"@aws-cdk/lambda-layer-kubectl-v22": "2.0.0",
84-
"aws-cdk-lib": "2.47.0",
83+
"@aws-cdk/lambda-layer-kubectl-v23": "^2.0.0",
84+
"aws-cdk-lib": "^2.47.0",
8585
"@aws-cdk/assertions": "0.0.0",
8686
"@aws-cdk/cdk-build-tools": "0.0.0",
8787
"@aws-cdk/integ-runner": "0.0.0",
@@ -95,7 +95,7 @@
9595
"aws-sdk": "^2.1211.0",
9696
"cdk8s": "^2.5.28",
9797
"cdk8s-plus-21": "^2.0.0-beta.12",
98-
"cdk8s-plus-22": "^2.0.0-rc.158",
98+
"cdk8s-plus-23": "2.0.2",
9999
"jest": "^27.5.1",
100100
"sinon": "^9.2.4"
101101
},
@@ -113,9 +113,11 @@
113113
"@aws-cdk/lambda-layer-kubectl": "0.0.0",
114114
"@aws-cdk/lambda-layer-node-proxy-agent": "0.0.0",
115115
"constructs": "^10.0.0",
116+
"semver": "^7.3.8",
116117
"yaml": "1.10.2"
117118
},
118119
"bundledDependencies": [
120+
"semver",
119121
"yaml"
120122
],
121123
"homepage": "https://github.com/aws/aws-cdk",

packages/@aws-cdk/aws-eks/test/alb-controller.integ.snapshot/aws-cdk-eks-cluster-alb-controller-test.assets.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"version": "21.0.0",
33
"files": {
4-
"c0f40a9fd16d1698ca05765606c04c8724dc5c8355b6e124a39af09449a3aa30": {
4+
"dd8086b05eeea461708bd66ad140d8965ddf70c0e144af871d078fdbddf0a67d": {
55
"source": {
6-
"path": "asset.c0f40a9fd16d1698ca05765606c04c8724dc5c8355b6e124a39af09449a3aa30.zip",
6+
"path": "asset.dd8086b05eeea461708bd66ad140d8965ddf70c0e144af871d078fdbddf0a67d.zip",
77
"packaging": "file"
88
},
99
"destinations": {
1010
"current_account-current_region": {
1111
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12-
"objectKey": "c0f40a9fd16d1698ca05765606c04c8724dc5c8355b6e124a39af09449a3aa30.zip",
12+
"objectKey": "dd8086b05eeea461708bd66ad140d8965ddf70c0e144af871d078fdbddf0a67d.zip",
1313
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
1414
}
1515
}
@@ -144,15 +144,15 @@
144144
}
145145
}
146146
},
147-
"c6b7a3e3c841118ec365de6b3227d6ec23618b7716c20175c7f18822b22fa08d": {
147+
"1e8f5b9efc22fb7df3c3a0e894ec6ddf91d5b71c100c70638ff47b2379c3a749": {
148148
"source": {
149149
"path": "aws-cdk-eks-cluster-alb-controller-test.template.json",
150150
"packaging": "file"
151151
},
152152
"destinations": {
153153
"current_account-current_region": {
154154
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
155-
"objectKey": "c6b7a3e3c841118ec365de6b3227d6ec23618b7716c20175c7f18822b22fa08d.json",
155+
"objectKey": "1e8f5b9efc22fb7df3c3a0e894ec6ddf91d5b71c100c70638ff47b2379c3a749.json",
156156
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
157157
}
158158
}

packages/@aws-cdk/aws-eks/test/alb-controller.integ.snapshot/aws-cdk-eks-cluster-alb-controller-test.template.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,9 +402,9 @@
402402
"S3Bucket": {
403403
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
404404
},
405-
"S3Key": "c0f40a9fd16d1698ca05765606c04c8724dc5c8355b6e124a39af09449a3aa30.zip"
405+
"S3Key": "dd8086b05eeea461708bd66ad140d8965ddf70c0e144af871d078fdbddf0a67d.zip"
406406
},
407-
"Description": "/opt/kubectl/kubectl 1.22; /opt/helm/helm 3.9",
407+
"Description": "/opt/kubectl/kubectl 1.23; /opt/helm/helm 3.9",
408408
"LicenseInfo": "Apache-2.0"
409409
}
410410
},
@@ -608,7 +608,7 @@
608608
]
609609
},
610610
"Config": {
611-
"version": "1.22",
611+
"version": "1.23",
612612
"roleArn": {
613613
"Fn::GetAtt": [
614614
"ClusterRoleFA261979",

packages/@aws-cdk/aws-eks/test/alb-controller.integ.snapshot/manifest.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"validateOnSynth": false,
2424
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
2525
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
26-
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/c6b7a3e3c841118ec365de6b3227d6ec23618b7716c20175c7f18822b22fa08d.json",
26+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/1e8f5b9efc22fb7df3c3a0e894ec6ddf91d5b71c100c70638ff47b2379c3a749.json",
2727
"requiresBootstrapStackVersion": 6,
2828
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
2929
"additionalDependencies": [
@@ -168,7 +168,10 @@
168168
"/aws-cdk-eks-cluster-alb-controller-test/KubectlLayer/Resource": [
169169
{
170170
"type": "aws:cdk:logicalId",
171-
"data": "KubectlLayer600207B5"
171+
"data": "KubectlLayer600207B5",
172+
"trace": [
173+
"!!DESTRUCTIVE_CHANGES: WILL_REPLACE"
174+
]
172175
}
173176
],
174177
"/aws-cdk-eks-cluster-alb-controller-test/Cluster/Role/Resource": [

packages/@aws-cdk/aws-eks/test/alb-controller.integ.snapshot/tree.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -691,9 +691,9 @@
691691
"s3Bucket": {
692692
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
693693
},
694-
"s3Key": "c0f40a9fd16d1698ca05765606c04c8724dc5c8355b6e124a39af09449a3aa30.zip"
694+
"s3Key": "dd8086b05eeea461708bd66ad140d8965ddf70c0e144af871d078fdbddf0a67d.zip"
695695
},
696-
"description": "/opt/kubectl/kubectl 1.22; /opt/helm/helm 3.9",
696+
"description": "/opt/kubectl/kubectl 1.23; /opt/helm/helm 3.9",
697697
"licenseInfo": "Apache-2.0"
698698
}
699699
},
@@ -704,7 +704,7 @@
704704
}
705705
},
706706
"constructInfo": {
707-
"fqn": "@aws-cdk/lambda-layer-kubectl-v22.KubectlV22Layer",
707+
"fqn": "@aws-cdk/lambda-layer-kubectl-v23.KubectlV23Layer",
708708
"version": "2.0.0"
709709
}
710710
},

0 commit comments

Comments
 (0)