Skip to content

Commit

Permalink
Revert "feat(eks): add k8s v1.22 (aws#19756)"
Browse files Browse the repository at this point in the history
This commit reverts addition of the latest version of EKS (1.22) to CDK as there are some incompatibilities between the current lambda-layer-kubectl and v1.22 EKS cluster.
Preferably we would have multiple versions fo kubectl lambda layer, but we are currently struggling with package size issues. kubectl is large, and our package is larger,
and adding multiple kubectls to it will make it exceed size limits of package managers. So we can't do this right now, until we have invested significant engineering
effort into lifting those limitations. In order to not break the backward compatibility with <=1.20 versions, it was decided to revert this addition PR until
all the underlying issues around package size issues are resolved.

This reverts commit 9a518c5.
  • Loading branch information
robertd committed Apr 21, 2022
1 parent 10f5ede commit c97636f
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 52 deletions.
38 changes: 19 additions & 19 deletions packages/@aws-cdk/aws-eks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ This example defines an Amazon EKS cluster with the following configuration:
```ts
// provisiong a cluster
const cluster = new eks.Cluster(this, 'hello-eks', {
version: eks.KubernetesVersion.V1_22,
version: eks.KubernetesVersion.V1_21,
});

// apply a kubernetes manifest to the cluster
Expand Down Expand Up @@ -143,15 +143,15 @@ Creating a new cluster is done using the `Cluster` or `FargateCluster` construct

```ts
new eks.Cluster(this, 'HelloEKS', {
version: eks.KubernetesVersion.V1_22,
version: eks.KubernetesVersion.V1_21,
});
```

You can also use `FargateCluster` to provision a cluster that uses only fargate workers.

```ts
new eks.FargateCluster(this, 'HelloEKS', {
version: eks.KubernetesVersion.V1_22,
version: eks.KubernetesVersion.V1_21,
});
```

Expand All @@ -175,7 +175,7 @@ At cluster instantiation time, you can customize the number of instances and the

```ts
new eks.Cluster(this, 'HelloEKS', {
version: eks.KubernetesVersion.V1_22,
version: eks.KubernetesVersion.V1_21,
defaultCapacity: 5,
defaultCapacityInstance: ec2.InstanceType.of(ec2.InstanceClass.M5, ec2.InstanceSize.SMALL),
});
Expand All @@ -187,7 +187,7 @@ Additional customizations are available post instantiation. To apply them, set t

