Skip to content

Commit

Permalink
feat(eks): support Kubernetes 1.20 (#14758)
Browse files Browse the repository at this point in the history
Support KubernetesVersion 1.20

Fixes: #14756 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
kirintwn authored Jun 1, 2021
1 parent 5a0e7b9 commit 1956ef6
Show file tree
Hide file tree
Showing 15 changed files with 54 additions and 49 deletions.
24 changes: 12 additions & 12 deletions packages/@aws-cdk/aws-eks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,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_19,
version: eks.KubernetesVersion.V1_20,
});

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

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

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

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

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

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

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

Expand Down Expand Up @@ -322,7 +322,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_19,
version: eks.KubernetesVersion.V1_20,
});
```

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

```ts
cluster = new eks.Cluster(this, 'HelloEKS', {
version: eks.KubernetesVersion.V1_19,
version: eks.KubernetesVersion.V1_20,
defaultCapacityType: eks.DefaultCapacityType.EC2,
});
```
Expand Down Expand Up @@ -461,7 +461,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_19,
version: eks.KubernetesVersion.V1_20,
endpointAccess: eks.EndpointAccess.PRIVATE // No access outside of your VPC.
});
```
Expand All @@ -476,7 +476,7 @@ You can specify the VPC of the cluster using the `vpc` and `vpcSubnets` properti
const vpc = new ec2.Vpc(this, 'Vpc');

