Module: AWSCDK::EKS::ICluster

Includes:
AWSCDK::EC2::IConnectable, IResource, Interfaces::AWSEKS::IClusterRef
Included in:
Cluster
Defined in:
eks/i_cluster.rb

Overview

An EKS cluster.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.jsii_overridable_methodsObject



370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
# File 'eks/i_cluster.rb', line 370

def self.jsii_overridable_methods
  {
    :node => { kind: :property, name: "node", is_optional: false },
    :env => { kind: :property, name: "env", is_optional: false },
    :stack => { kind: :property, name: "stack", is_optional: false },
    :connections => { kind: :property, name: "connections", is_optional: false },
    :cluster_ref => { kind: :property, name: "clusterRef", is_optional: false },
    :cluster_arn => { kind: :property, name: "clusterArn", is_optional: false },
    :cluster_certificate_authority_data => { kind: :property, name: "clusterCertificateAuthorityData", is_optional: false },
    :cluster_encryption_config_key_arn => { kind: :property, name: "clusterEncryptionConfigKeyArn", is_optional: false },
    :cluster_endpoint => { kind: :property, name: "clusterEndpoint", is_optional: false },
    :cluster_name => { kind: :property, name: "clusterName", is_optional: false },
    :cluster_security_group => { kind: :property, name: "clusterSecurityGroup", is_optional: false },
    :cluster_security_group_id => { kind: :property, name: "clusterSecurityGroupId", is_optional: false },
    :open_id_connect_provider => { kind: :property, name: "openIdConnectProvider", is_optional: false },
    :prune => { kind: :property, name: "prune", is_optional: false },
    :vpc => { kind: :property, name: "vpc", is_optional: false },
    :authentication_mode => { kind: :property, name: "authenticationMode", is_optional: true },
    :awscli_layer => { kind: :property, name: "awscliLayer", is_optional: true },
    :cluster_handler_security_group => { kind: :property, name: "clusterHandlerSecurityGroup", is_optional: true },
    :eks_pod_identity_agent => { kind: :property, name: "eksPodIdentityAgent", is_optional: true },
    :ip_family => { kind: :property, name: "ipFamily", is_optional: true },
    :kubectl_environment => { kind: :property, name: "kubectlEnvironment", is_optional: true },
    :kubectl_lambda_role => { kind: :property, name: "kubectlLambdaRole", is_optional: true },
    :kubectl_layer => { kind: :property, name: "kubectlLayer", is_optional: true },
    :kubectl_memory => { kind: :property, name: "kubectlMemory", is_optional: true },
    :kubectl_private_subnets => { kind: :property, name: "kubectlPrivateSubnets", is_optional: true },
    :kubectl_provider => { kind: :property, name: "kubectlProvider", is_optional: true },
    :kubectl_role => { kind: :property, name: "kubectlRole", is_optional: true },
    :kubectl_security_group => { kind: :property, name: "kubectlSecurityGroup", is_optional: true },
    :on_event_layer => { kind: :property, name: "onEventLayer", is_optional: true },
    :with => { kind: :method, name: "with", is_optional: false },
    :apply_removal_policy => { kind: :method, name: "applyRemovalPolicy", is_optional: false },
    :add_cdk8s_chart => { kind: :method, name: "addCdk8sChart", is_optional: false },
    :add_helm_chart => { kind: :method, name: "addHelmChart", is_optional: false },
    :add_manifest => { kind: :method, name: "addManifest", is_optional: false },
    :add_service_account => { kind: :method, name: "addServiceAccount", is_optional: false },
    :connect_auto_scaling_group_capacity => { kind: :method, name: "connectAutoScalingGroupCapacity", is_optional: false },
  }
end

Instance Method Details

#add_cdk8s_chart(id, chart, options = nil) ⇒ AWSCDK::EKS::KubernetesManifest

Defines a CDK8s chart in this cluster.

Parameters:

Returns:



297
298
299
300
301
302
303
# File 'eks/i_cluster.rb', line 297

