class CfnNodegroup (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.EKS.CfnNodegroup |
Java | software.amazon.awscdk.services.eks.CfnNodegroup |
Python | aws_cdk.aws_eks.CfnNodegroup |
TypeScript | @aws-cdk/aws-eks » CfnNodegroup |
Implements
IConstruct
, IConstruct
, IDependable
, IInspectable
A CloudFormation AWS::EKS::Nodegroup
.
Creates a managed node group for an Amazon EKS cluster. You can only create a node group for your cluster that is equal to the current Kubernetes version for the cluster. All node groups are created with the latest AMI release version for the respective minor Kubernetes version of the cluster, unless you deploy a custom AMI using a launch template. For more information about using launch templates, see Launch template support .
An Amazon EKS managed node group is an Amazon EC2 Auto Scaling group and associated Amazon EC2 instances that are managed by AWS for an Amazon EKS cluster. For more information, see Managed node groups in the Amazon EKS User Guide .
Windows AMI types are only supported for commercial Regions that support Windows Amazon EKS.
Example
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as eks from '@aws-cdk/aws-eks';
const cfnNodegroup = new eks.CfnNodegroup(this, 'MyCfnNodegroup', {
clusterName: 'clusterName',
nodeRole: 'nodeRole',
subnets: ['subnets'],
// the properties below are optional
amiType: 'amiType',
capacityType: 'capacityType',
diskSize: 123,
forceUpdateEnabled: false,
instanceTypes: ['instanceTypes'],
labels: {
labelsKey: 'labels',
},
launchTemplate: {
id: 'id',
name: 'name',
version: 'version',
},
nodegroupName: 'nodegroupName',
releaseVersion: 'releaseVersion',
remoteAccess: {
ec2SshKey: 'ec2SshKey',
// the properties below are optional
sourceSecurityGroups: ['sourceSecurityGroups'],
},
scalingConfig: {
desiredSize: 123,
maxSize: 123,
minSize: 123,
},
tags: {
tagsKey: 'tags',
},
taints: [{
effect: 'effect',
key: 'key',
value: 'value',
}],
updateConfig: {
maxUnavailable: 123,
maxUnavailablePercentage: 123,
},
version: 'version',
});
Initializer
new CfnNodegroup(scope: Construct, id: string, props: CfnNodegroupProps)
Parameters
- scope
Construct
— - scope in which this resource is defined. - id
string
— - scoped id of the resource. - props
Cfn
— - resource properties.Nodegroup Props
Create a new AWS::EKS::Nodegroup
.
Construct Props
Name | Type | Description |
---|---|---|
cluster | string | The name of the cluster to create the node group in. |
node | string | The Amazon Resource Name (ARN) of the IAM role to associate with your node group. |
subnets | string[] | The subnets to use for the Auto Scaling group that is created for your node group. |
ami | string | The AMI type for your node group. |
capacity | string | The capacity type of your managed node group. |
disk | number | The root device disk size (in GiB) for your node group instances. |
force | boolean | IResolvable | Force the update if the existing node group's pods are unable to be drained due to a pod disruption budget issue. |
instance | string[] | Specify the instance types for a node group. |
labels? | IResolvable | { [string]: string } | The Kubernetes labels applied to the nodes in the node group. |
launch | IResolvable | Launch | An object representing a node group's launch template specification. |
nodegroup | string | The unique name to give your node group. |
release | string | The AMI version of the Amazon EKS optimized AMI to use with your node group (for example, 1.14.7- *YYYYMMDD* ). By default, the latest available AMI version for the node group's current Kubernetes version is used. For more information, see Amazon EKS optimized Linux AMI Versions in the Amazon EKS User Guide . |
remote | IResolvable | Remote | The remote access configuration to use with your node group. |
scaling | IResolvable | Scaling | The scaling configuration details for the Auto Scaling group that is created for your node group. |
tags? | { [string]: string } | The metadata applied to the node group to assist with categorization and organization. |
taints? | IResolvable | IResolvable | Taint [] | The Kubernetes taints to be applied to the nodes in the node group when they are created. |
update | IResolvable | Update | The node group update configuration. |
version? | string | The Kubernetes version to use for your managed nodes. |
clusterName
Type:
string
The name of the cluster to create the node group in.
nodeRole
Type:
string
The Amazon Resource Name (ARN) of the IAM role to associate with your node group.
The Amazon EKS worker node kubelet
daemon makes calls to AWS APIs on your behalf. Nodes receive permissions for these API calls through an IAM instance profile and associated policies. Before you can launch nodes and register them into a cluster, you must create an IAM role for those nodes to use when they are launched. For more information, see Amazon EKS node IAM role in the Amazon EKS User Guide . If you specify launchTemplate
, then don't specify IamInstanceProfile
in your launch template, or the node group deployment will fail. For more information about using launch templates with Amazon EKS, see Launch template support in the Amazon EKS User Guide .
subnets
Type:
string[]
The subnets to use for the Auto Scaling group that is created for your node group.
If you specify launchTemplate
, then don't specify SubnetId
in your launch template, or the node group deployment will fail. For more information about using launch templates with Amazon EKS, see Launch template support in the Amazon EKS User Guide .
amiType?
Type:
string
(optional)
The AMI type for your node group.
If you specify launchTemplate
, and your launch template uses a custom AMI, then don't specify amiType
, or the node group deployment will fail. If your launch template uses a Windows custom AMI, then add eks:kube-proxy-windows
to your Windows nodes rolearn
in the aws-auth
ConfigMap
. For more information about using launch templates with Amazon EKS, see Launch template support in the Amazon EKS User Guide .
capacityType?
Type:
string
(optional)
The capacity type of your managed node group.
diskSize?
Type:
number
(optional)
The root device disk size (in GiB) for your node group instances.
The default disk size is 20 GiB for Linux and Bottlerocket. The default disk size is 50 GiB for Windows. If you specify launchTemplate
, then don't specify diskSize
, or the node group deployment will fail. For more information about using launch templates with Amazon EKS, see Launch template support in the Amazon EKS User Guide .
forceUpdateEnabled?
Type:
boolean |
IResolvable
(optional)
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:
string[]
(optional)
Specify the instance types for a node group.
If you specify a GPU instance type, make sure to also specify an applicable GPU AMI type with the amiType
parameter. If you specify launchTemplate
, then you can specify zero or one instance type in your launch template or you can specify 0-20 instance types for instanceTypes
. If however, you specify an instance type in your launch template and specify any instanceTypes
, the node group deployment will fail. If you don't specify an instance type in a launch template or for instanceTypes
, then t3.medium
is used, by default. If you specify Spot
for capacityType
, then we recommend specifying multiple values for instanceTypes
. For more information, see Managed node group capacity types and Launch template support in the Amazon EKS User Guide .
labels?
Type:
IResolvable
| { [string]: string }
(optional)
The Kubernetes labels applied to the nodes in the node group.
Only labels that are applied with the Amazon EKS API are shown here. There may be other Kubernetes labels applied to the nodes in this group.
launchTemplate?
Type:
IResolvable
|
Launch
(optional)
An object representing a node group's launch template specification.
If specified, then do not specify instanceTypes
, diskSize
, or remoteAccess
and make sure that the launch template meets the requirements in launchTemplateSpecification
.
nodegroupName?
Type:
string
(optional)
The unique name to give your node group.
releaseVersion?
Type:
string
(optional)
The AMI version of the Amazon EKS optimized AMI to use with your node group (for example, 1.14.7- *YYYYMMDD*
). By default, the latest available AMI version for the node group's current Kubernetes version is used. For more information, see Amazon EKS optimized Linux AMI Versions in the Amazon EKS User Guide .
Changing this value triggers an update of the node group if one is available. You can't update other properties at the same time as updating
Release Version
.
remoteAccess?
Type:
IResolvable
|
Remote
(optional)
The remote access configuration to use with your node group.
For Linux, the protocol is SSH. For Windows, the protocol is RDP. If you specify launchTemplate
, then don't specify remoteAccess
, or the node group deployment will fail. For more information about using launch templates with Amazon EKS, see Launch template support in the Amazon EKS User Guide .
scalingConfig?
Type:
IResolvable
|
Scaling
(optional)
The scaling configuration details for the Auto Scaling group that is created for your node group.
tags?
Type:
{ [string]: string }
(optional)
The metadata applied to the node group to assist with categorization and organization.
Each tag consists of a key and an optional value. You define both. 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:
IResolvable
|
IResolvable
|
Taint
[]
(optional)
The Kubernetes taints to be applied to the nodes in the node group when they are created.
Effect is one of No_Schedule
, Prefer_No_Schedule
, or No_Execute
. Kubernetes taints can be used together with tolerations to control how workloads are scheduled to your nodes. For more information, see Node taints on managed node groups .
updateConfig?
Type:
IResolvable
|
Update
(optional)
The node group update configuration.
version?
Type:
string
(optional)
The Kubernetes version to use for your managed nodes.
By default, the Kubernetes version of the cluster is used, and this is the only accepted specified value. If you specify launchTemplate
, and your launch template uses a custom AMI, then don't specify version
, or the node group deployment will fail. For more information about using launch templates with Amazon EKS, see Launch template support in the Amazon EKS User Guide .
You can't update other properties at the same time as updating
Version
.
Properties
Name | Type | Description |
---|---|---|
attr | string | The Amazon Resource Name (ARN) associated with the managed node group. |
attr | string | The name of the cluster that the managed node group resides in. |
attr | string | |
attr | string | The name associated with an Amazon EKS managed node group. |
cfn | ICfn | Options for this resource, such as condition, update policy etc. |
cfn | { [string]: any } | |
cfn | string | AWS resource type. |
cluster | string | The name of the cluster to create the node group in. |
creation | string[] | |
logical | string | The logical ID for this CloudFormation stack element. |
node | Construct | The construct tree node associated with this construct. |
node | string | The Amazon Resource Name (ARN) of the IAM role to associate with your node group. |
ref | string | Return a string that will be resolved to a CloudFormation { Ref } for this element. |
stack | Stack | The stack in which this element is defined. |
subnets | string[] | The subnets to use for the Auto Scaling group that is created for your node group. |
tags | Tag | The metadata applied to the node group to assist with categorization and organization. |
ami | string | The AMI type for your node group. |
capacity | string | The capacity type of your managed node group. |
disk | number | The root device disk size (in GiB) for your node group instances. |
force | boolean | IResolvable | Force the update if the existing node group's pods are unable to be drained due to a pod disruption budget issue. |
instance | string[] | Specify the instance types for a node group. |
labels? | IResolvable | { [string]: string } | The Kubernetes labels applied to the nodes in the node group. |
launch | IResolvable | Launch | An object representing a node group's launch template specification. |
nodegroup | string | The unique name to give your node group. |
release | string | The AMI version of the Amazon EKS optimized AMI to use with your node group (for example, 1.14.7- *YYYYMMDD* ). By default, the latest available AMI version for the node group's current Kubernetes version is used. For more information, see Amazon EKS optimized Linux AMI Versions in the Amazon EKS User Guide . |
remote | IResolvable | Remote | The remote access configuration to use with your node group. |
scaling | IResolvable | Scaling | The scaling configuration details for the Auto Scaling group that is created for your node group. |
taints? | IResolvable | IResolvable | Taint [] | The Kubernetes taints to be applied to the nodes in the node group when they are created. |
update | IResolvable | Update | The node group update configuration. |
version? | string | The Kubernetes version to use for your managed nodes. |
static CFN_RESOURCE_TYPE_NAME | string | The CloudFormation resource type name for this resource class. |
attrArn
Type:
string
The Amazon Resource Name (ARN) associated with the managed node group.
attrClusterName
Type:
string
The name of the cluster that the managed node group resides in.
attrId
Type:
string
attrNodegroupName
Type:
string
The name associated with an Amazon EKS managed node group.
cfnOptions
Type:
ICfn
Options for this resource, such as condition, update policy etc.
cfnProperties
Type:
{ [string]: any }
cfnResourceType
Type:
string
AWS resource type.
clusterName
Type:
string
The name of the cluster to create the node group in.
creationStack
Type:
string[]
logicalId
Type:
string
The logical ID for this CloudFormation stack element.
The logical ID of the element is calculated from the path of the resource node in the construct tree.
To override this value, use overrideLogicalId(newLogicalId)
.
node
Type:
Construct
The construct tree node associated with this construct.
nodeRole
Type:
string
The Amazon Resource Name (ARN) of the IAM role to associate with your node group.
The Amazon EKS worker node kubelet
daemon makes calls to AWS APIs on your behalf. Nodes receive permissions for these API calls through an IAM instance profile and associated policies. Before you can launch nodes and register them into a cluster, you must create an IAM role for those nodes to use when they are launched. For more information, see Amazon EKS node IAM role in the Amazon EKS User Guide . If you specify launchTemplate
, then don't specify IamInstanceProfile
in your launch template, or the node group deployment will fail. For more information about using launch templates with Amazon EKS, see Launch template support in the Amazon EKS User Guide .
ref
Type:
string
Return a string that will be resolved to a CloudFormation { Ref }
for this element.
If, by any chance, the intrinsic reference of a resource is not a string, you could
coerce it to an IResolvable through Lazy.any({ produce: resource.ref })
.
stack
Type:
Stack
The stack in which this element is defined.
CfnElements must be defined within a stack scope (directly or indirectly).
subnets
Type:
string[]
The subnets to use for the Auto Scaling group that is created for your node group.
If you specify launchTemplate
, then don't specify SubnetId
in your launch template, or the node group deployment will fail. For more information about using launch templates with Amazon EKS, see Launch template support in the Amazon EKS User Guide .
tags
Type:
Tag
The metadata applied to the node group to assist with categorization and organization.
Each tag consists of a key and an optional value. You define both. Node group tags do not propagate to any other resources associated with the node group, such as the Amazon EC2 instances or subnets.
amiType?
Type:
string
(optional)
The AMI type for your node group.
If you specify launchTemplate
, and your launch template uses a custom AMI, then don't specify amiType
, or the node group deployment will fail. If your launch template uses a Windows custom AMI, then add eks:kube-proxy-windows
to your Windows nodes rolearn
in the aws-auth
ConfigMap
. For more information about using launch templates with Amazon EKS, see Launch template support in the Amazon EKS User Guide .
capacityType?
Type:
string
(optional)
The capacity type of your managed node group.
diskSize?
Type:
number
(optional)
The root device disk size (in GiB) for your node group instances.
The default disk size is 20 GiB for Linux and Bottlerocket. The default disk size is 50 GiB for Windows. If you specify launchTemplate
, then don't specify diskSize
, or the node group deployment will fail. For more information about using launch templates with Amazon EKS, see Launch template support in the Amazon EKS User Guide .
forceUpdateEnabled?
Type:
boolean |
IResolvable
(optional)
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:
string[]
(optional)
Specify the instance types for a node group.
If you specify a GPU instance type, make sure to also specify an applicable GPU AMI type with the amiType
parameter. If you specify launchTemplate
, then you can specify zero or one instance type in your launch template or you can specify 0-20 instance types for instanceTypes
. If however, you specify an instance type in your launch template and specify any instanceTypes
, the node group deployment will fail. If you don't specify an instance type in a launch template or for instanceTypes
, then t3.medium
is used, by default. If you specify Spot
for capacityType
, then we recommend specifying multiple values for instanceTypes
. For more information, see Managed node group capacity types and Launch template support in the Amazon EKS User Guide .
labels?
Type:
IResolvable
| { [string]: string }
(optional)
The Kubernetes labels applied to the nodes in the node group.
Only labels that are applied with the Amazon EKS API are shown here. There may be other Kubernetes labels applied to the nodes in this group.
launchTemplate?
Type:
IResolvable
|
Launch
(optional)
An object representing a node group's launch template specification.
If specified, then do not specify instanceTypes
, diskSize
, or remoteAccess
and make sure that the launch template meets the requirements in launchTemplateSpecification
.
nodegroupName?
Type:
string
(optional)
The unique name to give your node group.
releaseVersion?
Type:
string
(optional)
The AMI version of the Amazon EKS optimized AMI to use with your node group (for example, 1.14.7- *YYYYMMDD*
). By default, the latest available AMI version for the node group's current Kubernetes version is used. For more information, see Amazon EKS optimized Linux AMI Versions in the Amazon EKS User Guide .
Changing this value triggers an update of the node group if one is available. You can't update other properties at the same time as updating
Release Version
.
remoteAccess?
Type:
IResolvable
|
Remote
(optional)
The remote access configuration to use with your node group.
For Linux, the protocol is SSH. For Windows, the protocol is RDP. If you specify launchTemplate
, then don't specify remoteAccess
, or the node group deployment will fail. For more information about using launch templates with Amazon EKS, see Launch template support in the Amazon EKS User Guide .
scalingConfig?
Type:
IResolvable
|
Scaling
(optional)
The scaling configuration details for the Auto Scaling group that is created for your node group.
taints?
Type:
IResolvable
|
IResolvable
|
Taint
[]
(optional)
The Kubernetes taints to be applied to the nodes in the node group when they are created.
Effect is one of No_Schedule
, Prefer_No_Schedule
, or No_Execute
. Kubernetes taints can be used together with tolerations to control how workloads are scheduled to your nodes. For more information, see Node taints on managed node groups .
updateConfig?
Type:
IResolvable
|
Update
(optional)
The node group update configuration.
version?
Type:
string
(optional)
The Kubernetes version to use for your managed nodes.
By default, the Kubernetes version of the cluster is used, and this is the only accepted specified value. If you specify launchTemplate
, and your launch template uses a custom AMI, then don't specify version
, or the node group deployment will fail. For more information about using launch templates with Amazon EKS, see Launch template support in the Amazon EKS User Guide .
You can't update other properties at the same time as updating
Version
.
static CFN_RESOURCE_TYPE_NAME
Type:
string
The CloudFormation resource type name for this resource class.
Methods
Name | Description |
---|---|
add | Syntactic sugar for addOverride(path, undefined) . |
add | Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned. |
add | Add a value to the CloudFormation Resource Metadata. |
add | Adds an override to the synthesized CloudFormation resource. |
add | Adds an override that deletes the value of a property from the resource definition. |
add | Adds an override to a resource property. |
apply | Sets the deletion policy of the resource based on the removal policy specified. |
get | Returns a token for an runtime attribute of this resource. |
get | Retrieve a value value from the CloudFormation Resource Metadata. |
inspect(inspector) | Examines the CloudFormation resource and discloses attributes. |
override | Overrides the auto-generated logical ID with a specific ID. |
to | Returns a string representation of this construct. |
protected render |
DeletionOverride(path)
addpublic addDeletionOverride(path: string): void
Parameters
- path
string
— The path of the value to delete.
Syntactic sugar for addOverride(path, undefined)
.
DependsOn(target)
addpublic addDependsOn(target: CfnResource): void
Parameters
- target
Cfn
Resource
Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.
This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.
Metadata(key, value)
addpublic addMetadata(key: string, value: any): void
Parameters
- key
string
- value
any
Add a value to the CloudFormation Resource Metadata.
See also: [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.)
Override(path, value)
addpublic addOverride(path: string, value: any): void
Parameters
- path
string
— - The path of the property, you can use dot notation to override values in complex types. - value
any
— - The value.
Adds an override to the synthesized CloudFormation resource.
To add a
property override, either use addPropertyOverride
or prefix path
with
"Properties." (i.e. Properties.TopicName
).
If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.
To include a literal .
in the property name, prefix with a \
. In most
programming languages you will need to write this as "\\."
because the
\
itself will need to be escaped.
For example,
cfnResource.addOverride('Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes', ['myattribute']);
cfnResource.addOverride('Properties.GlobalSecondaryIndexes.1.ProjectionType', 'INCLUDE');
would add the overrides
"Properties": {
"GlobalSecondaryIndexes": [
{
"Projection": {
"NonKeyAttributes": [ "myattribute" ]
...
}
...
},
{
"ProjectionType": "INCLUDE"
...
},
]
...
}
The value
argument to addOverride
will not be processed or translated
in any way. Pass raw JSON values in here with the correct capitalization
for CloudFormation. If you pass CDK classes or structs, they will be
rendered with lowercased key names, and CloudFormation will reject the
template.
PropertyDeletionOverride(propertyPath)
addpublic addPropertyDeletionOverride(propertyPath: string): void
Parameters
- propertyPath
string
— The path to the property.
Adds an override that deletes the value of a property from the resource definition.
PropertyOverride(propertyPath, value)
addpublic addPropertyOverride(propertyPath: string, value: any): void
Parameters
- propertyPath
string
— The path of the property. - value
any
— The value.
Adds an override to a resource property.
Syntactic sugar for addOverride("Properties.<...>", value)
.
RemovalPolicy(policy?, options?)
applypublic applyRemovalPolicy(policy?: RemovalPolicy, options?: RemovalPolicyOptions): void
Parameters
- policy
Removal
Policy - options
Removal
Policy Options
Sets the deletion policy of the resource based on the removal policy specified.
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
).
Att(attributeName)
getpublic getAtt(attributeName: string): Reference
Parameters
- attributeName
string
— The name of the attribute.
Returns
Returns a token for an runtime attribute of this resource.
Ideally, use generated attribute accessors (e.g. resource.arn
), but this can be used for future compatibility
in case there is no generated attribute.
Metadata(key)
getpublic getMetadata(key: string): any
Parameters
- key
string
Returns
any
Retrieve a value value from the CloudFormation Resource Metadata.
See also: [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.)
inspect(inspector)
public inspect(inspector: TreeInspector): void
Parameters
- inspector
Tree
— - tree inspector to collect and process attributes.Inspector
Examines the CloudFormation resource and discloses attributes.
LogicalId(newLogicalId)
overridepublic overrideLogicalId(newLogicalId: string): void
Parameters
- newLogicalId
string
— The new logical ID to use for this stack element.
Overrides the auto-generated logical ID with a specific ID.
String()
topublic toString(): string
Returns
string
Returns a string representation of this construct.
Properties(props)
protected renderprotected renderProperties(props: { [string]: any }): { [string]: any }
Parameters
- props
{ [string]: any }
Returns
{ [string]: any }