Conflict (409)
KubernetesWARNINGCriticalAPI InteractionHIGH confidence

Conflict updating a resource

Production Risk

Occasional conflicts are normal. Persistent conflicts may indicate a 'fight' between two controllers over a resource, which can lead to instability.

What this means

An attempt to update or delete a resource failed because the version of the resource you are modifying is outdated. This is a mechanism to prevent you from overwriting changes made by another user or controller.

Why it happens
  1. 1You read a resource, another process updated it, and then you tried to update the original version you read
  2. 2Running `kubectl apply` on a resource that has been modified by a controller since the last apply
  3. 3Two controllers or users attempting to modify the same resource at the same time
How to reproduce

Running `kubectl apply` or `kubectl edit` fails with a conflict error.

trigger — this will error
trigger — this will error
kubectl apply -f my-deployment.yaml

expected output

Error from server (Conflict): error when applying patch:
...
Operation: "replace" for field "spec" failed: conflict: Please apply your changes to the latest version and try again

Fix 1

Fetch the latest version and re-apply

WHEN An update fails due to a conflict during manual changes

Fetch the latest version and re-apply
kubectl get deployment my-deployment -o yaml > my-deployment.yaml

Why this works

Get the latest version of the resource from the API server and save it. Then, merge your intended changes into this new file and re-apply it.

Fix 2

Force the apply (with caution)

WHEN You are certain your changes should overwrite the server's state

Force the apply (with caution)
kubectl apply -f my-deployment.yaml --force

Why this works

The force flag deletes the resource and then recreates it with your new definition. This is a destructive action that can cause downtime for services.

What not to do

Repeatedly try the same command without updating the resource version

It will continue to fail with a conflict error every time. The client must resolve the conflict by working with the latest resource version.

Sources
Official documentation ↗

k8s.io/apimachinery/pkg/api/errors/errors.go

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All Kubernetes errors