class KubernetesPatch (construct)
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.EKSv2.KubernetesPatch |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awseksv2#KubernetesPatch |
Java | software.amazon.awscdk.services.eks_v2.KubernetesPatch |
Python | aws_cdk.aws_eks_v2.KubernetesPatch |
TypeScript (source) | aws-cdk-lib » aws_eks_v2 » KubernetesPatch |
Implements
IConstruct, IDependable
A CloudFormation resource which applies/restores a JSON patch into a Kubernetes resource.
See also: https://kubernetes.io/docs/tasks/run-application/update-api-object-kubectl-patch/
Example
declare const cluster: eks.Cluster;
new eks.KubernetesPatch(this, 'hello-kub-deployment-label', {
cluster,
resourceName: "deployment/hello-kubernetes",
applyPatch: { spec: { replicas: 5 } },
restorePatch: { spec: { replicas: 3 } },
})
Initializer
new KubernetesPatch(scope: Construct, id: string, props: KubernetesPatchProps)
Parameters
- scope
Construct - id
string - props
KubernetesPatch Props
Construct Props
| Name | Type | Description |
|---|---|---|
| apply | { [string]: any } | The JSON object to pass to kubectl patch when the resource is created/updated. |
| cluster | ICluster | The cluster to apply the patch to. |
| resource | string | The full name of the resource to patch (e.g. deployment/coredns). |
| restore | { [string]: any } | The JSON object to pass to kubectl patch when the resource is removed. |
| patch | Patch | The patch type to pass to kubectl patch. |
| removal | Removal | The removal policy applied to the custom resource that manages the Kubernetes patch. |
| resource | string | The kubernetes API namespace. |
applyPatch
Type:
{ [string]: any }
The JSON object to pass to kubectl patch when the resource is created/updated.
cluster
Type:
ICluster
The cluster to apply the patch to.
[disable-awslint:ref-via-interface]
resourceName
Type:
string
The full name of the resource to patch (e.g. deployment/coredns).
restorePatch
Type:
{ [string]: any }
The JSON object to pass to kubectl patch when the resource is removed.
patchType?
Type:
Patch
(optional, default: PatchType.STRATEGIC)
The patch type to pass to kubectl patch.
The default type used by kubectl patch is "strategic".
removalPolicy?
Type:
Removal
(optional, default: RemovalPolicy.DESTROY)
The removal policy applied to the custom resource that manages the Kubernetes patch.
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
resourceNamespace?
Type:
string
(optional, default: "default")
The kubernetes API namespace.
Properties
| Name | Type | Description |
|---|---|---|
| node | Node | The tree node. |
node
Type:
Node
The tree node.
Methods
| Name | Description |
|---|---|
| to | Returns a string representation of this construct. |
| with(...mixins) | Applies one or more mixins to this construct. |
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
with(...mixins)
public with(...mixins: IMixin[]): IConstruct
Parameters
- mixins
IMixin— The mixins to apply.
Returns
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.
Use multiple with() calls if subsequent mixins should apply to added
constructs.

.NET
Go
Java
Python
TypeScript (