[root@VM-0-14-kylin yaml]# kubectl apply -f config/aep-aep-nacos.yaml
Error from server (Conflict): error when applying patch:
{"metadata":{"creationTimestamp":"2024-06-04T08:40:22Z","managedFields":[{"apiVersion":"v1","fieldsType":"FieldsV1","fieldsV1":{"f:data":{".":{},"f:application.properties":{}},"f:metadata":{"f:annotations":{".":{},"f:kubectl.kubernetes.io/last-applied-configuration":{}}}},"manager":"kubectl","operation":"Update","time":"2024-06-04T08:40:22Z"}],"resourceVersion":"2180343","selfLink":"/api/v1/namespaces/default/configmaps/aep-aep-nacos","uid":"bca99974-8773-4b67-837e-286fa6b1deea"}}
to:
Resource: "/v1, Resource=configmaps", GroupVersionKind: "/v1, Kind=ConfigMap"
Name: "aep-aep-nacos", Namespace: "default"
for: "config/aep-aep-nacos.yaml": Operation cannot be fulfilled on configmaps "aep-aep-nacos": the object has been modified; please apply your changes to the latest version and try again
重点摘要:the object has been modified; please apply your changes to the latest version and try again
意思是“/root/yaml/config/aep-aep-nacos.yaml”: 配置映射 “aep-aep-nacos” 无法完成操作:对象已修改;请将更改应用到最新版本,然后重试
解决办法:执行kubectl get configmap aep-aep-nacos -o yaml生成新的配置文件,然后再次执行
报错分析:
更新冲突:错误信息提示您的更新操作与当前 ConfigMap 的最新版本存在冲突。这可能是因为在您获取 ConfigMap 之后,有其他用户或进程对其进行了修改。解决方法是先获取最新版本的 ConfigMap,然后再应用您的更改。 重新获取最新版本:通过运行 kubectl get configmap aep-aep-nacos -o yaml 命令获取最新的 ConfigMap 配置,并确保您的配置文件(例如 config/aep-aep-nacos.yaml)中反映了最新的状态。 并发操作问题:在多用户或多进程环境中,同时对同一 ConfigMap 进行更新可能会导致冲突。确保在操作时避免并发修改,或者确保所有修改都基于最新的配置。 |
然后再执行kubectl apply -f config/aep-aep-nacos.yaml
问题解决