class CfnNodegroup (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.EKS.CfnNodegroup |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awseks#CfnNodegroup |
Java | software.amazon.awscdk.services.eks.CfnNodegroup |
Python | aws_cdk.aws_eks.CfnNodegroup |
TypeScript | aws-cdk-lib » aws_eks » CfnNodegroup |
Implements
IConstruct
, IDependable
, IInspectable
, ITaggable
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 Customizing managed nodes with launch templates .
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 AWS Regions that support Windows on Amazon EKS.
See also: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-eks-nodegroup.html
Example
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_eks as eks } from 'aws-cdk-lib';
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',
nodeRepairConfig: {
enabled: false,
},
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
— Construct identifier for this resource (unique in its scope). - props
Cfn
— Resource properties.Nodegroup Props
Construct Props
Name | Type | Description |
---|---|---|
cluster | string | The name of your cluster. |
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 any Pod on the existing node group can't 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. |
node | IResolvable | Node | The node auto repair configuration for node group. |
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 } | Metadata that assists 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 your cluster.
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](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_IamInstanceProfile.html)
in your launch template, or the node group deployment will fail. For more information about using launch templates with Amazon EKS, see Customizing managed nodes with launch templates 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](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateNetworkInterface.html)
in your launch template, or the node group deployment will fail. For more information about using launch templates with Amazon EKS, see Customizing managed nodes with launch templates 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 Customizing managed nodes with launch templates 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 Customizing managed nodes with launch templates in the Amazon EKS User Guide .
forceUpdateEnabled?
Type:
boolean |
IResolvable
(optional, default: false)
Force the update if any Pod
on the existing node group can't be drained due to a Pod
disruption budget issue.
If an update fails because all Pods can't be drained, you can force the update after it fails to terminate the old node whether or not any Pod
is 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 Customizing managed nodes with launch templates 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 Kuberneteslabels
applied to the nodes in this group.
launchTemplate?
Type:
IResolvable
|
Launch
(optional)
An object representing a node group's launch template specification.
When using this object, don't directly specify instanceTypes
, diskSize
, or remoteAccess
. Make sure that the launch template meets the requirements in launchTemplateSpecification
. Also refer to Customizing managed nodes with launch templates in the Amazon EKS User Guide .
nodeRepairConfig?
Type:
IResolvable
|
Node
(optional)
The node auto repair configuration for node group.
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 Customizing managed nodes with launch templates 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)
Metadata that assists with categorization and organization.
Each tag consists of a key and an optional value. You define both. Tags don't propagate to any other cluster or AWS resources.
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 your cluster. |
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 your cluster. |
creation | string[] | |
logical | string | The logical ID for this CloudFormation stack element. |
node | Node | The tree node. |
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 | Tag Manager which manages the tags for this resource. |
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 any Pod on the existing node group can't 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. |
node | IResolvable | Node | The node auto repair configuration for node group. |
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 } | Metadata that assists 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. |
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 your cluster.
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 your cluster.
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:
Node
The tree node.
nodeRole
Type:
string
The Amazon Resource Name (ARN) of the IAM role to associate with your node group.
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.
tags
Type:
Tag
Tag Manager which manages the tags for this resource.
amiType?
Type:
string
(optional)
The AMI type for your node group.
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.
forceUpdateEnabled?
Type:
boolean |
IResolvable
(optional)
Force the update if any Pod
on the existing node group can't be drained due to a Pod
disruption budget issue.
instanceTypes?
Type:
string[]
(optional)
Specify the instance types for a node group.
labels?
Type:
IResolvable
| { [string]: string }
(optional)
The Kubernetes labels
applied to the nodes in the node group.
launchTemplate?
Type:
IResolvable
|
Launch
(optional)
An object representing a node group's launch template specification.
nodeRepairConfig?
Type:
IResolvable
|
Node
(optional)
The node auto repair configuration for node group.
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 .
remoteAccess?
Type:
IResolvable
|
Remote
(optional)
The remote access configuration to use with your node group.
scalingConfig?
Type:
IResolvable
|
Scaling
(optional)
The scaling configuration details for the Auto Scaling group that is created for your node group.
tagsRaw?
Type:
{ [string]: string }
(optional)
Metadata that assists with categorization and organization.
taints?
Type:
IResolvable
|
IResolvable
|
Taint
[]
(optional)
The Kubernetes taints to be applied to the nodes in the node group when they are created.
updateConfig?
Type:
IResolvable
|
Update
(optional)
The node group update configuration.
version?
Type:
string
(optional)
The Kubernetes version to use for your managed nodes.
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 | 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. |
obtain | Retrieves an array of resources this resource depends on. |
obtain | Get a shallow copy of dependencies between this resource and other resources in the same stack. |
override | Overrides the auto-generated logical ID with a specific ID. |
remove | Indicates that this resource no longer depends on another resource. |
replace | Replaces one dependency with another. |
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)
.
Dependency(target)
addpublic addDependency(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.
DependsOn(target)
addpublic addDependsOn(target: CfnResource): void
⚠️ Deprecated: use addDependency
Parameters
- target
Cfn
Resource
Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.
Metadata(key, value)
addpublic addMetadata(key: string, value: any): void
Parameters
- key
string
- value
any
Add a value to the CloudFormation Resource Metadata.
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
). In some
cases, a snapshot can be taken of the resource prior to deletion
(RemovalPolicy.SNAPSHOT
). A list of resources that support this policy
can be found in the following link:
Att(attributeName, typeHint?)
getpublic getAtt(attributeName: string, typeHint?: ResolutionTypeHint): Reference
Parameters
- attributeName
string
— The name of the attribute. - typeHint
Resolution
Type Hint
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.
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.
Dependencies()
obtainpublic obtainDependencies(): Stack | CfnResource[]
Returns
Stack
|
Cfn
Resource []
Retrieves an array of resources this resource depends on.
This assembles dependencies on resources across stacks (including nested stacks) automatically.
ResourceDependencies()
obtainpublic obtainResourceDependencies(): CfnResource[]
Returns
Get a shallow copy of dependencies between this resource and other resources in the same stack.
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.
Dependency(target)
removepublic removeDependency(target: CfnResource): void
Parameters
- target
Cfn
Resource
Indicates that this resource no longer depends on another resource.
This can be used for resources across stacks (including nested stacks) and the dependency will automatically be removed from the relevant scope.
Dependency(target, newTarget)
replacepublic replaceDependency(target: CfnResource, newTarget: CfnResource): void
Parameters
- target
Cfn
— The dependency to replace.Resource - newTarget
Cfn
— The new dependency to add.Resource
Replaces one dependency with another.
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 }