class Nodegroup (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.EKS.Nodegroup |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awseks#Nodegroup |
Java | software.amazon.awscdk.services.eks.Nodegroup |
Python | aws_cdk.aws_eks.Nodegroup |
TypeScript (source) | aws-cdk-lib » aws_eks » Nodegroup |
Implements
IConstruct
, IDependable
, IResource
, INodegroup
The Nodegroup resource class.
Example
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_ec2 as ec2 } from 'aws-cdk-lib';
import { aws_eks as eks } from 'aws-cdk-lib';
import { aws_iam as iam } from 'aws-cdk-lib';
declare const cluster: eks.Cluster;
declare const instanceType: ec2.InstanceType;
declare const role: iam.Role;
declare const securityGroup: ec2.SecurityGroup;
declare const subnet: ec2.Subnet;
declare const subnetFilter: ec2.SubnetFilter;
const nodegroup = new eks.Nodegroup(this, 'MyNodegroup', {
cluster: cluster,
// the properties below are optional
amiType: eks.NodegroupAmiType.AL2_X86_64,
capacityType: eks.CapacityType.SPOT,
desiredSize: 123,
diskSize: 123,
forceUpdate: false,
instanceTypes: [instanceType],
labels: {
labelsKey: 'labels',
},
launchTemplateSpec: {
id: 'id',
// the properties below are optional
version: 'version',
},
maxSize: 123,
maxUnavailable: 123,
maxUnavailablePercentage: 123,
minSize: 123,
nodegroupName: 'nodegroupName',
nodeRole: role,
releaseVersion: 'releaseVersion',
remoteAccess: {
sshKeyName: 'sshKeyName',
// the properties below are optional
sourceSecurityGroups: [securityGroup],
},
subnets: {
availabilityZones: ['availabilityZones'],
onePerAz: false,
subnetFilters: [subnetFilter],
subnetGroupName: 'subnetGroupName',
subnets: [subnet],
subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
},
tags: {
tagsKey: 'tags',
},
taints: [{
effect: eks.TaintEffect.NO_SCHEDULE,
key: 'key',
value: 'value',
}],
});
Initializer
new Nodegroup(scope: Construct, id: string, props: NodegroupProps)
Parameters
- scope
Construct
- id
string
- props
Nodegroup
Props
Construct Props
Name | Type | Description |
---|---|---|
cluster | ICluster | Cluster resource. |
ami | Nodegroup | The AMI type for your node group. |
capacity | Capacity | The capacity type of the nodegroup. |
desired | number | The current number of worker nodes that the managed node group should maintain. |
disk | number | The root device disk size (in GiB) for your node group instances. |
force | boolean | Force the update if the existing node group's pods are unable to be drained due to a pod disruption budget issue. |
instance | Instance [] | The instance types to use for your node group. |
labels? | { [string]: string } | The Kubernetes labels to be applied to the nodes in the node group when they are created. |
launch | Launch | Launch template specification used for the nodegroup. |
max | number | The maximum number of worker nodes that the managed node group can scale out to. |
max | number | The maximum number of nodes unavailable at once during a version update. |
max | number | The maximum percentage of nodes unavailable during a version update. |
min | number | The minimum number of worker nodes that the managed node group can scale in to. |
node | IRole | The IAM role to associate with your node group. |
nodegroup | string | Name of the Nodegroup. |
release | string | The AMI version of the Amazon EKS-optimized AMI to use with your node group (for example, 1.14.7-YYYYMMDD ). |
remote | Nodegroup | The remote access (SSH) configuration to use with your node group. |
subnets? | Subnet | The subnets to use for the Auto Scaling group that is created for your node group. |
tags? | { [string]: string } | The metadata to apply to the node group to assist with categorization and organization. |
taints? | Taint [] | The Kubernetes taints to be applied to the nodes in the node group when they are created. |
cluster
Type:
ICluster
Cluster resource.
amiType?
Type:
Nodegroup
(optional, default: auto-determined from the instanceTypes property when launchTemplateSpec property is not specified)
The AMI type for your node group.
If you explicitly specify the launchTemplate with custom AMI, do not specify this property, or the node group deployment will fail. In other cases, you will need to specify correct amiType for the nodegroup.
capacityType?
Type:
Capacity
(optional, default: ON_DEMAND)
The capacity type of the nodegroup.
desiredSize?
Type:
number
(optional, default: 2)
The current number of worker nodes that the managed node group should maintain.
If not specified,
the nodewgroup will initially create minSize
instances.
diskSize?
Type:
number
(optional, default: 20)
The root device disk size (in GiB) for your node group instances.
forceUpdate?
Type:
boolean
(optional, default: true)
Force the update if the existing node group's pods are unable to be drained due to a pod disruption budget issue.
If an update fails because pods could not be drained, you can force the update after it fails to terminate the old node whether or not any pods are running on the node.
instanceTypes?
Type:
Instance
[]
(optional, default: t3.medium will be used according to the cloudformation document.)
The instance types to use for your node group.
labels?
Type:
{ [string]: string }
(optional, default: None)
The Kubernetes labels to be applied to the nodes in the node group when they are created.
launchTemplateSpec?
Type:
Launch
(optional, default: no launch template)
Launch template specification used for the nodegroup.
See also: https://docs.aws.amazon.com/eks/latest/userguide/launch-templates.html
maxSize?
Type:
number
(optional, default: desiredSize)
The maximum number of worker nodes that the managed node group can scale out to.
Managed node groups can support up to 100 nodes by default.
maxUnavailable?
Type:
number
(optional, default: 1)
The maximum number of nodes unavailable at once during a version update.
Nodes will be updated in parallel. The maximum number is 100.
This value or maxUnavailablePercentage
is required to have a value for custom update configurations to be applied.
maxUnavailablePercentage?
Type:
number
(optional, default: undefined - node groups will update instances one at a time)
The maximum percentage of nodes unavailable during a version update.
This percentage of nodes will be updated in parallel, up to 100 nodes at once.
This value or maxUnavailable
is required to have a value for custom update configurations to be applied.
minSize?
Type:
number
(optional, default: 1)
The minimum number of worker nodes that the managed node group can scale in to.
This number must be greater than or equal to zero.
nodeRole?
Type:
IRole
(optional, default: None. Auto-generated if not specified.)
The IAM role to associate with your node group.
The Amazon EKS worker node kubelet daemon makes calls to AWS APIs on your behalf. Worker nodes receive permissions for these API calls through an IAM instance profile and associated policies. Before you can launch worker nodes and register them into a cluster, you must create an IAM role for those worker nodes to use when they are launched.
nodegroupName?
Type:
string
(optional, default: resource ID)
Name of the Nodegroup.
releaseVersion?
Type:
string
(optional, default: The latest available AMI version for the node group's current Kubernetes version is used.)
The AMI version of the Amazon EKS-optimized AMI to use with your node group (for example, 1.14.7-YYYYMMDD
).
remoteAccess?
Type:
Nodegroup
(optional, default: disabled)
The remote access (SSH) configuration to use with your node group.
Disabled by default, however, if you specify an Amazon EC2 SSH key but do not specify a source security group when you create a managed node group, then port 22 on the worker nodes is opened to the internet (0.0.0.0/0)
subnets?
Type:
Subnet
(optional, default: private subnets)
The subnets to use for the Auto Scaling group that is created for your node group.
By specifying the
SubnetSelection, the selected subnets will automatically apply required tags i.e.
kubernetes.io/cluster/CLUSTER_NAME
with a value of shared
, where CLUSTER_NAME
is replaced with
the name of your cluster.
tags?
Type:
{ [string]: string }
(optional, default: None)
The metadata to apply to the node group to assist with categorization and organization.
Each tag consists of a key and an optional value, both of which you define. Node group tags do not propagate to any other resources associated with the node group, such as the Amazon EC2 instances or subnets.
taints?
Type:
Taint
[]
(optional, default: None)
The Kubernetes taints to be applied to the nodes in the node group when they are created.
Properties
Name | Type | Description |
---|---|---|
cluster | ICluster | the Amazon EKS cluster resource. |
env | Resource | The environment this resource belongs to. |
node | Node | The tree node. |
nodegroup | string | ARN of the nodegroup. |
nodegroup | string | Nodegroup name. |
role | IRole | IAM role of the instance profile for the nodegroup. |
stack | Stack | The stack in which this resource is defined. |
cluster
Type:
ICluster
the Amazon EKS cluster resource.
env
Type:
Resource
The environment this resource belongs to.
For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.
node
Type:
Node
The tree node.
nodegroupArn
Type:
string
ARN of the nodegroup.
nodegroupName
Type:
string
Nodegroup name.
role
Type:
IRole
IAM role of the instance profile for the nodegroup.
stack
Type:
Stack
The stack in which this resource is defined.
Methods
Name | Description |
---|---|
apply | Apply the given removal policy to this resource. |
to | Returns a string representation of this construct. |
static from | Import the Nodegroup from attributes. |
RemovalPolicy(policy)
applypublic applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
Policy
Apply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY
), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN
).
String()
topublic toString(): string
Returns
string
Returns a string representation of this construct.
NodegroupName(scope, id, nodegroupName)
static frompublic static fromNodegroupName(scope: Construct, id: string, nodegroupName: string): INodegroup
Parameters
- scope
Construct
- id
string
- nodegroupName
string
Returns
Import the Nodegroup from attributes.