KubernetesPatch

class aws_cdk.aws_eks.KubernetesPatch(scope, id, *, apply_patch, cluster, resource_name, restore_patch, patch_type=None, resource_namespace=None)

Bases: aws_cdk.core.Construct

A CloudFormation resource which applies/restores a JSON patch into a Kubernetes resource.

See

https://kubernetes.io/docs/tasks/run-application/update-api-object-kubectl-patch/

ExampleMetadata

infused

Example:

# cluster: eks.Cluster

eks.KubernetesPatch(self, "hello-kub-deployment-label",
    cluster=cluster,
    resource_name="deployment/hello-kubernetes",
    apply_patch={"spec": {"replicas": 5}},
    restore_patch={"spec": {"replicas": 3}}
)
Parameters
  • scope (Construct) –

  • id (str) –

  • apply_patch (Mapping[str, Any]) – The JSON object to pass to kubectl patch when the resource is created/updated.

  • cluster (ICluster) – The cluster to apply the patch to. [disable-awslint:ref-via-interface]

  • resource_name (str) – The full name of the resource to patch (e.g. deployment/coredns).

  • restore_patch (Mapping[str, Any]) – The JSON object to pass to kubectl patch when the resource is removed.

  • patch_type (Optional[PatchType]) – The patch type to pass to kubectl patch. The default type used by kubectl patch is “strategic”. Default: PatchType.STRATEGIC

  • resource_namespace (Optional[str]) – The kubernetes API namespace. Default: “default”

Methods

to_string()

Returns a string representation of this construct.

Return type

str

Attributes

node

The construct tree node associated with this construct.

Return type

ConstructNode

Static Methods

classmethod is_construct(x)

Return whether the given object is a Construct.

Parameters

x (Any) –

Return type

bool