ClusterProps

class aws_cdk.aws_eks.ClusterProps(*, version, cluster_name=None, output_cluster_name=None, output_config_command=None, role=None, security_group=None, vpc=None, vpc_subnets=None, cluster_handler_environment=None, core_dns_compute_type=None, endpoint_access=None, kubectl_environment=None, kubectl_layer=None, kubectl_memory=None, masters_role=None, output_masters_role_arn=None, place_cluster_handler_in_vpc=None, prune=None, default_capacity=None, default_capacity_instance=None, default_capacity_type=None, secrets_encryption_key=None)

Bases: aws_cdk.aws_eks.ClusterOptions

(experimental) Common configuration props for EKS clusters.

Parameters
  • version (KubernetesVersion) – (experimental) The Kubernetes version to run in the cluster.

  • cluster_name (Optional[str]) – (experimental) Name for the cluster. Default: - Automatically generated name

  • output_cluster_name (Optional[bool]) – (experimental) Determines whether a CloudFormation output with the name of the cluster will be synthesized. Default: false

  • output_config_command (Optional[bool]) – (experimental) 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. Default: true

  • role (Optional[IRole]) – (experimental) Role that provides permissions for the Kubernetes control plane to make calls to AWS API operations on your behalf. Default: - A role is automatically created for you

  • security_group (Optional[ISecurityGroup]) – (experimental) Security Group to use for Control Plane ENIs. Default: - A security group is automatically created

  • vpc (Optional[IVpc]) – (experimental) The VPC in which to create the Cluster. Default: - a VPC with default configuration will be created and can be accessed through cluster.vpc.

  • vpc_subnets (Optional[List[SubnetSelection]]) – (experimental) 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:: vpcSubnets: [ { subnetType: ec2.SubnetType.Private } ] Default: - All public and private subnets

  • cluster_handler_environment (Optional[Mapping[str, str]]) – (experimental) Custom environment variables when interacting with the EKS endpoint to manage the cluster lifecycle. Default: - No environment variables.

  • core_dns_compute_type (Optional[CoreDnsComputeType]) – (experimental) Controls the “eks.amazonaws.com/compute-type” annotation in the CoreDNS configuration on your cluster to determine which compute type to use for CoreDNS. Default: CoreDnsComputeType.EC2 (for FargateCluster the default is FARGATE)

  • endpoint_access (Optional[EndpointAccess]) – (experimental) Configure access to the Kubernetes API server endpoint.. Default: EndpointAccess.PUBLIC_AND_PRIVATE

  • kubectl_environment (Optional[Mapping[str, str]]) – (experimental) Environment variables for the kubectl execution. Only relevant for kubectl enabled clusters. Default: - No environment variables.

  • kubectl_layer (Optional[ILayerVersion]) – (experimental) An AWS Lambda Layer which includes kubectl, Helm and the AWS CLI. By default, the provider will use the layer included in the “aws-lambda-layer-kubectl” SAR application which is available in all commercial regions. To deploy the layer locally, visit https://github.com/aws-samples/aws-lambda-layer-kubectl/blob/master/cdk/README.md for instructions on how to prepare the .zip file and then define it in your app as follows:: const layer = new lambda.LayerVersion(this, ‘kubectl-layer’, { code: lambda.Code.fromAsset(${__dirname}/layer.zip)), compatibleRuntimes: [lambda.Runtime.PROVIDED] }) Default: - the layer provided by the aws-lambda-layer-kubectl SAR app.

  • kubectl_memory (Optional[Size]) – (experimental) Amount of memory to allocate to the provider’s lambda function. Default: Size.gibibytes(1)

  • masters_role (Optional[IRole]) – (experimental) An IAM role that will be added to the system:masters Kubernetes RBAC group. Default: - a role that assumable by anyone with permissions in the same account will automatically be defined

  • output_masters_role_arn (Optional[bool]) – (experimental) Determines whether a CloudFormation output with the ARN of the “masters” IAM role will be synthesized (if mastersRole is specified). Default: false

  • place_cluster_handler_in_vpc (Optional[bool]) – (experimental) If set to true, the cluster handler functions will be placed in the private subnets of the cluster vpc, subject to the vpcSubnets selection strategy. Default: false

  • prune (Optional[bool]) – (experimental) Indicates whether Kubernetes resources added through addManifest() can be automatically pruned. When this is enabled (default), prune labels will be allocated and injected to each resource. These labels will then be used when issuing the kubectl apply operation with the --prune switch. Default: true

  • default_capacity (Union[int, float, None]) – (experimental) 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.addAutoScalingGroupCapacity to add additional customized capacity. Set this to 0 is you wish to avoid the initial capacity allocation. Default: 2

  • default_capacity_instance (Optional[InstanceType]) – (experimental) The instance type to use for the default capacity. This will only be taken into account if defaultCapacity is > 0. Default: m5.large

  • default_capacity_type (Optional[DefaultCapacityType]) – (experimental) The default capacity type for the cluster. Default: NODEGROUP

  • secrets_encryption_key (Optional[IKey]) – (experimental) KMS secret for envelope encryption for Kubernetes secrets. Default: - By default, Kubernetes stores all secret object data within etcd and all etcd volumes used by Amazon EKS are encrypted at the disk-level using AWS-Managed encryption keys.

Stability

experimental

Attributes

cluster_handler_environment

