Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubectl error: the object has been modified; please apply your changes to the latest version and try again

I am getting below error while trying to apply patch :

core@dgoutam22-1-coreos-5760 ~ $ kubectl apply -f ads-central-configuration.yaml Warning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl apply Error from server (Conflict): error when applying patch: {"data":{"default":"{\"dedicated_redis_cluster\": {\"nodes\": [{\"host\": \"192.168.1.94\", \"port\": 6379}]}}"},"metadata":{"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"v1\",\"data\":{\"default\":\"{\\\"dedicated_redis_cluster\\\": {\\\"nodes\\\": [{\\\"host\\\": \\\"192.168.1.94\\\", \\\"port\\\": 6379}]}}\"},\"kind\":\"ConfigMap\",\"metadata\":{\"annotations\":{},\"creationTimestamp\":\"2018-06-27T07:19:13Z\",\"labels\":{\"acp-app\":\"acp-discovery-service\",\"version\":\"1\"},\"name\":\"ads-central-configuration\",\"namespace\":\"acp-system\",\"resourceVersion\":\"1109832\",\"selfLink\":\"/api/v1/namespaces/acp-system/configmaps/ads-central-configuration\",\"uid\":\"64901676-79da-11e8-bd65-fa163eaa7a28\"}}\n"},"creationTimestamp":"2018-06-27T07:19:13Z","resourceVersion":"1109832","uid":"64901676-79da-11e8-bd65-fa163eaa7a28"}} to: &{0xc4200bb380 0xc420356230 acp-system ads-central-configuration ads-central-configuration.yaml 0xc42000c970 4434 false} **for: "ads-central-configuration.yaml": Operation cannot be fulfilled on configmaps "ads-central-configuration": the object has been modified; please apply your changes to the latest version and try again** core@dgoutam22-1-coreos-5760 ~ $  
like image 616
Goutam Avatar asked Jul 12 '18 04:07

Goutam


2 Answers

It seems likely that your yaml configurations were copy pasted from what was generated, and thus contains fields such as creationTimestamp (and resourceVersion, selfLink, and uid), which don't belong in a declarative configuration file.

Go through your yaml and clean it up. Remove things that are instance specific. Your final yaml should be simple enough that you can easily understand it.

like image 177
Roman Avatar answered Oct 01 '22 02:10

Roman


Remove these lines from the file:

  creationTimestamp:      resourceVersion:     selfLink:      uid:    

Then try to apply again.

like image 36
doublespaces Avatar answered Oct 01 '22 03:10

doublespaces