Last active
April 4, 2020 11:55
-
-
Save pahud/ae8280d27a574086a02114134d5ba470 to your computer and use it in GitHub Desktop.
CDK for Amazon EKS with c5.12xlarge nodegroup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cdk = require('@aws-cdk/core'); | |
import eks = require('@aws-cdk/aws-eks'); | |
import iam = require('@aws-cdk/aws-iam'); | |
import autoscaling = require('@aws-cdk/aws-autoscaling'); | |
import { InstanceType } from '@aws-cdk/aws-ec2'; | |
export class CdkStack extends cdk.Stack { | |
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) { | |
super(scope, id, props); | |
// first define the role | |
const clusterAdmin = new iam.Role(this, 'AdminRole', { | |
assumedBy: new iam.AccountRootPrincipal() | |
}); | |
// eks cluster with nodegroup of 2x m5.large instances in dedicated vpc with default configuratrion | |
const cluster = new eks.Cluster(this, 'Cluster', { | |
clusterName: 'cdk-eks3', | |
defaultCapacity: 0, | |
mastersRole: clusterAdmin | |
}); | |
const asg = new autoscaling.AutoScalingGroup(this, 'NG', { | |
vpc: cluster.vpc, | |
// on-demand price of c5.12xlarge in us-west-2 | |
spotPrice: '2.0400', | |
instanceType: new InstanceType('c5.12xlarge'), | |
machineImage: new eks.EksOptimizedAmi({ | |
kubernetesVersion: '1.13', | |
nodeType: eks.NodeType.NORMAL | |
}), | |
updateType: autoscaling.UpdateType.ROLLING_UPDATE | |
}) | |
cluster.addAutoScalingGroup(asg, { | |
// https://github.com/awslabs/amazon-eks-ami/blob/master/files/eni-max-pods.txt | |
maxPods: 234, | |
mapRole: true | |
}) |
Does this create a ManagedNodeGroup?
No, but the next release of CDK(1.32.0) will be allow you to create managed nodegroup.
Thank you so much!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does this create a ManagedNodeGroup?