new eks.Cluster(this, 'HelloEKS', {
version: eks.KubernetesVersion.V1_19,
version: eks.KubernetesVersion.V1_20,
vpc,
vpcSubnets: [{ subnetType: ec2.SubnetType.PRIVATE }]
});
Expand Down Expand Up @@ -515,7 +515,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_19,
version: eks.KubernetesVersion.V1_20,
clusterHandlerEnvironment: {
'http_proxy': 'http://proxy.myproxy.com'
}
Expand All @@ -532,7 +532,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_19,
version: eks.KubernetesVersion.V1_20,
kubectlEnvironment: {
'http_proxy': 'http://proxy.myproxy.com'
}
Expand Down Expand Up @@ -622,7 +622,7 @@ When you create a cluster, you can specify a `mastersRole`. The `Cluster` constr
```ts
const role = new iam.Role(...);
new eks.Cluster(this, 'HelloEKS', {
version: eks.KubernetesVersion.V1_19,
version: eks.KubernetesVersion.V1_20,
mastersRole: role,
});
```
Expand Down
5 changes: 5 additions & 0 deletions packages/@aws-cdk/aws-eks/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,11 @@ export class KubernetesVersion {
*/
public static readonly V1_19 = KubernetesVersion.of('1.19');

/**
* Kubernetes version 1.20
*/
public static readonly V1_20 = KubernetesVersion.of('1.20');

/**
* Custom cluster version
* @param version custom version number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class EksClusterStack extends cdk.Stack {

const cluster = new eks.Cluster(this, 'EKSCluster', {
vpc,
version: eks.KubernetesVersion.V1_19,
version: eks.KubernetesVersion.V1_20,
});

/// !show
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@
]
},
"Config": {
"version": "1.19",
"version": "1.20",
"roleArn": {
"Fn::GetAtt": [
"EksAllHandlersInVpcStackRoleC36F09F0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { App } from '@aws-cdk/core';
import * as eks from '../lib';
import { TestStack } from './util';

const CLUSTER_VERSION = eks.KubernetesVersion.V1_19;
const CLUSTER_VERSION = eks.KubernetesVersion.V1_20;


class EksAllHandlersInVpcStack extends TestStack {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@
]
},
"Config": {
"version": "1.19",
"version": "1.20",
"roleArn": {
"Fn::GetAtt": [
"ClusterRoleFA261979",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { App } from '@aws-cdk/core';
import * as eks from '../lib';
import { TestStack } from './util';

const CLUSTER_VERSION = eks.KubernetesVersion.V1_19;
const CLUSTER_VERSION = eks.KubernetesVersion.V1_20;


class EksClusterStack extends TestStack {
Expand Down
30 changes: 15 additions & 15 deletions packages/@aws-cdk/aws-eks/test/integ.eks-cluster.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@
]
},
"Config": {
"version": "1.19",
"version": "1.20",
"roleArn": {
"Fn::GetAtt": [
"ClusterRoleFA261979",
Expand Down Expand Up @@ -1653,7 +1653,7 @@
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Properties": {
"ImageId": {
"Ref": "SsmParameterValueawsserviceeksoptimizedami119amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
"Ref": "SsmParameterValueawsserviceeksoptimizedami120amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
},
"InstanceType": "t2.medium",
"IamInstanceProfile": {
Expand Down Expand Up @@ -1978,7 +1978,7 @@
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Properties": {
"ImageId": {
"Ref": "SsmParameterValueawsserviceeksoptimizedami119amazonlinux2arm64recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
"Ref": "SsmParameterValueawsserviceeksoptimizedami120amazonlinux2arm64recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
},
"InstanceType": "m6g.medium",
"IamInstanceProfile": {
Expand Down Expand Up @@ -2303,7 +2303,7 @@
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Properties": {
"ImageId": {
"Ref": "SsmParameterValueawsservicebottlerocketawsk8s119x8664latestimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
"Ref": "SsmParameterValueawsservicebottlerocketawsk8s120x8664latestimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
},
"InstanceType": "t3.small",
"IamInstanceProfile": {
Expand Down Expand Up @@ -2628,7 +2628,7 @@
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Properties": {
"ImageId": {
"Ref": "SsmParameterValueawsserviceeksoptimizedami119amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
"Ref": "SsmParameterValueawsserviceeksoptimizedami120amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
},
"InstanceType": "t3.large",
"IamInstanceProfile": {
Expand Down Expand Up @@ -2986,7 +2986,7 @@
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Properties": {
"ImageId": {
"Ref": "SsmParameterValueawsserviceeksoptimizedami119amazonlinux2gpurecommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
"Ref": "SsmParameterValueawsserviceeksoptimizedami120amazonlinux2gpurecommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
},
"InstanceType": "inf1.2xlarge",
"IamInstanceProfile": {
Expand Down Expand Up @@ -4029,7 +4029,7 @@
"Properties": {
"LaunchTemplateData": {
"ImageId": {
"Ref": "SsmParameterValueawsserviceeksoptimizedami119amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
"Ref": "SsmParameterValueawsserviceeksoptimizedami120amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
},
"InstanceType": "t3.small",
"UserData": {
Expand Down Expand Up @@ -4778,21 +4778,21 @@
"Type": "String",
"Description": "Artifact hash for asset \"e334ff007b5126b62d66d4baac94004f4281dc2b0b0c4685ec93e330cb59e921\""
},
"SsmParameterValueawsserviceeksoptimizedami119amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": {
"SsmParameterValueawsserviceeksoptimizedami120amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/aws/service/eks/optimized-ami/1.19/amazon-linux-2/recommended/image_id"
"Default": "/aws/service/eks/optimized-ami/1.20/amazon-linux-2/recommended/image_id"
},
"SsmParameterValueawsserviceeksoptimizedami119amazonlinux2arm64recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": {
"SsmParameterValueawsserviceeksoptimizedami120amazonlinux2arm64recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/aws/service/eks/optimized-ami/1.19/amazon-linux-2-arm64/recommended/image_id"
"Default": "/aws/service/eks/optimized-ami/1.20/amazon-linux-2-arm64/recommended/image_id"
},
"SsmParameterValueawsservicebottlerocketawsk8s119x8664latestimageidC96584B6F00A464EAD1953AFF4B05118Parameter": {
"SsmParameterValueawsservicebottlerocketawsk8s120x8664latestimageidC96584B6F00A464EAD1953AFF4B05118Parameter": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/aws/service/bottlerocket/aws-k8s-1.19/x86_64/latest/image_id"
"Default": "/aws/service/bottlerocket/aws-k8s-1.20/x86_64/latest/image_id"
},
"SsmParameterValueawsserviceeksoptimizedami119amazonlinux2gpurecommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": {
"SsmParameterValueawsserviceeksoptimizedami120amazonlinux2gpurecommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/aws/service/eks/optimized-ami/1.19/amazon-linux-2-gpu/recommended/image_id"
"Default": "/aws/service/eks/optimized-ami/1.20/amazon-linux-2-gpu/recommended/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 TestStack {
vpc: this.vpc,
mastersRole,
defaultCapacity: 2,
version: eks.KubernetesVersion.V1_19,
version: eks.KubernetesVersion.V1_20,
secretsEncryptionKey,
});

Expand Down Expand Up @@ -188,7 +188,7 @@ class EksClusterStack extends TestStack {
const lt = new ec2.CfnLaunchTemplate(this, 'LaunchTemplate', {
launchTemplateData: {
imageId: new eks.EksOptimizedImage({
kubernetesVersion: eks.KubernetesVersion.V1_19.version,
kubernetesVersion: eks.KubernetesVersion.V1_20.version,
}).getImage(this).imageId,
instanceType: new ec2.InstanceType('t3.small').toString(),
userData: Fn.base64(userData.render()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@
]
},
"Config": {
"version": "1.19",
"version": "1.20",
"roleArn": {
"Fn::GetAtt": [
"FargateClusterRole8E36B33A",
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-eks/test/integ.fargate-cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { App } from '@aws-cdk/core';
import * as eks from '../lib';
import { TestStack } from './util';

const CLUSTER_VERSION = eks.KubernetesVersion.V1_19;
const CLUSTER_VERSION = eks.KubernetesVersion.V1_20;


class EksFargateClusterStack extends TestStack {
Expand All @@ -22,4 +22,4 @@ const app = new App();

new EksFargateClusterStack(app, 'aws-cdk-eks-fargate-cluster-test');

app.synth();
app.synth();
18 changes: 9 additions & 9 deletions packages/@aws-cdk/aws-eks/test/test.cluster.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_19;
const CLUSTER_VERSION = eks.KubernetesVersion.V1_20;

export = {

Expand Down Expand Up @@ -85,7 +85,7 @@ export = {
vpc: vpc,
vpcSubnets: [{ subnetType: ec2.SubnetType.PUBLIC }, { subnetType: ec2.SubnetType.PRIVATE }],
defaultCapacity: 0,
version: eks.KubernetesVersion.V1_19,
version: eks.KubernetesVersion.V1_20,
}), /cannot select multiple subnet groups/);

test.done();
Expand All @@ -97,7 +97,7 @@ export = {
vpc: vpc,
vpcSubnets: [{ subnetType: ec2.SubnetType.PUBLIC }],
defaultCapacity: 0,
version: eks.KubernetesVersion.V1_19,
version: eks.KubernetesVersion.V1_20,
});

// THEN
Expand Down Expand Up @@ -629,7 +629,7 @@ export = {
expect(stack).to(haveResourceLike('Custom::AWSCDK-EKS-Cluster', {
Config: {
roleArn: { 'Fn::GetAtt': ['ClusterRoleFA261979', 'Arn'] },
version: '1.19',
version: '1.20',
resourcesVpcConfig: {
securityGroupIds: [{ 'Fn::GetAtt': ['ClusterControlPlaneSecurityGroupD274242C', 'GroupId'] }],
subnetIds: [
Expand Down Expand Up @@ -1462,7 +1462,7 @@ export = {
const { app, stack } = testFixtureNoVpc();

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

// THEN
const assembly = app.synth();
Expand All @@ -1473,7 +1473,7 @@ export = {
), 'EKS STANDARD AMI should be in ssm parameters');
test.ok(Object.entries(parameters).some(
([k, v]) => k.startsWith('SsmParameterValueawsserviceeksoptimizedami') &&
(v as any).Default.includes('/1.19/'),
(v as any).Default.includes('/1.20/'),
), 'kubernetesVersion should be in ssm parameters');
test.done();
},
Expand Down Expand Up @@ -1611,7 +1611,7 @@ export = {
const { app, stack } = testFixtureNoVpc();

// WHEN
new BottleRocketImage({ kubernetesVersion: '1.19' }).getImage(stack);
new BottleRocketImage({ kubernetesVersion: '1.20' }).getImage(stack);

// THEN
const assembly = app.synth();
Expand All @@ -1622,7 +1622,7 @@ export = {
), 'BottleRocket AMI should be in ssm parameters');
test.ok(Object.entries(parameters).some(
([k, v]) => k.startsWith('SsmParameterValueawsservicebottlerocketaws') &&
(v as any).Default.includes('/aws-k8s-1.19/'),
(v as any).Default.includes('/aws-k8s-1.20/'),
), 'kubernetesVersion should be in ssm parameters');
test.done();
},
Expand All @@ -1643,7 +1643,7 @@ export = {
Config: {
name: 'my-cluster-name',
roleArn: { 'Fn::GetAtt': ['MyClusterRoleBA20FE72', 'Arn'] },
version: '1.19',
version: '1.20',
resourcesVpcConfig: {
securityGroupIds: [
{ 'Fn::GetAtt': ['MyClusterControlPlaneSecurityGroup6B658F79', 'GroupId'] },
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-eks/test/test.fargate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Test } from 'nodeunit';
import * as eks from '../lib';


const CLUSTER_VERSION = eks.KubernetesVersion.V1_19;
const CLUSTER_VERSION = eks.KubernetesVersion.V1_20;

export = {
'can be added to a cluster'(test: Test) {
Expand Down
Loading

0 comments on commit 1956ef6

Please sign in to comment.