Class Cluster
- All Implemented Interfaces:
IEnvironmentAware,IResource,IConnectable,ICluster,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct,software.constructs.IDependable
- Direct Known Subclasses:
FargateCluster
This is a fully managed cluster of API Servers (control-plane) The user is still required to create the worker nodes.
Example:
Cluster cluster = Cluster.Builder.create(this, "ManagedNodeCluster")
.version(KubernetesVersion.V1_33)
.defaultCapacityType(DefaultCapacityType.NODEGROUP)
.build();
// Add a Fargate Profile for specific workloads (e.g., default namespace)
cluster.addFargateProfile("FargateProfile", FargateProfileOptions.builder()
.selectors(List.of(Selector.builder().namespace("default").build()))
.build());
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.amazon.awscdk.services.eks.v2.alpha.ICluster
ICluster.Jsii$Default, ICluster.Jsii$ProxyNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.IResource
IResource.Jsii$Default -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String(experimental) Uniquely identifies this class. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCluster(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedCluster(software.amazon.jsii.JsiiObjectRef objRef) Cluster(software.constructs.Construct scope, String id, ClusterProps props) (experimental) Initiates an EKS Cluster with the supplied arguments. -
Method Summary
Modifier and TypeMethodDescription(experimental) Add nodes to this EKS cluster.addCdk8sChart(String id, software.constructs.Construct chart) (experimental) Defines a CDK8s chart in this cluster.addCdk8sChart(String id, software.constructs.Construct chart, KubernetesManifestOptions options) (experimental) Defines a CDK8s chart in this cluster.addFargateProfile(String id, FargateProfileOptions options) (experimental) Adds a Fargate profile to this cluster.addHelmChart(String id, HelmChartOptions options) (experimental) Defines a Helm chart in this cluster.addManifest(String id, Map<String, Object>... manifest) (experimental) Defines a Kubernetes resource in this cluster.(experimental) Add managed nodegroup to this Amazon EKS cluster.addNodegroupCapacity(String id, NodegroupOptions options) (experimental) Add managed nodegroup to this Amazon EKS cluster.(experimental) Creates a new service account with corresponding IAM Role (IRSA).addServiceAccount(String id, ServiceAccountOptions options) (experimental) Creates a new service account with corresponding IAM Role (IRSA).voidconnectAutoScalingGroupCapacity(AutoScalingGroup autoScalingGroup, AutoScalingGroupOptions options) (experimental) Connect capacity in the form of an existing AutoScalingGroup to the EKS cluster.static IClusterfromClusterAttributes(software.constructs.Construct scope, String id, ClusterAttributes attrs) (experimental) Import an existing cluster.(experimental) The ALB Controller construct defined for this cluster.(experimental) The AWS generated ARN for the Cluster resource.(experimental) The certificate-authority-data for your cluster.(experimental) Amazon Resource Name (ARN) or alias of the customer master key (CMK).(experimental) The endpoint URL for the Cluster.(experimental) The Name of the created EKS Cluster.(experimental) If this cluster is kubectl-enabled, returns the OpenID Connect issuer url.(experimental) The cluster security group that was created by Amazon EKS for the cluster.(experimental) The id of the cluster security group that was created by Amazon EKS for the cluster.(experimental) Manages connection rules (Security Group Rules) for the cluster.(experimental) The auto scaling group that hosts the default capacity for this cluster.(experimental) The node group that hosts the default capacity for this cluster.(experimental) Retrieves the EKS Pod Identity Agent addon for the EKS cluster.getIngressLoadBalancerAddress(String ingressName) (experimental) Fetch the load balancer address of an ingress backed by a load balancer.getIngressLoadBalancerAddress(String ingressName, IngressLoadBalancerAddressOptions options) (experimental) Fetch the load balancer address of an ingress backed by a load balancer.(experimental) Specify which IP family is used to assign Kubernetes pod and service IP addresses.(experimental) Kubectl Provider for issuing kubectl commands against it.(experimental) AnOpenIdConnectProviderresource associated with this cluster, and which can be used to link this cluster to AWS IAM.getPrune()(experimental) Determines if Kubernetes resources can be pruned automatically.getRole()(experimental) IAM role assumed by the EKS Control Plane.getServiceLoadBalancerAddress(String serviceName) (experimental) Fetch the load balancer address of a service of type 'LoadBalancer'.getServiceLoadBalancerAddress(String serviceName, ServiceLoadBalancerAddressOptions options) (experimental) Fetch the load balancer address of a service of type 'LoadBalancer'.getVpc()(experimental) The VPC in which this Cluster was created.voidgrantAccess(String id, String principal, List<IAccessPolicy> accessPolicies) (experimental) Grants the specified IAM principal access to the EKS cluster based on the provided access policies.grantClusterAdmin(String id, String principal) (experimental) Grants the specified IAM principal cluster admin access to the EKS cluster.Methods inherited from class software.amazon.awscdk.Resource
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isOwnedResource, isResourceMethods inherited from class software.constructs.Construct
getNode, isConstruct, toStringMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.amazon.awscdk.services.eks.v2.alpha.ICluster
getKubectlProviderOptionsMethods inherited from interface software.constructs.IConstruct
getNodeMethods inherited from interface software.amazon.awscdk.IEnvironmentAware
getEnvMethods inherited from interface software.amazon.awscdk.IResource
applyRemovalPolicy, getStackMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Field Details
-
PROPERTY_INJECTION_ID
(experimental) Uniquely identifies this class.
-
-
Constructor Details
-
Cluster
protected Cluster(software.amazon.jsii.JsiiObjectRef objRef) -
Cluster
protected Cluster(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
Cluster
@Stability(Experimental) public Cluster(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull ClusterProps props) (experimental) Initiates an EKS Cluster with the supplied arguments.- Parameters:
scope- a Construct, most likely a cdk.Stack created. This parameter is required.id- the id of the Construct to create. This parameter is required.props- properties in the IClusterProps interface. This parameter is required.
-
-
Method Details
-
fromClusterAttributes
@Stability(Experimental) @NotNull public static ICluster fromClusterAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull ClusterAttributes attrs) (experimental) Import an existing cluster.- Parameters:
scope- the construct scope, in most cases 'this'. This parameter is required.id- the id or name to import as. This parameter is required.attrs- the cluster properties to use for importing information. This parameter is required.
-
addAutoScalingGroupCapacity
@Stability(Experimental) @NotNull public AutoScalingGroup addAutoScalingGroupCapacity(@NotNull String id, @NotNull AutoScalingGroupCapacityOptions options) (experimental) Add nodes to this EKS cluster.The nodes will automatically be configured with the right VPC and AMI for the instance type and Kubernetes version.
Note that if you specify
updateType: RollingUpdateorupdateType: ReplacingUpdate, your nodes might be replaced at deploy time without notice in case the recommended AMI for your machine image type has been updated by AWS. The default behavior forupdateTypeisNone, which means only new instances will be launched using the new AMI.- Parameters:
id- This parameter is required.options- This parameter is required.
-
addCdk8sChart
@Stability(Experimental) @NotNull public KubernetesManifest addCdk8sChart(@NotNull String id, @NotNull software.constructs.Construct chart, @Nullable KubernetesManifestOptions options) (experimental) Defines a CDK8s chart in this cluster.- Specified by:
addCdk8sChartin interfaceICluster- Parameters:
id- logical id of this chart. This parameter is required.chart- the cdk8s chart. This parameter is required.options-- Returns:
- a
KubernetesManifestconstruct representing the chart.
-
addCdk8sChart
@Stability(Experimental) @NotNull public KubernetesManifest addCdk8sChart(@NotNull String id, @NotNull software.constructs.Construct chart) (experimental) Defines a CDK8s chart in this cluster.- Specified by:
addCdk8sChartin interfaceICluster- Parameters:
id- logical id of this chart. This parameter is required.chart- the cdk8s chart. This parameter is required.- Returns:
- a
KubernetesManifestconstruct representing the chart.
-
addFargateProfile
@Stability(Experimental) @NotNull public FargateProfile addFargateProfile(@NotNull String id, @NotNull FargateProfileOptions options) (experimental) Adds a Fargate profile to this cluster.- Parameters:
id- the id of this profile. This parameter is required.options- profile options. This parameter is required.- See Also:
-
addHelmChart
@Stability(Experimental) @NotNull public HelmChart addHelmChart(@NotNull String id, @NotNull HelmChartOptions options) (experimental) Defines a Helm chart in this cluster.- Specified by:
addHelmChartin interfaceICluster- Parameters:
id- logical id of this chart. This parameter is required.options- options of this chart. This parameter is required.- Returns:
- a
HelmChartconstruct
-
addManifest
@Stability(Experimental) @NotNull public KubernetesManifest addManifest(@NotNull String id, @NotNull Map<String, Object>... manifest) (experimental) Defines a Kubernetes resource in this cluster.The manifest will be applied/deleted using kubectl as needed.
- Specified by:
addManifestin interfaceICluster- Parameters:
id- logical id of this manifest. This parameter is required.manifest- a list of Kubernetes resource specifications. This parameter is required.- Returns:
- a
KubernetesResourceobject.
-
addNodegroupCapacity
@Stability(Experimental) @NotNull public Nodegroup addNodegroupCapacity(@NotNull String id, @Nullable NodegroupOptions options) (experimental) Add managed nodegroup to this Amazon EKS cluster.This method will create a new managed nodegroup and add into the capacity.
- Parameters:
id- The ID of the nodegroup. This parameter is required.options- options for creating a new nodegroup.- See Also:
-
addNodegroupCapacity
(experimental) Add managed nodegroup to this Amazon EKS cluster.This method will create a new managed nodegroup and add into the capacity.
- Parameters:
id- The ID of the nodegroup. This parameter is required.- See Also:
-
addServiceAccount
@Stability(Experimental) @NotNull public ServiceAccount addServiceAccount(@NotNull String id, @Nullable ServiceAccountOptions options) (experimental) Creates a new service account with corresponding IAM Role (IRSA).- Specified by:
addServiceAccountin interfaceICluster- Parameters:
id- This parameter is required.options-
-
addServiceAccount
(experimental) Creates a new service account with corresponding IAM Role (IRSA).- Specified by:
addServiceAccountin interfaceICluster- Parameters:
id- This parameter is required.
-
connectAutoScalingGroupCapacity
@Stability(Experimental) public void connectAutoScalingGroupCapacity(@NotNull AutoScalingGroup autoScalingGroup, @NotNull AutoScalingGroupOptions options) (experimental) Connect capacity in the form of an existing AutoScalingGroup to the EKS cluster.The AutoScalingGroup must be running an EKS-optimized AMI containing the /etc/eks/bootstrap.sh script. This method will configure Security Groups, add the right policies to the instance role, apply the right tags, and add the required user data to the instance's launch configuration.
Prefer to use
addAutoScalingGroupCapacityif possible.- Specified by:
connectAutoScalingGroupCapacityin interfaceICluster- Parameters:
autoScalingGroup- [disable-awslint:ref-via-interface]. This parameter is required.options- options for adding auto scaling groups, like customizing the bootstrap script. This parameter is required.- See Also:
-
getIngressLoadBalancerAddress
@Stability(Experimental) @NotNull public String getIngressLoadBalancerAddress(@NotNull String ingressName, @Nullable IngressLoadBalancerAddressOptions options) (experimental) Fetch the load balancer address of an ingress backed by a load balancer.- Parameters:
ingressName- The name of the ingress. This parameter is required.options- Additional operation options.
-
getIngressLoadBalancerAddress
@Stability(Experimental) @NotNull public String getIngressLoadBalancerAddress(@NotNull String ingressName) (experimental) Fetch the load balancer address of an ingress backed by a load balancer.- Parameters:
ingressName- The name of the ingress. This parameter is required.
-
getServiceLoadBalancerAddress
@Stability(Experimental) @NotNull public String getServiceLoadBalancerAddress(@NotNull String serviceName, @Nullable ServiceLoadBalancerAddressOptions options) (experimental) Fetch the load balancer address of a service of type 'LoadBalancer'.- Parameters:
serviceName- The name of the service. This parameter is required.options- Additional operation options.
-
getServiceLoadBalancerAddress
@Stability(Experimental) @NotNull public String getServiceLoadBalancerAddress(@NotNull String serviceName) (experimental) Fetch the load balancer address of a service of type 'LoadBalancer'.- Parameters:
serviceName- The name of the service. This parameter is required.
-
grantAccess
@Stability(Experimental) public void grantAccess(@NotNull String id, @NotNull String principal, @NotNull List<IAccessPolicy> accessPolicies) (experimental) Grants the specified IAM principal access to the EKS cluster based on the provided access policies.This method creates an
AccessEntryconstruct that grants the specified IAM principal the access permissions defined by the providedIAccessPolicyarray. This allows the IAM principal to perform the actions permitted by the access policies within the EKS cluster.- Parameters:
id-- The ID of the
AccessEntryconstruct to be created.
- The ID of the
principal-- The IAM principal (role or user) to be granted access to the EKS cluster.
accessPolicies-- An array of
IAccessPolicyobjects that define the access permissions to be granted to the IAM principal.
- An array of
-
grantClusterAdmin
@Stability(Experimental) @NotNull public AccessEntry grantClusterAdmin(@NotNull String id, @NotNull String principal) (experimental) Grants the specified IAM principal cluster admin access to the EKS cluster.This method creates an
AccessEntryconstruct that grants the specified IAM principal the cluster admin access permissions. This allows the IAM principal to perform the actions permitted by the cluster admin acces.- Parameters:
id-- The ID of the
AccessEntryconstruct to be created.
- The ID of the
principal-- The IAM principal (role or user) to be granted access to the EKS cluster.
- Returns:
- the access entry construct
-
getClusterArn
(experimental) The AWS generated ARN for the Cluster resource.For example,
arn:aws:eks:us-west-2:666666666666:cluster/prod- Specified by:
getClusterArnin interfaceICluster
-
getClusterCertificateAuthorityData
(experimental) The certificate-authority-data for your cluster.- Specified by:
getClusterCertificateAuthorityDatain interfaceICluster
-
getClusterEncryptionConfigKeyArn
(experimental) Amazon Resource Name (ARN) or alias of the customer master key (CMK).- Specified by:
getClusterEncryptionConfigKeyArnin interfaceICluster
-
getClusterEndpoint
(experimental) The endpoint URL for the Cluster.This is the URL inside the kubeconfig file to use with kubectl
For example,
https://5E1D0CEXAMPLEA591B746AFC5AB30262.yl4.us-west-2.eks.amazonaws.com- Specified by:
getClusterEndpointin interfaceICluster
-
getClusterName
(experimental) The Name of the created EKS Cluster.- Specified by:
getClusterNamein interfaceICluster
-
getClusterOpenIdConnectIssuerUrl
(experimental) If this cluster is kubectl-enabled, returns the OpenID Connect issuer url.If this cluster is not kubectl-enabled (i.e. uses the stock
CfnCluster), this isundefined. -
getClusterSecurityGroup
(experimental) The cluster security group that was created by Amazon EKS for the cluster.- Specified by:
getClusterSecurityGroupin interfaceICluster
-
getClusterSecurityGroupId
(experimental) The id of the cluster security group that was created by Amazon EKS for the cluster.- Specified by:
getClusterSecurityGroupIdin interfaceICluster
-
getConnections
(experimental) Manages connection rules (Security Group Rules) for the cluster.- Specified by:
getConnectionsin interfaceIConnectable
-
getOpenIdConnectProvider
(experimental) AnOpenIdConnectProviderresource associated with this cluster, and which can be used to link this cluster to AWS IAM.A provider will only be defined if this property is accessed (lazy initialization).
- Specified by:
getOpenIdConnectProviderin interfaceICluster
-
getPrune
(experimental) Determines if Kubernetes resources can be pruned automatically. -
getRole
(experimental) IAM role assumed by the EKS Control Plane. -
getVpc
(experimental) The VPC in which this Cluster was created. -
getAlbController
(experimental) The ALB Controller construct defined for this cluster.Will be undefined if
albControllerwasn't configured. -
getDefaultCapacity
(experimental) The auto scaling group that hosts the default capacity for this cluster.This will be
undefinedif thedefaultCapacityTypeis notEC2ordefaultCapacityTypeisEC2but default capacity is set to 0. -
getDefaultNodegroup
(experimental) The node group that hosts the default capacity for this cluster.This will be
undefinedif thedefaultCapacityTypeisEC2ordefaultCapacityTypeisNODEGROUPbut default capacity is set to 0. -
getEksPodIdentityAgent
(experimental) Retrieves the EKS Pod Identity Agent addon for the EKS cluster.The EKS Pod Identity Agent is responsible for managing the temporary credentials used by pods in the cluster to access AWS resources. It runs as a DaemonSet on each node and provides the necessary credentials to the pods based on their associated service account.
- Specified by:
getEksPodIdentityAgentin interfaceICluster
-
getIpFamily
(experimental) Specify which IP family is used to assign Kubernetes pod and service IP addresses.Default: - IpFamily.IP_V4
- Specified by:
getIpFamilyin interfaceICluster- See Also:
-
getKubectlProvider
Description copied from interface:ICluster(experimental) Kubectl Provider for issuing kubectl commands against it.If not defined, a default provider will be used
- Specified by:
getKubectlProviderin interfaceICluster
-