Use a separate data source
@@ -119,8 +119,8 @@ func (r *ReconcilePerconaXtraDBCluster) updatePod(sfs api.StatefulApp, podSpec *
}
func (r *ReconcilePerconaXtraDBCluster) updateService(svc *corev1.Service, podSpec *api.PodSpec) error {
- currentService := svc
- err := r.client.Get(context.TODO(), types.NamespacedName{Name: currentService.Name, Namespace: currentService.Namespace}, currentService)
+ currentService := &corev1.Service{}
+ err := r.client.Get(context.TODO(), types.NamespacedName{Name: svc.Name, Namespace: svc.Namespace}, currentService)
if err != nil {
return fmt.Errorf("failed to get sate: %v", err)
@@ -136,7 +136,7 @@ func (r *ReconcilePerconaXtraDBCluster) updateService(svc *corev1.Service, podSp
},
}
currentService.Spec.Type = *podSpec.ServiceType
- default:
+ case corev1.ServiceTypeLoadBalancer:
currentService.Spec.Type = *podSpec.ServiceType
}
}
