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

feat(eks): EKS is now in Developer Preview #10518

Merged
merged 29 commits into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0af939c
rename addChart => addHelmChart
iliapolo Sep 24, 2020
ffaa5b1
rename capacity methods
iliapolo Sep 24, 2020
107214b
rename launchTemplate to launchTemplateSpec
iliapolo Sep 24, 2020
3110f3e
Merge branch 'master' into epolon/10364-eks-dev-preview
iliapolo Sep 24, 2020
f24e819
flip maturity to dev preview
iliapolo Sep 24, 2020
3add737
working on new readme
iliapolo Sep 27, 2020
6e00ef1
mid work
iliapolo Sep 27, 2020
d661f85
mid work
iliapolo Sep 27, 2020
c7fa886
mid work
iliapolo Sep 27, 2020
d5aa7e4
mid work
iliapolo Sep 27, 2020
9bbc1bc
mid work
iliapolo Sep 27, 2020
c9e929b
mid work
iliapolo Sep 28, 2020
42a4f72
mid work
iliapolo Sep 28, 2020
20d17a6
mid work
iliapolo Sep 28, 2020
2e23a1d
mid work
iliapolo Sep 28, 2020
4396001
mid work
iliapolo Sep 28, 2020
55dbfad
mid work
iliapolo Sep 28, 2020
aae7274
mid work
iliapolo Sep 28, 2020
14fa878
refactor
iliapolo Sep 28, 2020
37bb76a
refactor
iliapolo Sep 28, 2020
a9e849c
mid work
iliapolo Sep 29, 2020
806ad5e
review comments
iliapolo Sep 29, 2020
b326e54
remove comment
iliapolo Sep 29, 2020
6c5e62d
more fixups
iliapolo Sep 29, 2020
2c28aee
add code snippet for passing a mastersRole
iliapolo Sep 29, 2020
a800570
remove RoadMap section
iliapolo Sep 29, 2020
2b77291
Merge branch 'master' of github.com:aws/aws-cdk into epolon/10364-eks…
iliapolo Sep 29, 2020
de41d2d
Merge branch 'master' into epolon/10364-eks-dev-preview
iliapolo Sep 29, 2020
81c319b
Merge branch 'master' into epolon/10364-eks-dev-preview
mergify[bot] Sep 29, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
982 changes: 572 additions & 410 deletions packages/@aws-cdk/aws-eks/README.md

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions packages/@aws-cdk/aws-eks/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export interface ICluster extends IResource, ec2.IConnectable {
* @param options options of this chart.
* @returns a `HelmChart` construct
*/
addChart(id: string, options: HelmChartOptions): HelmChart;
addHelmChart(id: string, options: HelmChartOptions): HelmChart;
}

