megaease / easemesh

A service mesh implementation for connecting, control, and observe services in spring-cloud.
https://megaease.com/easemesh
Apache License 2.0
508 stars 61 forks source link

Install will meet resource invalid problem when there are existed resources #73

Closed xxx7xxxx closed 3 years ago

xxx7xxxx commented 3 years ago

Backgroud

DeployXXX[1] will meet problems when update existed resources, it is a problem when use PUT method in kubernete APIs:

Error message example 1

customresourcedefinitions.apiextensions.k8s.io is invalid: metadata.resourceVersion: Invalid value: 0x0: must be specified for an update.

Error message example 2:

install mesh infrastructure error: invoke install func: deploy mesh control panel resource: deploy easemesh controlpanel inner service failed: Service "easemesh-controlplane-hs" is invalid: metadata.resourceVersion: Invalid value: "": must be specified for an update.

Same problems from the community:

Proposal

  1. Get the last resouceVersion to put in update spec, but it has a race condition.
  2. Set annotation kubectl.kubernetes.io/last-applied-configuration then update (kubectl way).
  3. Delete existed one and PUT brand new resource.

    Method 3 seems to be the best choice: simple and clean, won't change along with kubernetes implicit stuff. We could add a flag --replace to do it, by default we will output errors when there are existed resources.

Reference

[1] https://github.com/megaease/easemesh/blob/main/emctl/cmd/client/command/meshinstall/base/k8sutils.go

zhao-kun commented 3 years ago

I prefer to choosing solution No.2. The consequence of solution No.3 is equal to emctl reset and emctl install