Patch a Kubernetes resource with targeted updates.
Unlike kubectl.Apply which requires the full resource specification, kubectl.Patch allows targeted updates to specific fields. Supports three patch strategies: Strategic Merge (default), JSON Merge, and JSON Patch.
type: "io.kestra.plugin.kubernetes.kubectl.Patch"Examples
Patch pod resource limits and wait for it to become ready.
id: patch_pod_with_wait
namespace: company.team
tasks:
- id: patch
type: io.kestra.plugin.kubernetes.kubectl.Patch
namespace: production
resourceType: pod
resourceName: my-pod
waitUntilReady: PT5M
patch: |
{
"spec": {
"containers": [
{
"name": "app",
"resources": {
"limits": {"memory": "512Mi", "cpu": "500m"},
"requests": {"memory": "256Mi", "cpu": "250m"}
}
}
]
}
}
Patch a deployment to update container resources using strategic merge (default).
id: patch_deployment_resources
namespace: company.team
tasks:
- id: patch
type: io.kestra.plugin.kubernetes.kubectl.Patch
namespace: production
resourceType: deployment
resourceName: my-api
apiGroup: apps
patch: |
{
"spec": {
"template": {
"spec": {
"containers": [
{
"name": "api",
"resources": {
"limits": {"memory": "2Gi", "cpu": "1000m"},
"requests": {"memory": "1Gi", "cpu": "500m"}
}
}
]
}
}
}
}
Scale a deployment using JSON Patch operations.
id: scale_deployment
namespace: company.team
tasks:
- id: scale
type: io.kestra.plugin.kubernetes.kubectl.Patch
namespace: production
resourceType: deployment
resourceName: my-api
apiGroup: apps
patchStrategy: JSON_PATCH
patch: |
[
{"op": "replace", "path": "/spec/replicas", "value": 5}
]
Remove an annotation using JSON Merge Patch.
id: remove_annotation
namespace: company.team
tasks:
- id: patch
type: io.kestra.plugin.kubernetes.kubectl.Patch
namespace: production
resourceType: deployment
resourceName: my-api
apiGroup: apps
patchStrategy: JSON_MERGE
patch: |
{
"metadata": {
"annotations": {
"deprecated-annotation": null
}
}
}
Patch a custom resource.
id: patch_custom_resource
namespace: company.team
tasks:
- id: patch
type: io.kestra.plugin.kubernetes.kubectl.Patch
namespace: production
resourceType: shirts
resourceName: my-shirt
apiGroup: stable.example.com
apiVersion: v1
patch: |
{
"spec": {
"color": "blue",
"size": "L"
}
}
Conditionally update replicas using JSON Patch test operation.
id: conditional_scale
namespace: company.team
tasks:
- id: scale
type: io.kestra.plugin.kubernetes.kubectl.Patch
namespace: production
resourceType: deployment
resourceName: my-api
apiGroup: apps
patchStrategy: JSON_PATCH
patch: |
[
{"op": "test", "path": "/spec/replicas", "value": 3},
{"op": "replace", "path": "/spec/replicas", "value": 10}
]
Properties
namespace *Requiredstring
The Kubernetes namespace
patch *Requiredstring
The patch content
The format depends on the patchStrategy. For STRATEGIC_MERGE and JSON_MERGE, provide a JSON object with the fields to update. For JSON_PATCH, provide a JSON array of operations with 'op', 'path', and 'value' fields.
resourceName *Requiredstring
The name of the Kubernetes resource to patch
resourceType *Requiredstring
The Kubernetes resource type (e.g., deployment, statefulset, pod)
Note: Currently only namespaced resources are supported. Cluster-scoped resources (e.g., ClusterRole, Node) are not supported.
apiGroup string
The Kubernetes resource apiGroup
Required for custom resources. For core resources (pods, services, etc.), leave empty.
apiVersion string
The Kubernetes resource API version
The version part of the API (e.g., 'v1', 'v1beta1'). Default is 'v1'. Note: This is just the version, not the full group/version. Use apiGroup for the group part.
connection Non-dynamicConnection
The connection parameters to the Kubernetes cluster
If no connection is defined, we try to load the connection from the current context in the following order:
- System properties
- Environment variables
- Kube config file
- Service account token and a mounted CA certificate.
You can pass a full configuration with all options if needed.
fileSidecar Non-dynamicSideCar
{
"image": "busybox"
}The configuration of the file sidecar container that handles the download and upload of files
inputFiles object
The files to create on the local filesystem – it can be a map or a JSON object.
The files will be available inside the kestra/working-dir directory of the container. You can use the special variable {{workingDir}} in your command to refer to it.
outputFiles array
The files from the container filesystem to send to Kestra's internal storage
Only files created inside the kestra/working-dir directory of the container can be retrieved.
Must be a list of glob expressions relative to the current working directory, some examples: my-dir/**, my-dir/*/** or my-dir/my-file.txt..
patchStrategy string
STRATEGIC_MERGESTRATEGIC_MERGEJSON_MERGEJSON_PATCHThe patch strategy to use
STRATEGIC_MERGE (default): Kubernetes strategic merge patch, most user-friendly. Understands K8s resource structure and intelligently merges lists by merge keys. JSON_MERGE: Simple merge with null-deletion semantics (RFC 7386). JSON_PATCH: Precision operations with add/remove/replace/test (RFC 6902).
waitRunning string
PT1HdurationThe maximum duration to wait for the job completion
waitUntilReady string
PT0SdurationThe maximum duration to wait until the patched resource becomes ready
When set to a positive duration, waits for the resource to report Ready=True in its status conditions. Set to PT0S (zero) to skip waiting. Supports Pods, StatefulSets, and custom resources that use the Ready condition. Note: Deployments are not supported as they use the Available condition instead of Ready.
waitUntilRunning string
PT10MdurationThe maximum duration to wait until the job and the pod is created
This timeout is the maximum time that Kubernetes scheduler will take to
- schedule the job
- pull the pod image
- and start the pod.
Outputs
metadata Metadata
The resource metadata after patching
status ResourceStatus
The resource status after patching
Contains the current state of the resource including conditions, replicas, phase, etc. Useful for validation and conditional logic in workflows.
Definitions
io.kestra.plugin.kubernetes.models.Connection
apiVersion string
v1The API version
caCertData string
CA certificate as data
caCertFile string
CA certificate as file path
clientCertData string
Client certificate as data
clientCertFile string
Client certificate as a file path
clientKeyAlgo string
RSAClient key encryption algorithm
default is RSA
clientKeyData string
Client key as data
clientKeyFile string
Client key as a file path
clientKeyPassphrase string
Client key passphrase
disableHostnameVerification booleanstring
Disable hostname verification
keyStoreFile string
Key store file
keyStorePassphrase string
Key store passphrase
masterUrl string
https://kubernetes.default.svcThe URL to the Kubernetes API
namespace string
The namespace used
oauthToken string
Oauth token
oauthTokenProvider OAuthTokenProvider
Oauth token provider
password string
Password
trustCerts booleanstring
Trust all certificates
trustStoreFile string
Truststore file
trustStorePassphrase string
Truststore passphrase
username string
Username
io.fabric8.kubernetes.api.model.FieldsV1
io.kestra.plugin.kubernetes.models.Metadata
annotations object
List of all annotations of the resource
clusterName string
Name of the current cluster
creationTimestamp string
date-timeCreation datetime
deletionGracePeriodSeconds integer
Deletetion grace period in seconds
deletionTimestamp string
date-timeDeletion datetime
finalizers array
List of finalizers
generateName string
Generate name of the resource
generation integer
Generation
labels object
List of labels
name string
Name of the resource
namespace string
Namespace of the resource
resourceVersion string
Resource version
selfLink string
Direct link to the API of this resource
uid string
Generated UUID of this resource
io.fabric8.kubernetes.api.model.ManagedFieldsEntry
apiVersion string
fieldsType string
fieldsV1 FieldsV1
manager string
operation string
subresource string
time string
io.kestra.plugin.kubernetes.models.SideCar
image string
busyboxThe image used for the file sidecar container
resources object
The resource requirements applied to the file sidecar container
io.kestra.plugin.kubernetes.models.ResourceStatus
status object
The status of the Kubernetes resource
Contains the current state of the resource as a generic map structure