class Cluster (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.EKS.Legacy.Cluster |
Java | software.amazon.awscdk.services.eks.legacy.Cluster |
Python | aws_cdk.aws_eks_legacy.Cluster |
TypeScript (source) | @aws-cdk/aws-eks-legacy » Cluster |
⚠️ Deprecated: undefined
Implements
IConstruct
, IConstruct
, IDependable
, IResource
, ICluster
, IConnectable
A Cluster represents a managed Kubernetes Service (EKS).
This is a fully managed cluster of API Servers (control-plane) The user is still required to create the worker nodes.
Example
declare const cluster: eks.Cluster;
// option 1: use a construct
new eks.HelmChart(this, 'NginxIngress', {
cluster,
chart: 'nginx-ingress',
repository: 'https://helm.nginx.com/stable',
namespace: 'kube-system',
});
// or, option2: use `addChart`
cluster.addChart('NginxIngress', {
chart: 'nginx-ingress',
repository: 'https://helm.nginx.com/stable',
namespace: 'kube-system',
});
Initializer
new Cluster(scope: Construct, id: string, props?: ClusterProps)
⚠️ Deprecated: undefined
Parameters
- scope
Construct
— a Construct, most likely a cdk.Stack created. - id
string
- props
Cluster
— properties in the IClusterProps interface.Props
Initiates an EKS Cluster with the supplied arguments.
Construct Props
Name | Type | Description |
---|---|---|
cluster | string | Name for the cluster. |
default | number | Number of instances to allocate as an initial capacity for this cluster. |
default | Instance | The instance type to use for the default capacity. |
kubectl | boolean | Allows defining kubectrl -related resources on this cluster. |
masters | IRole | An IAM role that will be added to the system:masters Kubernetes RBAC group. |
output | boolean | Determines whether a CloudFormation output with the name of the cluster will be synthesized. |
output | boolean | Determines whether a CloudFormation output with the aws eks update-kubeconfig command will be synthesized. |
output | boolean | Determines whether a CloudFormation output with the ARN of the "masters" IAM role will be synthesized (if mastersRole is specified). |
role? | IRole | Role that provides permissions for the Kubernetes control plane to make calls to AWS API operations on your behalf. |
security | ISecurity | Security Group to use for Control Plane ENIs. |
version? | string | The Kubernetes version to run in the cluster. |
vpc? | IVpc | The VPC in which to create the Cluster. |
vpc | Subnet [] | Where to place EKS Control Plane ENIs. |
clusterName?
⚠️ Deprecated: undefined
Type:
string
(optional, default: Automatically generated name)
Name for the cluster.
defaultCapacity?
⚠️ Deprecated: undefined
Type:
number
(optional, default: 2)
Number of instances to allocate as an initial capacity for this cluster.
Instance type can be configured through defaultCapacityInstanceType
,
which defaults to m5.large
.
Use cluster.addCapacity
to add additional customized capacity. Set this
to 0
is you wish to avoid the initial capacity allocation.
defaultCapacityInstance?
⚠️ Deprecated: undefined
Type:
Instance
(optional, default: m5.large)
The instance type to use for the default capacity.
This will only be taken
into account if defaultCapacity
is > 0.
kubectlEnabled?
⚠️ Deprecated: undefined
Type:
boolean
(optional, default: true The cluster can be managed by the AWS CDK application.)
Allows defining kubectrl
-related resources on this cluster.
If this is disabled, it will not be possible to use the following capabilities:
addResource
addRoleMapping
addUserMapping
addMastersRole
andprops.mastersRole
If this is disabled, the cluster can only be managed by issuing kubectl
commands from a session that uses the IAM role/user that created the
account.
NOTE: changing this value will destoy the cluster. This is because a managable cluster must be created using an AWS CloudFormation custom resource which executes with an IAM role owned by the CDK app.
mastersRole?
⚠️ Deprecated: undefined
Type:
IRole
(optional, default: By default, it will only possible to update this Kubernetes
system by adding resources to this cluster via addResource
or
by defining KubernetesResource
resources in your AWS CDK app.
Use this if you wish to grant cluster administration privileges
to another role.)
An IAM role that will be added to the system:masters
Kubernetes RBAC group.
See also: https://kubernetes.io/docs/reference/access-authn-authz/rbac/#default-roles-and-role-bindings
outputClusterName?
⚠️ Deprecated: undefined
Type:
boolean
(optional, default: false)
Determines whether a CloudFormation output with the name of the cluster will be synthesized.
outputConfigCommand?
⚠️ Deprecated: undefined
Type:
boolean
(optional, default: true)
Determines whether a CloudFormation output with the aws eks update-kubeconfig
command will be synthesized.
This command will include the cluster name and, if applicable, the ARN of the masters IAM role.
outputMastersRoleArn?
⚠️ Deprecated: undefined
Type:
boolean
(optional, default: false)
Determines whether a CloudFormation output with the ARN of the "masters" IAM role will be synthesized (if mastersRole
is specified).
role?
⚠️ Deprecated: undefined
Type:
IRole
(optional, default: A role is automatically created for you)
Role that provides permissions for the Kubernetes control plane to make calls to AWS API operations on your behalf.
securityGroup?
⚠️ Deprecated: undefined
Type:
ISecurity
(optional, default: A security group is automatically created)
Security Group to use for Control Plane ENIs.
version?
⚠️ Deprecated: undefined
Type:
string
(optional, default: If not supplied, will use Amazon default version)
The Kubernetes version to run in the cluster.
vpc?
⚠️ Deprecated: undefined
Type:
IVpc
(optional, default: a VPC with default configuration will be created and can be accessed through cluster.vpc
.)
The VPC in which to create the Cluster.
vpcSubnets?
⚠️ Deprecated: undefined
Type:
Subnet
[]
(optional, default: All public and private subnets)
Where to place EKS Control Plane ENIs.
If you want to create public load balancers, this must include public subnets.
For example, to only select private subnets, supply the following:
const vpcSubnets = [
{ subnetType: ec2.SubnetType.PRIVATE_WITH_NAT }
]
Properties
Name | Type | Description |
---|---|---|
aws | Aws | Lazily creates the AwsAuth resource, which manages AWS authentication mapping. |
cluster | string | The AWS generated ARN for the Cluster resource. |
cluster | string | The certificate-authority-data for your cluster. |
cluster | string | The endpoint URL for the Cluster. |
cluster | string | The Name of the created EKS Cluster. |
connections | Connections | Manages connection rules (Security Group Rules) for the cluster. |
env | Resource | The environment this resource belongs to. |
kubectl | boolean | Indicates if kubectl related operations can be performed on this cluster. |
node | Construct | The construct tree node associated with this construct. |
role | IRole | IAM role assumed by the EKS Control Plane. |
stack | Stack | The stack in which this resource is defined. |
vpc | IVpc | The VPC in which this Cluster was created. |
default | Auto | The auto scaling group that hosts the default capacity for this cluster. |
awsAuth
⚠️ Deprecated: undefined
Type:
Aws
Lazily creates the AwsAuth resource, which manages AWS authentication mapping.
clusterArn
⚠️ Deprecated: undefined
Type:
string
The AWS generated ARN for the Cluster resource.
For example, arn:aws:eks:us-west-2:666666666666:cluster/prod
clusterCertificateAuthorityData
⚠️ Deprecated: undefined
Type:
string
The certificate-authority-data for your cluster.
clusterEndpoint
⚠️ Deprecated: undefined
Type:
string
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
clusterName
⚠️ Deprecated: undefined
Type:
string
The Name of the created EKS Cluster.
connections
⚠️ Deprecated: undefined
Type:
Connections
Manages connection rules (Security Group Rules) for the cluster.
env
⚠️ Deprecated: undefined
Type:
Resource
The environment this resource belongs to.
For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.
kubectlEnabled
⚠️ Deprecated: undefined
Type:
boolean
Indicates if kubectl
related operations can be performed on this cluster.
node
⚠️ Deprecated: undefined
Type:
Construct
The construct tree node associated with this construct.
role
⚠️ Deprecated: undefined
Type:
IRole
IAM role assumed by the EKS Control Plane.
stack
⚠️ Deprecated: undefined
Type:
Stack
The stack in which this resource is defined.
vpc
⚠️ Deprecated: undefined
Type:
IVpc
The VPC in which this Cluster was created.
defaultCapacity?
⚠️ Deprecated: undefined
Type:
Auto
(optional)
The auto scaling group that hosts the default capacity for this cluster.
This will be undefined
if the default capacity is set to 0.
Methods
Name | Description |
---|---|
add | Add compute capacity to this EKS cluster in the form of an AutoScalingGroup. |
add | Add nodes to this EKS cluster. |
add | Defines a Helm chart in this cluster. |
add | Defines a Kubernetes resource in this cluster. |
apply | Apply the given removal policy to this resource. |
to | Returns a string representation of this construct. |
static from | Import an existing cluster. |
AutoScalingGroup(autoScalingGroup, options)
addpublic addAutoScalingGroup(autoScalingGroup: AutoScalingGroup, options: AutoScalingGroupOptions): void
⚠️ Deprecated: undefined
Parameters
- autoScalingGroup
Auto
— [disable-awslint:ref-via-interface].Scaling Group - options
Auto
— options for adding auto scaling groups, like customizing the bootstrap script.Scaling Group Options
Add compute capacity to this EKS cluster in the form of an AutoScalingGroup.
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.
Spot instances will be labeled lifecycle=Ec2Spot
and tainted with PreferNoSchedule
.
If kubectl is enabled, the
spot interrupt handler
daemon will be installed on all spot instances to handle
EC2 Spot Instance Termination Notices.
Prefer to use addCapacity
if possible.
See also: https://docs.aws.amazon.com/eks/latest/userguide/launch-workers.html
Capacity(id, options)
addpublic addCapacity(id: string, options: CapacityOptions): AutoScalingGroup
⚠️ Deprecated: undefined
Parameters
- id
string
- options
Capacity
Options
Returns
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.
Spot instances will be labeled lifecycle=Ec2Spot
and tainted with PreferNoSchedule
.
If kubectl is enabled, the
spot interrupt handler
daemon will be installed on all spot instances to handle
EC2 Spot Instance Termination Notices.
Chart(id, options)
addpublic addChart(id: string, options: HelmChartOptions): HelmChart
⚠️ Deprecated: undefined
Parameters
- id
string
— logical id of this chart. - options
Helm
— options of this chart.Chart Options
Returns
Defines a Helm chart in this cluster.
Resource(id, ...manifest)
addpublic addResource(id: string, ...manifest: any[]): KubernetesResource
⚠️ Deprecated: undefined
Parameters
- id
string
— logical id of this manifest. - manifest
any
— a list of Kubernetes resource specifications.
Returns
Defines a Kubernetes resource in this cluster.
The manifest will be applied/deleted using kubectl as needed.
RemovalPolicy(policy)
applypublic applyRemovalPolicy(policy: RemovalPolicy): void
⚠️ Deprecated: undefined
Parameters
- policy
Removal
Policy
Apply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY
), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN
).
String()
topublic toString(): string
⚠️ Deprecated: undefined
Returns
string
Returns a string representation of this construct.
ClusterAttributes(scope, id, attrs)
static frompublic static fromClusterAttributes(scope: Construct, id: string, attrs: ClusterAttributes): ICluster
⚠️ Deprecated: undefined
Parameters
- scope
Construct
— the construct scope, in most cases 'this'. - id
string
— the id or name to import as. - attrs
Cluster
— the cluster properties to use for importing information.Attributes
Returns
Import an existing cluster.