retain healthCheckNodePort for service when updating
@@ -46,6 +46,17 @@ func RetainClusterFields(targetKind string, desiredObj, clusterObj, fedObj *unst
}
func retainServiceFields(desiredObj, clusterObj *unstructured.Unstructured) error {
+ // healthCheckNodePort is allocated by APIServer and unchangeable, so it should be retained while updating
+ healthCheckNodePort, ok, err := unstructured.NestedInt64(clusterObj.Object, "spec", "healthCheckNodePort")
+ if err != nil {
+ return errors.Wrap(err, "Error retrieving healthCheckNodePort from service")
+ }
+ if ok && healthCheckNodePort > 0 {
+ if err = unstructured.SetNestedField(desiredObj.Object, healthCheckNodePort, "spec", "healthCheckNodePort"); err != nil {
+ return errors.Wrap(err, "Error setting healthCheckNodePort for service")
+ }
+ }
+
// ClusterIP and NodePort are allocated to Service by cluster, so retain the same if any while updating
// Retain clusterip