```ts
const cluster = new eks.Cluster(this, 'HelloEKS', {
version: eks.KubernetesVersion.V1_22,
version: eks.KubernetesVersion.V1_21,
defaultCapacity: 0,
});

Expand Down Expand Up @@ -345,7 +345,7 @@ The following code defines an Amazon EKS cluster with a default Fargate Profile

```ts
const cluster = new eks.FargateCluster(this, 'MyCluster', {
version: eks.KubernetesVersion.V1_22,
version: eks.KubernetesVersion.V1_21,
});
```

Expand Down Expand Up @@ -422,7 +422,7 @@ You can also configure the cluster to use an auto-scaling group as the default c

```ts
const cluster = new eks.Cluster(this, 'HelloEKS', {
version: eks.KubernetesVersion.V1_22,
version: eks.KubernetesVersion.V1_21,
defaultCapacityType: eks.DefaultCapacityType.EC2,
});
```
Expand Down Expand Up @@ -515,7 +515,7 @@ You can configure the [cluster endpoint access](https://docs.aws.amazon.com/eks/

```ts
const cluster = new eks.Cluster(this, 'hello-eks', {
version: eks.KubernetesVersion.V1_22,
version: eks.KubernetesVersion.V1_21,
endpointAccess: eks.EndpointAccess.PRIVATE, // No access outside of your VPC.
});
```
Expand All @@ -537,7 +537,7 @@ To deploy the controller on your EKS cluster, configure the `albController` prop

```ts
new eks.Cluster(this, 'HelloEKS', {
version: eks.KubernetesVersion.V1_22,
version: eks.KubernetesVersion.V1_21,
albController: {
version: eks.AlbControllerVersion.V2_4_1,
},
Expand Down Expand Up @@ -577,7 +577,7 @@ You can specify the VPC of the cluster using the `vpc` and `vpcSubnets` properti
declare const vpc: ec2.Vpc;

new eks.Cluster(this, 'HelloEKS', {
version: eks.KubernetesVersion.V1_22,
version: eks.KubernetesVersion.V1_21,
vpc,
vpcSubnets: [{ subnetType: ec2.SubnetType.PRIVATE }],
});
Expand Down Expand Up @@ -624,7 +624,7 @@ You can configure the environment of the Cluster Handler functions by specifying
```ts
declare const proxyInstanceSecurityGroup: ec2.SecurityGroup;
const cluster = new eks.Cluster(this, 'hello-eks', {
version: eks.KubernetesVersion.V1_22,
version: eks.KubernetesVersion.V1_21,
clusterHandlerEnvironment: {
https_proxy: 'http://proxy.myproxy.com',
},
Expand Down Expand Up @@ -662,7 +662,7 @@ You can configure the environment of this function by specifying it at cluster i

```ts
const cluster = new eks.Cluster(this, 'hello-eks', {
version: eks.KubernetesVersion.V1_22,
version: eks.KubernetesVersion.V1_21,
kubectlEnvironment: {
'http_proxy': 'http://proxy.myproxy.com',
},
Expand Down Expand Up @@ -706,7 +706,7 @@ const cluster1 = new eks.Cluster(this, 'MyCluster', {
kubectlLayer: layer,
vpc,
clusterName: 'cluster-name',
version: eks.KubernetesVersion.V1_22,
version: eks.KubernetesVersion.V1_21,
});

// or
Expand All @@ -724,7 +724,7 @@ By default, the kubectl provider is configured with 1024MiB of memory. You can u
```ts
new eks.Cluster(this, 'MyCluster', {
kubectlMemory: Size.gibibytes(4),
version: eks.KubernetesVersion.V1_22,
version: eks.KubernetesVersion.V1_21,
});

// or
Expand Down Expand Up @@ -763,7 +763,7 @@ When you create a cluster, you can specify a `mastersRole`. The `Cluster` constr
```ts
declare const role: iam.Role;
new eks.Cluster(this, 'HelloEKS', {
version: eks.KubernetesVersion.V1_22,
version: eks.KubernetesVersion.V1_21,
mastersRole: role,
});
```
Expand Down Expand Up @@ -791,7 +791,7 @@ You can use the `secretsEncryptionKey` to configure which key the cluster will u
const secretsKey = new kms.Key(this, 'SecretsKey');
const cluster = new eks.Cluster(this, 'MyCluster', {
secretsEncryptionKey: secretsKey,
version: eks.KubernetesVersion.V1_22,
version: eks.KubernetesVersion.V1_21,
});
```

Expand All @@ -801,7 +801,7 @@ You can also use a similar configuration for running a cluster built using the F
const secretsKey = new kms.Key(this, 'SecretsKey');
const cluster = new eks.FargateCluster(this, 'MyFargateCluster', {
secretsEncryptionKey: secretsKey,
version: eks.KubernetesVersion.V1_22,
version: eks.KubernetesVersion.V1_21,
});
```

Expand Down Expand Up @@ -1076,7 +1076,7 @@ when a cluster is defined:

```ts
new eks.Cluster(this, 'MyCluster', {
version: eks.KubernetesVersion.V1_22,
version: eks.KubernetesVersion.V1_21,
prune: false,
});
```
Expand Down Expand Up @@ -1431,7 +1431,7 @@ property. For example:
```ts
const cluster = new eks.Cluster(this, 'Cluster', {
// ...
version: eks.KubernetesVersion.V1_22,
version: eks.KubernetesVersion.V1_21,
clusterLogging: [
eks.ClusterLoggingTypes.API,
eks.ClusterLoggingTypes.AUTHENTICATOR,
Expand Down
6 changes: 0 additions & 6 deletions packages/@aws-cdk/aws-eks/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,6 @@ export class KubernetesVersion {

/**
* Kubernetes version 1.18
* @deprecated Use newer version of EKS
*/
public static readonly V1_18 = KubernetesVersion.of('1.18');

Expand All @@ -815,11 +814,6 @@ export class KubernetesVersion {
*/
public static readonly V1_21 = KubernetesVersion.of('1.21');

/**
* Kubernetes version 1.22
*/
public static readonly V1_22 = KubernetesVersion.of('1.22');

/**
* Custom cluster version
* @param version custom version number
Expand Down
26 changes: 13 additions & 13 deletions packages/@aws-cdk/aws-eks/test/cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { testFixture, testFixtureNoVpc } from './util';

/* eslint-disable max-len */

const CLUSTER_VERSION = eks.KubernetesVersion.V1_22;
const CLUSTER_VERSION = eks.KubernetesVersion.V1_21;

describe('cluster', () => {

Expand Down Expand Up @@ -135,9 +135,9 @@ describe('cluster', () => {
test('throws if selecting more than one subnet group', () => {
expect(() => new eks.Cluster(stack, 'Cluster', {
vpc: vpc,
vpcSubnets: [{ subnetType: ec2.SubnetType.PUBLIC }, { subnetType: ec2.SubnetType.PRIVATE_WITH_NAT }],
vpcSubnets: [{ subnetType: ec2.SubnetType.PUBLIC }, { subnetType: ec2.SubnetType.PRIVATE }],
defaultCapacity: 0,
version: CLUSTER_VERSION,
version: eks.KubernetesVersion.V1_21,
})).toThrow(/cannot select multiple subnet groups/);


Expand All @@ -149,7 +149,7 @@ describe('cluster', () => {
vpc: vpc,
vpcSubnets: [{ subnetType: ec2.SubnetType.PUBLIC }],
defaultCapacity: 0,
version: CLUSTER_VERSION,
version: eks.KubernetesVersion.V1_21,
});

// THEN
Expand Down Expand Up @@ -697,7 +697,7 @@ describe('cluster', () => {
Template.fromStack(stack).hasResourceProperties('Custom::AWSCDK-EKS-Cluster', {
Config: {
roleArn: { 'Fn::GetAtt': ['ClusterRoleFA261979', 'Arn'] },
version: '1.22',
version: '1.21',
resourcesVpcConfig: {
securityGroupIds: [{ 'Fn::GetAtt': ['ClusterControlPlaneSecurityGroupD274242C', 'GroupId'] }],
subnetIds: [
Expand Down Expand Up @@ -1657,7 +1657,7 @@ describe('cluster', () => {
const { app, stack } = testFixtureNoVpc();

// WHEN
new eks.EksOptimizedImage({ kubernetesVersion: '1.22' }).getImage(stack);
new eks.EksOptimizedImage({ kubernetesVersion: '1.21' }).getImage(stack);

// THEN
const assembly = app.synth();
Expand All @@ -1668,7 +1668,7 @@ describe('cluster', () => {
)).toEqual(true);
expect(Object.entries(parameters).some(
([k, v]) => k.startsWith('SsmParameterValueawsserviceeksoptimizedami') &&
(v as any).Default.includes('/1.22/'),
(v as any).Default.includes('/1.21/'),
)).toEqual(true);

});
Expand Down Expand Up @@ -1806,7 +1806,7 @@ describe('cluster', () => {
const { app, stack } = testFixtureNoVpc();

// WHEN
new BottleRocketImage({ kubernetesVersion: '1.22' }).getImage(stack);
new BottleRocketImage({ kubernetesVersion: '1.21' }).getImage(stack);

// THEN
const assembly = app.synth();
Expand All @@ -1817,7 +1817,7 @@ describe('cluster', () => {
)).toEqual(true);
expect(Object.entries(parameters).some(
([k, v]) => k.startsWith('SsmParameterValueawsservicebottlerocketaws') &&
(v as any).Default.includes('/aws-k8s-1.22/'),
(v as any).Default.includes('/aws-k8s-1.21/'),
)).toEqual(true);

});
Expand All @@ -1838,7 +1838,7 @@ describe('cluster', () => {
Config: {
name: 'my-cluster-name',
roleArn: { 'Fn::GetAtt': ['MyClusterRoleBA20FE72', 'Arn'] },
version: '1.22',
version: '1.21',
resourcesVpcConfig: {
securityGroupIds: [
{ 'Fn::GetAtt': ['MyClusterControlPlaneSecurityGroup6B658F79', 'GroupId'] },
Expand Down Expand Up @@ -2789,7 +2789,7 @@ describe('cluster', () => {
natGateways: 1,
subnetConfiguration: [
{
subnetType: ec2.SubnetType.PRIVATE_WITH_NAT,
subnetType: ec2.SubnetType.PRIVATE,
name: 'Private1',
},
{
Expand Down Expand Up @@ -2848,7 +2848,7 @@ describe('cluster', () => {

for (let i = 0; i < 20; i++) {
subnetConfiguration.push({
subnetType: ec2.SubnetType.PRIVATE_WITH_NAT,
subnetType: ec2.SubnetType.PRIVATE,
name: `Private${i}`,
},
);
Expand Down Expand Up @@ -2897,7 +2897,7 @@ describe('cluster', () => {

for (let i = 0; i < 20; i++) {
subnetConfiguration.push({
subnetType: ec2.SubnetType.PRIVATE_WITH_NAT,
subnetType: ec2.SubnetType.PRIVATE,
name: `Private${i}`,
},
);
Expand Down
24 changes: 12 additions & 12 deletions packages/@aws-cdk/aws-eks/test/integ.eks-cluster.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@
]
},
"Config": {
"version": "1.22",
"version": "1.21",
"roleArn": {
"Fn::GetAtt": [
"ClusterRoleFA261979",
Expand Down Expand Up @@ -1585,7 +1585,7 @@
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Properties": {
"ImageId": {
"Ref": "SsmParameterValueawsserviceeksoptimizedami122amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
"Ref": "SsmParameterValueawsserviceeksoptimizedami121amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
},
"InstanceType": "t2.medium",
"IamInstanceProfile": {
Expand Down Expand Up @@ -1900,7 +1900,7 @@
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Properties": {
"ImageId": {
"Ref": "SsmParameterValueawsserviceeksoptimizedami122amazonlinux2arm64recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
"Ref": "SsmParameterValueawsserviceeksoptimizedami121amazonlinux2arm64recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
},
"InstanceType": "m6g.medium",
"IamInstanceProfile": {
Expand Down Expand Up @@ -2215,7 +2215,7 @@
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Properties": {
"ImageId": {
"Ref": "SsmParameterValueawsservicebottlerocketawsk8s122x8664latestimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
"Ref": "SsmParameterValueawsservicebottlerocketawsk8s121x8664latestimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
},
"InstanceType": "t3.small",
"IamInstanceProfile": {
Expand Down Expand Up @@ -2530,7 +2530,7 @@
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Properties": {
"ImageId": {
"Ref": "SsmParameterValueawsserviceeksoptimizedami122amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
"Ref": "SsmParameterValueawsserviceeksoptimizedami121amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
},
"InstanceType": "t3.large",
"IamInstanceProfile": {
Expand Down Expand Up @@ -3526,7 +3526,7 @@
"Properties": {
"LaunchTemplateData": {
"ImageId": {
"Ref": "SsmParameterValueawsserviceeksoptimizedami122amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
"Ref": "SsmParameterValueawsserviceeksoptimizedami121amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
},
"InstanceType": "t3.small",
"UserData": {
Expand Down Expand Up @@ -3971,17 +3971,17 @@
"Type": "String",
"Description": "Artifact hash for asset \"4e9b35054b4d4d206c33c65400dcfae51f6dc1804d2cfd6d80b1eda0e598129c\""
},
"SsmParameterValueawsserviceeksoptimizedami122amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": {
"SsmParameterValueawsserviceeksoptimizedami121amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/aws/service/eks/optimized-ami/1.22/amazon-linux-2/recommended/image_id"
"Default": "/aws/service/eks/optimized-ami/1.21/amazon-linux-2/recommended/image_id"
},
"SsmParameterValueawsserviceeksoptimizedami122amazonlinux2arm64recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": {
"SsmParameterValueawsserviceeksoptimizedami121amazonlinux2arm64recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/aws/service/eks/optimized-ami/1.22/amazon-linux-2-arm64/recommended/image_id"
"Default": "/aws/service/eks/optimized-ami/1.21/amazon-linux-2-arm64/recommended/image_id"
},
"SsmParameterValueawsservicebottlerocketawsk8s122x8664latestimageidC96584B6F00A464EAD1953AFF4B05118Parameter": {
"SsmParameterValueawsservicebottlerocketawsk8s121x8664latestimageidC96584B6F00A464EAD1953AFF4B05118Parameter": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/aws/service/bottlerocket/aws-k8s-1.22/x86_64/latest/image_id"
"Default": "/aws/service/bottlerocket/aws-k8s-1.21/x86_64/latest/image_id"
}
}
}
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-eks/test/integ.eks-cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class EksClusterStack extends Stack {
vpc: this.vpc,
mastersRole,
defaultCapacity: 2,
version: eks.KubernetesVersion.V1_22,
version: eks.KubernetesVersion.V1_21,
secretsEncryptionKey,
tags: {
foo: 'bar',
Expand Down Expand Up @@ -205,7 +205,7 @@ class EksClusterStack extends Stack {
const lt = new ec2.CfnLaunchTemplate(this, 'LaunchTemplate', {
launchTemplateData: {
imageId: new eks.EksOptimizedImage({
kubernetesVersion: eks.KubernetesVersion.V1_22.version,
kubernetesVersion: eks.KubernetesVersion.V1_21.version,
}).getImage(this).imageId,
instanceType: new ec2.InstanceType('t3.small').toString(),
userData: Fn.base64(userData.render()),
Expand Down

0 comments on commit c97636f

Please sign in to comment.