software.amazon.awscdk.services.eks.Nodegroup Maven / Gradle / Ivy
Show all versions of eks Show documentation
package software.amazon.awscdk.services.eks;
/**
* 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 software.amazon.awscdk.services.ec2.*;
* import software.amazon.awscdk.services.eks.*;
* import software.amazon.awscdk.services.iam.*;
* Cluster cluster;
* InstanceType instanceType;
* Role role;
* SecurityGroup securityGroup;
* Subnet subnet;
* SubnetFilter subnetFilter;
* Nodegroup nodegroup = Nodegroup.Builder.create(this, "MyNodegroup")
* .cluster(cluster)
* // the properties below are optional
* .amiType(NodegroupAmiType.AL2_X86_64)
* .capacityType(CapacityType.SPOT)
* .desiredSize(123)
* .diskSize(123)
* .forceUpdate(false)
* .instanceType(instanceType)
* .instanceTypes(List.of(instanceType))
* .labels(Map.of(
* "labelsKey", "labels"))
* .launchTemplateSpec(LaunchTemplateSpec.builder()
* .id("id")
* // the properties below are optional
* .version("version")
* .build())
* .maxSize(123)
* .minSize(123)
* .nodegroupName("nodegroupName")
* .nodeRole(role)
* .releaseVersion("releaseVersion")
* .remoteAccess(NodegroupRemoteAccess.builder()
* .sshKeyName("sshKeyName")
* // the properties below are optional
* .sourceSecurityGroups(List.of(securityGroup))
* .build())
* .subnets(SubnetSelection.builder()
* .availabilityZones(List.of("availabilityZones"))
* .onePerAz(false)
* .subnetFilters(List.of(subnetFilter))
* .subnetGroupName("subnetGroupName")
* .subnetName("subnetName")
* .subnets(List.of(subnet))
* .subnetType(SubnetType.ISOLATED)
* .build())
* .tags(Map.of(
* "tagsKey", "tags"))
* .taints(List.of(TaintSpec.builder()
* .effect(TaintEffect.NO_SCHEDULE)
* .key("key")
* .value("value")
* .build()))
* .build();
*
*/
@javax.annotation.Generated(value = "jsii-pacmak/1.74.0 (build 6d08790)", date = "2023-03-08T16:00:32.644Z")
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
@software.amazon.jsii.Jsii(module = software.amazon.awscdk.services.eks.$Module.class, fqn = "@aws-cdk/aws-eks.Nodegroup")
public class Nodegroup extends software.amazon.awscdk.core.Resource implements software.amazon.awscdk.services.eks.INodegroup {
protected Nodegroup(final software.amazon.jsii.JsiiObjectRef objRef) {
super(objRef);
}
protected Nodegroup(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) {
super(initializationMode);
}
/**
* @param scope This parameter is required.
* @param id This parameter is required.
* @param props This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Nodegroup(final @org.jetbrains.annotations.NotNull software.constructs.Construct scope, final @org.jetbrains.annotations.NotNull java.lang.String id, final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.eks.NodegroupProps props) {
super(software.amazon.jsii.JsiiObject.InitializationMode.JSII);
software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this, new Object[] { java.util.Objects.requireNonNull(scope, "scope is required"), java.util.Objects.requireNonNull(id, "id is required"), java.util.Objects.requireNonNull(props, "props is required") });
}
/**
* Import the Nodegroup from attributes.
*
* @param scope This parameter is required.
* @param id This parameter is required.
* @param nodegroupName This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public static @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.eks.INodegroup fromNodegroupName(final @org.jetbrains.annotations.NotNull software.constructs.Construct scope, final @org.jetbrains.annotations.NotNull java.lang.String id, final @org.jetbrains.annotations.NotNull java.lang.String nodegroupName) {
return software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.awscdk.services.eks.Nodegroup.class, "fromNodegroupName", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.eks.INodegroup.class), new Object[] { java.util.Objects.requireNonNull(scope, "scope is required"), java.util.Objects.requireNonNull(id, "id is required"), java.util.Objects.requireNonNull(nodegroupName, "nodegroupName is required") });
}
/**
* the Amazon EKS cluster resource.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.eks.ICluster getCluster() {
return software.amazon.jsii.Kernel.get(this, "cluster", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.eks.ICluster.class));
}
/**
* ARN of the nodegroup.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public @org.jetbrains.annotations.NotNull java.lang.String getNodegroupArn() {
return software.amazon.jsii.Kernel.get(this, "nodegroupArn", software.amazon.jsii.NativeType.forClass(java.lang.String.class));
}
/**
* Nodegroup name.
*/
@Override
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public @org.jetbrains.annotations.NotNull java.lang.String getNodegroupName() {
return software.amazon.jsii.Kernel.get(this, "nodegroupName", software.amazon.jsii.NativeType.forClass(java.lang.String.class));
}
/**
* IAM role of the instance profile for the nodegroup.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.iam.IRole getRole() {
return software.amazon.jsii.Kernel.get(this, "role", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.iam.IRole.class));
}
/**
* A fluent builder for {@link software.amazon.awscdk.services.eks.Nodegroup}.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public static final class Builder implements software.amazon.jsii.Builder {
/**
* @return a new instance of {@link Builder}.
* @param scope This parameter is required.
* @param id This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public static Builder create(final software.constructs.Construct scope, final java.lang.String id) {
return new Builder(scope, id);
}
private final software.constructs.Construct scope;
private final java.lang.String id;
private final software.amazon.awscdk.services.eks.NodegroupProps.Builder props;
private Builder(final software.constructs.Construct scope, final java.lang.String id) {
this.scope = scope;
this.id = id;
this.props = new software.amazon.awscdk.services.eks.NodegroupProps.Builder();
}
/**
* 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.
*
* Default: - auto-determined from the instanceTypes property when launchTemplateSpec property is not specified
*
* @return {@code this}
* @param amiType The AMI type for your node group. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder amiType(final software.amazon.awscdk.services.eks.NodegroupAmiType amiType) {
this.props.amiType(amiType);
return this;
}
/**
* The capacity type of the nodegroup.
*
* Default: - ON_DEMAND
*
* @return {@code this}
* @param capacityType The capacity type of the nodegroup. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder capacityType(final software.amazon.awscdk.services.eks.CapacityType capacityType) {
this.props.capacityType(capacityType);
return this;
}
/**
* The current number of worker nodes that the managed node group should maintain.
*
* If not specified,
* the nodewgroup will initially create minSize
instances.
*
* Default: 2
*
* @return {@code this}
* @param desiredSize The current number of worker nodes that the managed node group should maintain. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder desiredSize(final java.lang.Number desiredSize) {
this.props.desiredSize(desiredSize);
return this;
}
/**
* The root device disk size (in GiB) for your node group instances.
*
* Default: 20
*
* @return {@code this}
* @param diskSize The root device disk size (in GiB) for your node group instances. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder diskSize(final java.lang.Number diskSize) {
this.props.diskSize(diskSize);
return this;
}
/**
* 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.
*
* Default: true
*
* @return {@code this}
* @param forceUpdate Force the update if the existing node group's pods are unable to be drained due to a pod disruption budget issue. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder forceUpdate(final java.lang.Boolean forceUpdate) {
this.props.forceUpdate(forceUpdate);
return this;
}
/**
* (deprecated) The instance type to use for your node group.
*
* Currently, you can specify a single instance type for a node group.
* The default value for this parameter is t3.medium
. If you choose a GPU instance type, be sure to specify the
* AL2_x86_64_GPU
with the amiType parameter.
*
* Default: t3.medium
*
* @return {@code this}
* @deprecated Use `instanceTypes` instead.
* @param instanceType The instance type to use for your node group. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated)
@Deprecated
public Builder instanceType(final software.amazon.awscdk.services.ec2.InstanceType instanceType) {
this.props.instanceType(instanceType);
return this;
}
/**
* The instance types to use for your node group.
*
* Default: t3.medium will be used according to the cloudformation document.
*
* @return {@code this}
* @see - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-eks-nodegroup.html#cfn-eks-nodegroup-instancetypes
* @param instanceTypes The instance types to use for your node group. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder instanceTypes(final java.util.List extends software.amazon.awscdk.services.ec2.InstanceType> instanceTypes) {
this.props.instanceTypes(instanceTypes);
return this;
}
/**
* The Kubernetes labels to be applied to the nodes in the node group when they are created.
*
* Default: - None
*
* @return {@code this}
* @param labels The Kubernetes labels to be applied to the nodes in the node group when they are created. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder labels(final java.util.Map labels) {
this.props.labels(labels);
return this;
}
/**
* Launch template specification used for the nodegroup.
*
* Default: - no launch template
*
* @return {@code this}
* @see - https://docs.aws.amazon.com/eks/latest/userguide/launch-templates.html
* @param launchTemplateSpec Launch template specification used for the nodegroup. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder launchTemplateSpec(final software.amazon.awscdk.services.eks.LaunchTemplateSpec launchTemplateSpec) {
this.props.launchTemplateSpec(launchTemplateSpec);
return this;
}
/**
* 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.
*
* Default: - desiredSize
*
* @return {@code this}
* @param maxSize The maximum number of worker nodes that the managed node group can scale out to. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder maxSize(final java.lang.Number maxSize) {
this.props.maxSize(maxSize);
return this;
}
/**
* 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.
*
* Default: 1
*
* @return {@code this}
* @param minSize The minimum number of worker nodes that the managed node group can scale in to. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder minSize(final java.lang.Number minSize) {
this.props.minSize(minSize);
return this;
}
/**
* Name of the Nodegroup.
*
* Default: - resource ID
*
* @return {@code this}
* @param nodegroupName Name of the Nodegroup. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder nodegroupName(final java.lang.String nodegroupName) {
this.props.nodegroupName(nodegroupName);
return this;
}
/**
* 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.
*
* Default: - None. Auto-generated if not specified.
*
* @return {@code this}
* @param nodeRole The IAM role to associate with your node group. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder nodeRole(final software.amazon.awscdk.services.iam.IRole nodeRole) {
this.props.nodeRole(nodeRole);
return this;
}
/**
* The AMI version of the Amazon EKS-optimized AMI to use with your node group (for example, `1.14.7-YYYYMMDD`).
*
* Default: - The latest available AMI version for the node group's current Kubernetes version is used.
*
* @return {@code this}
* @param releaseVersion The AMI version of the Amazon EKS-optimized AMI to use with your node group (for example, `1.14.7-YYYYMMDD`). This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder releaseVersion(final java.lang.String releaseVersion) {
this.props.releaseVersion(releaseVersion);
return this;
}
/**
* 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)
*
* Default: - disabled
*
* @return {@code this}
* @param remoteAccess The remote access (SSH) configuration to use with your node group. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder remoteAccess(final software.amazon.awscdk.services.eks.NodegroupRemoteAccess remoteAccess) {
this.props.remoteAccess(remoteAccess);
return this;
}
/**
* 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.
*
* Default: - private subnets
*
* @return {@code this}
* @param subnets The subnets to use for the Auto Scaling group that is created for your node group. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder subnets(final software.amazon.awscdk.services.ec2.SubnetSelection subnets) {
this.props.subnets(subnets);
return this;
}
/**
* 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.
*
* Default: - None
*
* @return {@code this}
* @param tags The metadata to apply to the node group to assist with categorization and organization. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder tags(final java.util.Map tags) {
this.props.tags(tags);
return this;
}
/**
* The Kubernetes taints to be applied to the nodes in the node group when they are created.
*
* Default: - None
*
* @return {@code this}
* @param taints The Kubernetes taints to be applied to the nodes in the node group when they are created. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder taints(final java.util.List extends software.amazon.awscdk.services.eks.TaintSpec> taints) {
this.props.taints(taints);
return this;
}
/**
* Cluster resource.
*
* @return {@code this}
* @param cluster Cluster resource. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder cluster(final software.amazon.awscdk.services.eks.ICluster cluster) {
this.props.cluster(cluster);
return this;
}
/**
* @returns a newly built instance of {@link software.amazon.awscdk.services.eks.Nodegroup}.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
@Override
public software.amazon.awscdk.services.eks.Nodegroup build() {
return new software.amazon.awscdk.services.eks.Nodegroup(
this.scope,
this.id,
this.props.build()
);
}
}
}