/**
Expand Down Expand Up @@ -507,7 +507,7 @@ export interface ClusterProps extends ClusterOptions {
* Instance type can be configured through `defaultCapacityInstanceType`,
* which defaults to `m5.large`.
*
* Use `cluster.addCapacity` to add additional customized capacity. Set this
* Use `cluster.addAutoScalingGroupCapacity` to add additional customized capacity. Set this
* to `0` is you wish to avoid the initial capacity allocation.
*
* @default 2
Expand Down Expand Up @@ -609,7 +609,7 @@ abstract class ClusterBase extends Resource implements ICluster {
* @param options options of this chart.
* @returns a `HelmChart` construct
*/
public addChart(id: string, options: HelmChartOptions): HelmChart {
public addHelmChart(id: string, options: HelmChartOptions): HelmChart {
return new HelmChart(this, `chart-${id}`, { cluster: this, ...options });
}
}
Expand Down Expand Up @@ -984,10 +984,10 @@ export class Cluster extends ClusterBase {
if (minCapacity > 0) {
const instanceType = props.defaultCapacityInstance || DEFAULT_CAPACITY_TYPE;
this.defaultCapacity = props.defaultCapacityType === DefaultCapacityType.EC2 ?
this.addCapacity('DefaultCapacity', { instanceType, minCapacity }) : undefined;
this.addAutoScalingGroupCapacity('DefaultCapacity', { instanceType, minCapacity }) : undefined;

this.defaultNodegroup = props.defaultCapacityType !== DefaultCapacityType.EC2 ?
this.addNodegroup('DefaultCapacity', { instanceType, minSize: minCapacity }) : undefined;
this.addNodegroupCapacity('DefaultCapacity', { instanceType, minSize: minCapacity }) : undefined;
}

const outputConfigCommand = props.outputConfigCommand === undefined ? true : props.outputConfigCommand;
Expand Down Expand Up @@ -1036,7 +1036,7 @@ export class Cluster extends ClusterBase {
* daemon will be installed on all spot instances to handle
* [EC2 Spot Instance Termination Notices](https://aws.amazon.com/blogs/aws/new-ec2-spot-instance-termination-notices/).
*/
public addCapacity(id: string, options: CapacityOptions): autoscaling.AutoScalingGroup {
public addAutoScalingGroupCapacity(id: string, options: AutoScalingGroupCapacityOptions): autoscaling.AutoScalingGroup {
if (options.machineImageType === MachineImageType.BOTTLEROCKET && options.bootstrapOptions !== undefined ) {
throw new Error('bootstrapOptions is not supported for Bottlerocket');
}
Expand All @@ -1056,7 +1056,7 @@ export class Cluster extends ClusterBase {
instanceType: options.instanceType,
});

this.addAutoScalingGroup(asg, {
this.connectAutoScalingGroupCapacity(asg, {
mapRole: options.mapRole,
bootstrapOptions: options.bootstrapOptions,
bootstrapEnabled: options.bootstrapEnabled,
Expand All @@ -1079,15 +1079,15 @@ export class Cluster extends ClusterBase {
* @param id The ID of the nodegroup
* @param options options for creating a new nodegroup
*/
public addNodegroup(id: string, options?: NodegroupOptions): Nodegroup {
public addNodegroupCapacity(id: string, options?: NodegroupOptions): Nodegroup {
return new Nodegroup(this, `Nodegroup${id}`, {
cluster: this,
...options,
});
}

/**
* Add compute capacity to this EKS cluster in the form of an AutoScalingGroup
* Connect capacity in the form of an existing AutoScalingGroup to the EKS cluster.
*
* The AutoScalingGroup must be running an EKS-optimized AMI containing the
* /etc/eks/bootstrap.sh script. This method will configure Security Groups,
Expand All @@ -1100,13 +1100,13 @@ export class Cluster extends ClusterBase {
* daemon will be installed on all spot instances to handle
* [EC2 Spot Instance Termination Notices](https://aws.amazon.com/blogs/aws/new-ec2-spot-instance-termination-notices/).
*
* Prefer to use `addCapacity` if possible.
* Prefer to use `addAutoScalingGroupCapacity` if possible.
*
* @see https://docs.aws.amazon.com/eks/latest/userguide/launch-workers.html
* @param autoScalingGroup [disable-awslint:ref-via-interface]
* @param options options for adding auto scaling groups, like customizing the bootstrap script
*/
public addAutoScalingGroup(autoScalingGroup: autoscaling.AutoScalingGroup, options: AutoScalingGroupOptions) {
public connectAutoScalingGroupCapacity(autoScalingGroup: autoscaling.AutoScalingGroup, options: AutoScalingGroupOptions) {
// self rules
autoScalingGroup.connections.allowInternally(ec2.Port.allTraffic());

Expand Down Expand Up @@ -1333,7 +1333,7 @@ export class Cluster extends ClusterBase {
*/
private addSpotInterruptHandler() {
if (!this._spotInterruptHandler) {
this._spotInterruptHandler = this.addChart('spot-interrupt-handler', {
this._spotInterruptHandler = this.addHelmChart('spot-interrupt-handler', {
chart: 'aws-node-termination-handler',
version: '0.9.5',
repository: 'https://aws.github.io/eks-charts',
Expand Down Expand Up @@ -1430,7 +1430,7 @@ export class Cluster extends ClusterBase {
/**
* Options for adding worker nodes
*/
export interface CapacityOptions extends autoscaling.CommonAutoScalingGroupProps {
export interface AutoScalingGroupCapacityOptions extends autoscaling.CommonAutoScalingGroupProps {
/**
* Instance type of the instances to start
*/
Expand Down
8 changes: 4 additions & 4 deletions packages/@aws-cdk/aws-eks/lib/legacy-cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as iam from '@aws-cdk/aws-iam';
import * as kms from '@aws-cdk/aws-kms';
import * as ssm from '@aws-cdk/aws-ssm';
import { Annotations, CfnOutput, Construct, Resource, Stack, Token, Tags } from '@aws-cdk/core';
import { ICluster, ClusterAttributes, KubernetesVersion, NodeType, DefaultCapacityType, EksOptimizedImage, CapacityOptions, MachineImageType, AutoScalingGroupOptions, CommonClusterOptions } from './cluster';
import { ICluster, ClusterAttributes, KubernetesVersion, NodeType, DefaultCapacityType, EksOptimizedImage, AutoScalingGroupCapacityOptions, MachineImageType, AutoScalingGroupOptions, CommonClusterOptions } from './cluster';
import { clusterArnComponents } from './cluster-resource';
import { CfnCluster, CfnClusterProps } from './eks.generated';
import { HelmChartOptions, HelmChart } from './helm-chart';
Expand Down Expand Up @@ -251,7 +251,7 @@ export class LegacyCluster extends Resource implements ICluster {
*
* Spot instances will be labeled `lifecycle=Ec2Spot` and tainted with `PreferNoSchedule`.
*/
public addCapacity(id: string, options: CapacityOptions): autoscaling.AutoScalingGroup {
public addCapacity(id: string, options: AutoScalingGroupCapacityOptions): autoscaling.AutoScalingGroup {
if (options.machineImageType === MachineImageType.BOTTLEROCKET && options.bootstrapOptions !== undefined ) {
throw new Error('bootstrapOptions is not supported for Bottlerocket');
}
Expand Down Expand Up @@ -366,7 +366,7 @@ export class LegacyCluster extends Resource implements ICluster {
throw new Error('legacy cluster does not support adding kubernetes manifests');
}

public addChart(_id: string, _options: HelmChartOptions): HelmChart {
public addHelmChart(_id: string, _options: HelmChartOptions): HelmChart {
throw new Error('legacy cluster does not support adding helm charts');
}

Expand Down Expand Up @@ -424,7 +424,7 @@ class ImportedCluster extends Resource implements ICluster {
throw new Error('legacy cluster does not support adding kubernetes manifests');
}

public addChart(_id: string, _options: HelmChartOptions): HelmChart {
public addHelmChart(_id: string, _options: HelmChartOptions): HelmChart {
throw new Error('legacy cluster does not support adding helm charts');
}

Expand Down
12 changes: 6 additions & 6 deletions packages/@aws-cdk/aws-eks/lib/managed-nodegroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export interface NodegroupRemoteAccess {
/**
* Launch template property specification
*/
export interface LaunchTemplate {
export interface LaunchTemplateSpec {
/**
* The Launch template ID
*/
Expand Down Expand Up @@ -177,11 +177,11 @@ export interface NodegroupOptions {
*/
readonly tags?: { [name: string]: string };
/**
* Launch template used for the nodegroup
* Launch template specification used for the nodegroup
* @see - https://docs.aws.amazon.com/eks/latest/userguide/launch-templates.html
* @default - no launch template
*/
readonly launchTemplate?: LaunchTemplate;
readonly launchTemplateSpec?: LaunchTemplateSpec;
}

/**
Expand Down Expand Up @@ -290,7 +290,7 @@ export class Nodegroup extends Resource implements INodegroup {
tags: props.tags,
});

if (props.launchTemplate) {
if (props.launchTemplateSpec) {
if (props.diskSize) {
// see - https://docs.aws.amazon.com/eks/latest/userguide/launch-templates.html
// and https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-eks-nodegroup.html#cfn-eks-nodegroup-disksize
Expand All @@ -303,8 +303,8 @@ export class Nodegroup extends Resource implements INodegroup {
}
// TODO: update this when the L1 resource spec is updated.
resource.addPropertyOverride('LaunchTemplate', {
Id: props.launchTemplate.id,
Version: props.launchTemplate.version,
Id: props.launchTemplateSpec.id,
Version: props.launchTemplateSpec.version,
});
}

Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-eks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
]
},
"stability": "experimental",
"maturity": "experimental",
"maturity": "developer-preview",
"awscdkio": {
"announce": false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class EksClusterStack extends cdk.Stack {
});

/// !show
const asg = cluster.addCapacity('Nodes', {
const asg = cluster.addAutoScalingGroupCapacity('Nodes', {
instanceType: new ec2.InstanceType('t2.medium'),
vpcSubnets: { subnetType: ec2.SubnetType.PUBLIC },
keyName: 'my-key-name',
Expand Down
22 changes: 11 additions & 11 deletions packages/@aws-cdk/aws-eks/test/integ.eks-cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class EksClusterStack extends TestStack {
},
});

const nginxIngress = this.cluster.addChart('nginx-ingress', {
const nginxIngress = this.cluster.addHelmChart('nginx-ingress', {
chart: 'nginx-ingress',
repository: 'https://helm.nginx.com/stable',
namespace: 'nginx',
Expand All @@ -103,7 +103,7 @@ class EksClusterStack extends TestStack {
}
private assertSimpleHelmChart() {
// deploy the Kubernetes dashboard through a helm chart
this.cluster.addChart('dashboard', {
this.cluster.addHelmChart('dashboard', {
chart: 'kubernetes-dashboard',
repository: 'https://kubernetes.github.io/dashboard/',
});
Expand All @@ -114,7 +114,7 @@ class EksClusterStack extends TestStack {
}
private assertNodeGroupX86() {
// add a extra nodegroup
this.cluster.addNodegroup('extra-ng', {
this.cluster.addNodegroupCapacity('extra-ng', {
instanceType: new ec2.InstanceType('t3.small'),
minSize: 1,
// reusing the default capacity nodegroup instance role when available
Expand All @@ -135,19 +135,19 @@ class EksClusterStack extends TestStack {
userData: Fn.base64(userData.render()),
},
});
this.cluster.addNodegroup('extra-ng2', {
this.cluster.addNodegroupCapacity('extra-ng2', {
minSize: 1,
// reusing the default capacity nodegroup instance role when available
nodeRole: this.cluster.defaultNodegroup?.role || this.cluster.defaultCapacity?.role,
launchTemplate: {
launchTemplateSpec: {
id: lt.ref,
version: lt.attrDefaultVersionNumber,
},
});
}
private assertNodeGroupArm() {
// add a extra nodegroup
this.cluster.addNodegroup('extra-ng-arm', {
this.cluster.addNodegroupCapacity('extra-ng-arm', {
instanceType: new ec2.InstanceType('m6g.medium'),
minSize: 1,
// reusing the default capacity nodegroup instance role when available
Expand All @@ -156,14 +156,14 @@ class EksClusterStack extends TestStack {
}
private assertInferenceInstances() {
// inference instances
this.cluster.addCapacity('InferenceInstances', {
this.cluster.addAutoScalingGroupCapacity('InferenceInstances', {
instanceType: new ec2.InstanceType('inf1.2xlarge'),
minCapacity: 1,
});
}
private assertSpotCapacity() {
// spot instances (up to 10)
this.cluster.addCapacity('spot', {
this.cluster.addAutoScalingGroupCapacity('spot', {
spotPrice: '0.1094',
instanceType: new ec2.InstanceType('t3.large'),
maxCapacity: 10,
Expand All @@ -175,7 +175,7 @@ class EksClusterStack extends TestStack {
}
private assertBottlerocket() {
// add bottlerocket nodes
this.cluster.addCapacity('BottlerocketNodes', {
this.cluster.addAutoScalingGroupCapacity('BottlerocketNodes', {
instanceType: new ec2.InstanceType('t3.small'),
minCapacity: 2,
machineImageType: eks.MachineImageType.BOTTLEROCKET,
Expand All @@ -185,7 +185,7 @@ class EksClusterStack extends TestStack {
private assertCapacityX86() {
// add some x86_64 capacity to the cluster. The IAM instance role will
// automatically be mapped via aws-auth to allow nodes to join the cluster.
this.cluster.addCapacity('Nodes', {
this.cluster.addAutoScalingGroupCapacity('Nodes', {
instanceType: new ec2.InstanceType('t2.medium'),
minCapacity: 3,
});
Expand All @@ -194,7 +194,7 @@ class EksClusterStack extends TestStack {
private assertCapacityArm() {
// add some arm64 capacity to the cluster. The IAM instance role will
// automatically be mapped via aws-auth to allow nodes to join the cluster.
this.cluster.addCapacity('NodesArm', {
this.cluster.addAutoScalingGroupCapacity('NodesArm', {
instanceType: new ec2.InstanceType('m6g.medium'),
minCapacity: 1,
});
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-eks/test/test.awsauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export = {
// GIVEN
const { stack } = testFixtureNoVpc();
const cluster = new Cluster(stack, 'Cluster', { version: CLUSTER_VERSION });
cluster.addNodegroup('NG');
cluster.addNodegroupCapacity('NG');
const role = iam.Role.fromRoleArn(stack, 'imported-role', 'arn:aws:iam::123456789012:role/S3Access');

// WHEN
Expand Down
Loading