def add_cdk8s_chart(id, chart, options = nil)
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  Jsii::Type.check_type(chart, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "chart")
  options = options.is_a?(Hash) ? ::AWSCDK::EKS::KubernetesManifestOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWtzLkt1YmVybmV0ZXNNYW5pZmVzdE9wdGlvbnMifQ==")), "options") unless options.nil?
  jsii_call_method("addCdk8sChart", [id, chart, options])
end

#add_helm_chart(id, options) ⇒ AWSCDK::EKS::HelmChart

Defines a Helm chart in this cluster.

Parameters:

Returns:



310
311
312
313
314
315
# File 'eks/i_cluster.rb', line 310

def add_helm_chart(id, options)
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  options = options.is_a?(Hash) ? ::AWSCDK::EKS::HelmChartOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWtzLkhlbG1DaGFydE9wdGlvbnMifQ==")), "options")
  jsii_call_method("addHelmChart", [id, options])
end

#add_manifest(id, *manifest) ⇒ AWSCDK::EKS::KubernetesManifest

Defines a Kubernetes resource in this cluster.

The manifest will be applied/deleted using kubectl as needed.

Parameters:

  • id (String)

    logical id of this manifest.

  • manifest (Array<Hash{String => Object}>)

    a list of Kubernetes resource specifications.

Returns:



324
325
326
327
328
329
330
# File 'eks/i_cluster.rb', line 324

