<p>I keep getting the below error inconsistently on one of my services' endpoint object. : &quot;Failed to update endpoint default/myservice: Operation cannot be fulfilled on endpoints &quot;myservice&quot;: the object has been modified; please apply your changes to the latest version and try again&quot;. I am sure I am not editing the endpoint object manually because all my Kubernetes objects are deployed through helm3 charts. But it keeps giving the same error. It goes away if I delete and recreate the service. Please help/give any leads as to what could be the issue.
Below is my service.yml object from the cluster:</p>
<pre><code>kind: Service
apiVersion: v1
metadata:
name: myservice
namespace: default
selfLink: /api/v1/namespaces/default/services/myservice
uid: 4af68af5-4082-4ffb-b11b-641d16b28f31
resourceVersion: '1315842'
creationTimestamp: '2020-08-13T11:00:53Z'
labels:
app: myservice
app.kubernetes.io/managed-by: Helm
chart: myservice-1.0.0
heritage: Helm
release: vanilla
annotations:
meta.helm.sh/release-name: vanilla
meta.helm.sh/release-namespace: default
spec:
ports:
- name: http
protocol: TCP
port: 5000
targetPort: 5000
selector:
app: myservice
clusterIP: 10.0.225.85
type: ClusterIP
sessionAffinity: None
status:
loadBalancer: {}
</code></pre>

<p>It's <a href="https://stackoverflow.com/questions/57957516/kubernetes-failed-to-update-endpoints-warning">common behavior</a> and might happen when you try to deploy resources by copy-pasting manifests including <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#metadata" rel="nofollow noreferrer"><code>metadata</code> fields</a> like <code>creationTimeStamp</code>, <code>resourceVersion</code>, <code>selfLink</code> etc.</p>
<p><a href="https://kubernetes.io/docs/reference/using-api/api-concepts/#generated-values" rel="nofollow noreferrer">Those fields</a> are generated before the object is persisted.  It appears when you attempt to update the resource that has been already updated and the version has changed so it refuses to update it. The solution is to check your yamls and apply must-have objects without specifying fields populated by the system.</p>
