Class: AWSCDK::EKSv2::KubernetesManifestProps

Inherits:
KubernetesManifestOptions
  • Object
show all
Defined in:
ek_sv2/kubernetes_manifest_props.rb

Overview

Properties for KubernetesManifest.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ingress_alb: nil, ingress_alb_scheme: nil, prune: nil, removal_policy: nil, skip_validation: nil, cluster:, manifest:, overwrite: nil) ⇒ KubernetesManifestProps

Returns a new instance of KubernetesManifestProps.

Parameters:

  • ingress_alb (Boolean, nil) (defaults to: nil)

    Automatically detect Ingress resources in the manifest and annotate them so they are picked up by an ALB Ingress Controller.

  • ingress_alb_scheme (AWSCDK::EKSv2::ALBScheme, nil) (defaults to: nil)

    Specify the ALB scheme that should be applied to Ingress resources.

  • prune (Boolean, nil) (defaults to: nil)

    When a resource is removed from a Kubernetes manifest, it no longer appears in the manifest, and there is no way to know that this resource needs to be deleted.

  • removal_policy (AWSCDK::RemovalPolicy, nil) (defaults to: nil)

    The removal policy applied to the custom resource that manages the Kubernetes manifest.

  • skip_validation (Boolean, nil) (defaults to: nil)

    A flag to signify if the manifest validation should be skipped.

  • cluster (AWSCDK::EKSv2::ICluster)

    The EKS cluster to apply this manifest to.

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

    The manifest to apply.

  • overwrite (Boolean, nil) (defaults to: nil)

    Overwrite any existing resources.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'ek_sv2/kubernetes_manifest_props.rb', line 15

