Install will meet resource invalid problem when there are existed resources
xxx7xxxx opened this issue · 1 comments
xxx7xxxx commented
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:
- ManageIQ/kubeclient#403
- kubernetes/kubernetes#70674
- https://www.timcosta.io/kubernetes-service-invalid-clusterip-or-resourceversion/
Proposal
- Get the last
resouceVersion
to put in update spec, but it has a race condition. - Set annotation
kubectl.kubernetes.io/last-applied-configuration
then update (kubectl way). - 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
I prefer to choosing solution No.2. The consequence of solution No.3 is equal to emctl reset
and emctl install