(experimental) Custom environment variables when interacting with the EKS endpoint to manage the cluster lifecycle.

Default
  • No environment variables.

Stability

experimental

Return type

Optional[Mapping[str, str]]

cluster_name

(experimental) Name for the cluster.

Default
  • Automatically generated name

Stability

experimental

Return type

Optional[str]

core_dns_compute_type

(experimental) Controls the “eks.amazonaws.com/compute-type” annotation in the CoreDNS configuration on your cluster to determine which compute type to use for CoreDNS.

Default

CoreDnsComputeType.EC2 (for FargateCluster the default is FARGATE)

Stability

experimental

Return type

Optional[CoreDnsComputeType]

default_capacity

(experimental) 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.addAutoScalingGroupCapacity to add additional customized capacity. Set this to 0 is you wish to avoid the initial capacity allocation.

Default

2

Stability

experimental

Return type

Union[int, float, None]

default_capacity_instance

(experimental) The instance type to use for the default capacity.

This will only be taken into account if defaultCapacity is > 0.

Default

m5.large

Stability

experimental

Return type

Optional[InstanceType]

default_capacity_type

(experimental) The default capacity type for the cluster.

Default

NODEGROUP

Stability

experimental

Return type

Optional[DefaultCapacityType]

endpoint_access

(experimental) Configure access to the Kubernetes API server endpoint..

Default

EndpointAccess.PUBLIC_AND_PRIVATE

See

https://docs.aws.amazon.com/eks/latest/userguide/cluster-endpoint.html

Stability

experimental

Return type

Optional[EndpointAccess]

kubectl_environment

(experimental) Environment variables for the kubectl execution.

Only relevant for kubectl enabled clusters.

Default
  • No environment variables.

Stability

experimental

Return type

Optional[Mapping[str, str]]

kubectl_layer

(experimental) An AWS Lambda Layer which includes kubectl, Helm and the AWS CLI.

By default, the provider will use the layer included in the “aws-lambda-layer-kubectl” SAR application which is available in all commercial regions.

To deploy the layer locally, visit https://github.com/aws-samples/aws-lambda-layer-kubectl/blob/master/cdk/README.md for instructions on how to prepare the .zip file and then define it in your app as follows:

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
layer = lambda_.LayerVersion(self, "kubectl-layer",
    code=lambda_.Code.from_asset(f"{__dirname}/layer.zip")
)
compatible_runtimes =
Default
  • the layer provided by the aws-lambda-layer-kubectl SAR app.

See

https://github.com/aws-samples/aws-lambda-layer-kubectl

Stability

experimental

Return type

Optional[ILayerVersion]

kubectl_memory

(experimental) Amount of memory to allocate to the provider’s lambda function.

Default

Size.gibibytes(1)

Stability

experimental

Return type

Optional[Size]

masters_role

(experimental) An IAM role that will be added to the system:masters Kubernetes RBAC group.

Default

  • a role that assumable by anyone with permissions in the same

account will automatically be defined

See

https://kubernetes.io/docs/reference/access-authn-authz/rbac/#default-roles-and-role-bindings

Stability

experimental

Return type

Optional[IRole]

output_cluster_name

(experimental) Determines whether a CloudFormation output with the name of the cluster will be synthesized.

Default

false

Stability

experimental

Return type

Optional[bool]

output_config_command

(experimental) 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.

Default

true

Stability

experimental

Return type

Optional[bool]

output_masters_role_arn

(experimental) Determines whether a CloudFormation output with the ARN of the “masters” IAM role will be synthesized (if mastersRole is specified).

Default

false

Stability

experimental

Return type

Optional[bool]

place_cluster_handler_in_vpc

(experimental) If set to true, the cluster handler functions will be placed in the private subnets of the cluster vpc, subject to the vpcSubnets selection strategy.

Default

false

Stability

experimental

Return type

Optional[bool]

prune

(experimental) Indicates whether Kubernetes resources added through addManifest() can be automatically pruned.

When this is enabled (default), prune labels will be allocated and injected to each resource. These labels will then be used when issuing the kubectl apply operation with the --prune switch.

Default

true

Stability

experimental

Return type

Optional[bool]

role

(experimental) Role that provides permissions for the Kubernetes control plane to make calls to AWS API operations on your behalf.

Default
  • A role is automatically created for you

Stability

experimental

Return type

Optional[IRole]

secrets_encryption_key

(experimental) KMS secret for envelope encryption for Kubernetes secrets.

Default

  • By default, Kubernetes stores all secret object data within etcd and

all etcd volumes used by Amazon EKS are encrypted at the disk-level using AWS-Managed encryption keys.

Stability

experimental

Return type

Optional[IKey]

security_group

(experimental) Security Group to use for Control Plane ENIs.

Default
  • A security group is automatically created

Stability

experimental

Return type

Optional[ISecurityGroup]

version

(experimental) The Kubernetes version to run in the cluster.

Stability

experimental

Return type

KubernetesVersion

vpc

(experimental) The VPC in which to create the Cluster.

Default
  • a VPC with default configuration will be created and can be accessed through cluster.vpc.

Stability

experimental

Return type

Optional[IVpc]

vpc_subnets

(experimental) 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:

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
vpcSubnets: [
   { subnetType: ec2.SubnetType.Private }
]
Default
  • All public and private subnets

Stability

experimental

Return type

Optional[List[SubnetSelection]]