def add_manifest(id, *manifest)
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  manifest.each_with_index do |item, index|
    Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6ImFueSJ9LCJraW5kIjoibWFwIn19")), "manifest[#{index}]")
  end
  jsii_call_method("addManifest", [id, *manifest])
end

#add_service_account(id, options = nil) ⇒ AWSCDK::EKS::ServiceAccount

Creates a new service account with corresponding IAM Role (IRSA).

Parameters:

Returns:



337
338
339
340
341
342
# File 'eks/i_cluster.rb', line 337

def (id, options = nil)
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  options = options.is_a?(Hash) ? ::AWSCDK::EKS::ServiceAccountOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWtzLlNlcnZpY2VBY2NvdW50T3B0aW9ucyJ9")), "options") unless options.nil?
  jsii_call_method("addServiceAccount", [id, options])
end

#apply_removal_policy(policy) ⇒ void

This method returns an undefined value.

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

Parameters:



286
287
288
289
# File 'eks/i_cluster.rb', line 286

def apply_removal_policy(policy)
  Jsii::Type.check_type(policy, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5SZW1vdmFsUG9saWN5In0=")), "policy")
  jsii_call_method("applyRemovalPolicy", [policy])
end

#authentication_modeAWSCDK::EKS::AuthenticationMode?

Note:

Default: AuthenticationMode.CONFIG_MAP

The authentication mode for the cluster.



131
132
133
# File 'eks/i_cluster.rb', line 131

def authentication_mode()
  jsii_get_property("authenticationMode")
end

#awscli_layerAWSCDK::Lambda::ILayerVersion?

An AWS Lambda layer that contains the aws CLI.

If not defined, a default layer will be used containing the AWS CLI 1.x.



140
141
142
# File 'eks/i_cluster.rb', line 140

def awscli_layer()
  jsii_get_property("awscliLayer")
end

#cluster_arnString

The unique ARN assigned to the service by AWS in the form of arn:aws:eks:.

Returns:

  • (String)


56
57
58
# File 'eks/i_cluster.rb', line 56

def cluster_arn()
  jsii_get_property("clusterArn")
end

#cluster_certificate_authority_dataString

The certificate-authority-data for your cluster.

Returns:

  • (String)


63
64
65
# File 'eks/i_cluster.rb', line 63

def cluster_certificate_authority_data()
  jsii_get_property("clusterCertificateAuthorityData")
end

#cluster_encryption_config_key_arnString

Amazon Resource Name (ARN) or alias of the customer master key (CMK).

Returns:

  • (String)


70
71
72
# File 'eks/i_cluster.rb', line 70

def cluster_encryption_config_key_arn()
  jsii_get_property("clusterEncryptionConfigKeyArn")
end

#cluster_endpointString

The API Server endpoint URL.

Returns:

  • (String)


77
78
79
# File 'eks/i_cluster.rb', line 77

def cluster_endpoint()
  jsii_get_property("clusterEndpoint")
end

#cluster_handler_security_groupAWSCDK::EC2::ISecurityGroup?

Note:

Default: - No security group.

A security group to associate with the Cluster Handler's Lambdas.

The Cluster Handler's Lambdas are responsible for calling AWS's EKS API.

Requires place_cluster_handler_in_vpc to be set to true.

Returns:



152
153
154
# File 'eks/i_cluster.rb', line 152

def cluster_handler_security_group()
  jsii_get_property("clusterHandlerSecurityGroup")
end

#cluster_nameString

The physical name of the Cluster.

Returns:

  • (String)


84
85
86
# File 'eks/i_cluster.rb', line 84

def cluster_name()
  jsii_get_property("clusterName")
end

#cluster_refAWSCDK::Interfaces::AWSEKS::ClusterReference

A reference to a Cluster resource.



49
50
51
# File 'eks/i_cluster.rb', line 49

def cluster_ref()
  jsii_get_property("clusterRef")
end

#cluster_security_groupAWSCDK::EC2::ISecurityGroup

The cluster security group that was created by Amazon EKS for the cluster.



91
92
93
# File 'eks/i_cluster.rb', line 91

def cluster_security_group()
  jsii_get_property("clusterSecurityGroup")
end

#cluster_security_group_idString

The id of the cluster security group that was created by Amazon EKS for the cluster.

Returns:

  • (String)


98
99
100
# File 'eks/i_cluster.rb', line 98

def cluster_security_group_id()
  jsii_get_property("clusterSecurityGroupId")
end

#connect_auto_scaling_group_capacity(auto_scaling_group, options) ⇒ void

This method returns an undefined value.

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.

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 add_auto_scaling_group_capacity if possible.

Parameters:

See Also:



363
364
365
366
367
368
# File 'eks/i_cluster.rb', line 363

def connect_auto_scaling_group_capacity(auto_scaling_group, options)
  Jsii::Type.check_type(auto_scaling_group, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYXV0b3NjYWxpbmcuQXV0b1NjYWxpbmdHcm91cCJ9")), "autoScalingGroup")
  options = options.is_a?(Hash) ? ::AWSCDK::EKS::AutoScalingGroupOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWtzLkF1dG9TY2FsaW5nR3JvdXBPcHRpb25zIn0=")), "options")
  jsii_call_method("connectAutoScalingGroupCapacity", [auto_scaling_group, options])
end

#connectionsAWSCDK::EC2::Connections

The network connections associated with this resource.



42
43
44
# File 'eks/i_cluster.rb', line 42

def connections()
  jsii_get_property("connections")
end

#eks_pod_identity_agentAWSCDK::EKS::IAddon?

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.

This property returns the CfnAddon resource representing the EKS Pod Identity Agent addon. If the addon has not been created yet, it will be created and returned.

Returns:



168
169
170
# File 'eks/i_cluster.rb', line 168

def eks_pod_identity_agent()
  jsii_get_property("eksPodIdentityAgent")
end

#envAWSCDK::Interfaces::ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.

For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.



28
29
30
# File 'eks/i_cluster.rb', line 28

def env()
  jsii_get_property("env")
end

#ip_familyAWSCDK::EKS::IPFamily?

Note:

Default: - IpFamily.IP_V4

Specify which IP family is used to assign Kubernetes pod and service IP addresses.



177
178
179
# File 'eks/i_cluster.rb', line 177

def ip_family()
  jsii_get_property("ipFamily")
end

#kubectl_environmentHash{String => String}?

Custom environment variables when running kubectl against this cluster.

Returns:

  • (Hash{String => String}, nil)


184
185
186
# File 'eks/i_cluster.rb', line 184

def kubectl_environment()
  jsii_get_property("kubectlEnvironment")
end

#kubectl_lambda_roleAWSCDK::IAM::IRole?

An IAM role that can perform kubectl operations against this cluster.

The role should be mapped to the system:masters Kubernetes RBAC role.

This role is directly passed to the lambda handler that sends Kube Ctl commands to the cluster.

Returns:



195
196
197
# File 'eks/i_cluster.rb', line 195

def kubectl_lambda_role()
  jsii_get_property("kubectlLambdaRole")
end

#kubectl_layerAWSCDK::Lambda::ILayerVersion?

An AWS Lambda layer that includes kubectl and helm.



202
203
204
# File 'eks/i_cluster.rb', line 202

def kubectl_layer()
  jsii_get_property("kubectlLayer")
end

#kubectl_memoryAWSCDK::Size?

Amount of memory to allocate to the provider's lambda function.

Returns:



209
210
211
# File 'eks/i_cluster.rb', line 209

def kubectl_memory()
  jsii_get_property("kubectlMemory")
end

#kubectl_private_subnetsArray<AWSCDK::EC2::ISubnet>?

Subnets to host the kubectl compute resources.

If this is undefined, the k8s endpoint is expected to be accessible publicly.

Returns:



219
220
221
# File 'eks/i_cluster.rb', line 219

def kubectl_private_subnets()
  jsii_get_property("kubectlPrivateSubnets")
end

#kubectl_providerAWSCDK::EKS::IKubectlProvider?

Kubectl Provider for issuing kubectl commands against it.

If not defined, a default provider will be used



228
229
230
# File 'eks/i_cluster.rb', line 228

def kubectl_provider()
  jsii_get_property("kubectlProvider")
end

#kubectl_roleAWSCDK::IAM::IRole?

An IAM role that can perform kubectl operations against this cluster.

The role should be mapped to the system:masters Kubernetes RBAC role.

Returns:



237
238
239
# File 'eks/i_cluster.rb', line 237

def kubectl_role()
  jsii_get_property("kubectlRole")
end

#kubectl_security_groupAWSCDK::EC2::ISecurityGroup?

A security group to use for kubectl execution.

If this is undefined, the k8s endpoint is expected to be accessible publicly.

Returns:



247
248
249
# File 'eks/i_cluster.rb', line 247

def kubectl_security_group()
  jsii_get_property("kubectlSecurityGroup")
end

#nodeConstructs::Node

The tree node.

Returns:

  • (Constructs::Node)


13
14
15
# File 'eks/i_cluster.rb', line 13

def node()
  jsii_get_property("node")
end

#on_event_layerAWSCDK::Lambda::ILayerVersion?

An AWS Lambda layer that includes the NPM dependency proxy-agent.

If not defined, a default layer will be used.



256
257
258
# File 'eks/i_cluster.rb', line 256

def on_event_layer()
  jsii_get_property("onEventLayer")
end

#open_id_connect_providerAWSCDK::IAM::IOpenIdConnectProvider

The Open ID Connect Provider of the cluster used to configure Service Accounts.



105
106
107
# File 'eks/i_cluster.rb', line 105

def open_id_connect_provider()
  jsii_get_property("openIdConnectProvider")
end

#pruneBoolean

Indicates whether Kubernetes resources 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.

Returns:

  • (Boolean)


116
117
118
# File 'eks/i_cluster.rb', line 116

def prune()
  jsii_get_property("prune")
end

#stackAWSCDK::Stack

The stack in which this resource is defined.

Returns:



35
36
37
# File 'eks/i_cluster.rb', line 35

def stack()
  jsii_get_property("stack")
end

#vpcAWSCDK::EC2::IVPC

The VPC in which this Cluster was created.

Returns:



123
124
125
# File 'eks/i_cluster.rb', line 123

def vpc()
  jsii_get_property("vpc")
end

#with(*mixins) ⇒ Constructs::IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited.

Parameters:

  • mixins (Array<Constructs::IMixin>)

    The mixins to apply.

Returns:

  • (Constructs::IConstruct)

    This construct for chaining



267
268
269
270
271
272
# File 'eks/i_cluster.rb', line 267

def with(*mixins)
  mixins.each_with_index do |item, index|
    Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLklNaXhpbiJ9")), "mixins[#{index}]")
  end
  jsii_call_method("with", [*mixins])
end