Include selector in service reconciliation

- detect changes in the Kubernetes service selectors and ports
- preserve the immutable fields when updating the ClusterIP services
This commit is contained in:
stefanprodan
2019-06-18 17:57:00 +03:00
parent 806b233d58
commit f25023ed1b
+6 -3
View File
@@ -128,10 +128,13 @@ func (c *KubernetesRouter) reconcileService(canary *flaggerv1.Canary, name strin
}
if svc != nil {
if diff := cmp.Diff(svcSpec.Ports, svc.Spec.Ports); diff != "" {
portsDiff := cmp.Diff(svcSpec.Ports, svc.Spec.Ports)
selectorsDiff := cmp.Diff(svcSpec.Selector, svc.Spec.Selector)
if portsDiff != "" || selectorsDiff != "" {
svcClone := svc.DeepCopy()
svcClone.Spec = svcSpec
svcClone.Spec.ClusterIP = svc.Spec.ClusterIP
svcClone.Spec.Ports = svcSpec.Ports
svcClone.Spec.Selector = svcSpec.Selector
_, err = c.kubeClient.CoreV1().Services(canary.Namespace).Update(svcClone)
if err != nil {
return fmt.Errorf("service %s update error %v", name, err)