KubernetesPatch

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

Bases: 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 tree node.

Static Methods

classmethod is_construct(x)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters:

x (Any) – Any object.

Return type:

bool

Returns:

true if x is an object created from a class which extends Construct.