def initialize(ingress_alb: nil, ingress_alb_scheme: nil, prune: nil, removal_policy: nil, skip_validation: nil, cluster:, manifest:, overwrite: nil)
  @ingress_alb = ingress_alb
  Jsii::Type.check_type(@ingress_alb, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "ingressAlb") unless @ingress_alb.nil?
  @ingress_alb_scheme = ingress_alb_scheme
  Jsii::Type.check_type(@ingress_alb_scheme, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWtzX3YyLkFsYlNjaGVtZSJ9")), "ingressAlbScheme") unless @ingress_alb_scheme.nil?
  @prune = prune
  Jsii::Type.check_type(@prune, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "prune") unless @prune.nil?
  @removal_policy = removal_policy
  Jsii::Type.check_type(@removal_policy, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5SZW1vdmFsUG9saWN5In0=")), "removalPolicy") unless @removal_policy.nil?
  @skip_validation = skip_validation
  Jsii::Type.check_type(@skip_validation, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "skipValidation") unless @skip_validation.nil?
  @cluster = cluster
  Jsii::Type.check_type(@cluster, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWtzX3YyLklDbHVzdGVyIn0=")), "cluster")
  @manifest = manifest
  Jsii::Type.check_type(@manifest, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImNvbGxlY3Rpb24iOnsiZWxlbWVudHR5cGUiOnsicHJpbWl0aXZlIjoiYW55In0sImtpbmQiOiJtYXAifX0sImtpbmQiOiJhcnJheSJ9fQ==")), "manifest")
  @overwrite = overwrite
  Jsii::Type.check_type(@overwrite, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "overwrite") unless @overwrite.nil?
end

Instance Attribute Details

#clusterAWSCDK::EKSv2::ICluster (readonly)

The EKS cluster to apply this manifest to.

[disable-awslint:ref-via-interface]



88
89
90
# File 'ek_sv2/kubernetes_manifest_props.rb', line 88

def cluster
  @cluster
end

#ingress_albBoolean? (readonly)

Note:

Default: false

Automatically detect Ingress resources in the manifest and annotate them so they are picked up by an ALB Ingress Controller.

Returns:

  • (Boolean, nil)


38
39
40
# File 'ek_sv2/kubernetes_manifest_props.rb', line 38

def ingress_alb
  @ingress_alb
end

#ingress_alb_schemeAWSCDK::EKSv2::ALBScheme? (readonly)

Note:

Default: AlbScheme.INTERNAL

Specify the ALB scheme that should be applied to Ingress resources.

Only applicable if ingress_alb is set to true.

Returns:



45
46
47
# File 'ek_sv2/kubernetes_manifest_props.rb', line 45

def ingress_alb_scheme
  @ingress_alb_scheme
end

#manifestArray<Hash{String => Object}> (readonly)

The manifest to apply.

Consists of any number of child resources.

When the resources are created/updated, this manifest will be applied to the cluster through kubectl apply and when the resources or the stack is deleted, the resources in the manifest will be deleted through kubectl delete.

Examples:

[
    {
        api_version: "v1",
        kind: "Pod",
        metadata: {name: "mypod"},
        spec: {
            containers: [{name: "hello", image: "paulbouwer/hello-kubernetes:1.5", ports: [{container_port: 8080}]}],
        },
    },
]

Returns:

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


109
110
111
# File 'ek_sv2/kubernetes_manifest_props.rb', line 109

def manifest
  @manifest
end

#overwriteBoolean? (readonly)

Note:

Default: false

Overwrite any existing resources.

If this is set, we will use kubectl apply instead of kubectl create when the resource is created. Otherwise, if there is already a resource in the cluster with the same name, the operation will fail.

Returns:

  • (Boolean, nil)


118
119
120
# File 'ek_sv2/kubernetes_manifest_props.rb', line 118

def overwrite
  @overwrite
end

#pruneBoolean? (readonly)

Note:

Default: - based on the prune option of the cluster, which is true unless otherwise specified.

When a resource is removed from a Kubernetes manifest, it no longer appears in the manifest, and there is no way to know that this resource needs to be deleted.

To address this, kubectl apply has a --prune option which will query the cluster for all resources with a specific label and will remove all the labeld resources that are not part of the applied manifest. If this option is disabled and a resource is removed, it will become "orphaned" and will not be deleted from the cluster.

When this option is enabled (default), the construct will inject a label to all Kubernetes resources included in this manifest which will be used to prune resources when the manifest changes via kubectl apply --prune.

The label name will be aws.cdk.eks/prune-<ADDR> where <ADDR> is the 42-char unique address of this construct in the construct tree. Value is empty.



65
66
67
# File 'ek_sv2/kubernetes_manifest_props.rb', line 65

def prune
  @prune
end

#removal_policyAWSCDK::RemovalPolicy? (readonly)

Note:

Default: RemovalPolicy.DESTROY

The removal policy applied to the custom resource that manages the Kubernetes manifest.

The removal policy controls what happens to the resource if it stops being managed by CloudFormation. This can happen in one of three situations:

  • The resource is removed from the template, so CloudFormation stops managing it
  • A change to the resource is made that requires it to be replaced, so CloudFormation stops managing it
  • The stack is deleted, so CloudFormation stops managing all resources in it

Returns:



77
78
79
# File 'ek_sv2/kubernetes_manifest_props.rb', line 77

def removal_policy
  @removal_policy
end

#skip_validationBoolean? (readonly)

Note:

Default: false

A flag to signify if the manifest validation should be skipped.

Returns:

  • (Boolean, nil)


82
83
84
# File 'ek_sv2/kubernetes_manifest_props.rb', line 82

def skip_validation
  @skip_validation
end

Class Method Details

.jsii_propertiesObject



120
121
122
123
124
125
126
127
128
129
130
131
# File 'ek_sv2/kubernetes_manifest_props.rb', line 120

def self.jsii_properties
  {
    :ingress_alb => "ingressAlb",
    :ingress_alb_scheme => "ingressAlbScheme",
    :prune => "prune",
    :removal_policy => "removalPolicy",
    :skip_validation => "skipValidation",
    :cluster => "cluster",
    :manifest => "manifest",
    :overwrite => "overwrite",
  }
end

Instance Method Details

#to_jsiiObject



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'ek_sv2/kubernetes_manifest_props.rb', line 133

def to_jsii
  result = {}
  result.merge!(super)
  result.merge!({
    "ingressAlb" => @ingress_alb,
    "ingressAlbScheme" => @ingress_alb_scheme,
    "prune" => @prune,
    "removalPolicy" => @removal_policy,
    "skipValidation" => @skip_validation,
    "cluster" => @cluster,
    "manifest" => @manifest,
    "overwrite" => @overwrite,
  })
  result.compact
end