func (r *ReconcileRethinkDBCluster) reconcileDriverService(cr *rethinkdbv1alpha1.RethinkDBCluster) error {
	found := &corev1.Service{}
	err := r.client.Get(context.TODO(), types.NamespacedName{Name: cr.Name, Namespace: cr.Namespace}, found)
	if err != nil && errors.IsNotFound(err) {
		log.Info("creating new service", "service", cr.Name)
		svc := newDriverService(cr)

		// Set RethinkDBCluster instance as the owner and controller
		if err = controllerutil.SetControllerReference(cr, svc, r.scheme); err != nil {
			return err
		}

		// Create the Service
		err = r.client.Create(context.TODO(), svc)
		if err != nil {
			return err
		}

		// Service created successfully, update status and return
		cr.Status.ServiceName = svc.Name
		return r.client.Status().Update(context.TODO(), cr)
	} else if err != nil {
		return err
	}

	log.Info("service exists", "service", found.Name)
	return nil
}
// reconcileDriverService ensures the driver Service is present.
reconcileDriverService ensures the driver Service is present.
// reconcileDriverService ensures the driver Service is present .
func (r *ReconcileRethinkDBCluster) reconcileDriverService(cr *rethinkdbv1alpha1.RethinkDBCluster) error {
	found := &corev1.Service{}
	err := r.client.Get(context.TODO(), types.NamespacedName{Name: cr.Name, Namespace: cr.Namespace}, found)
	if err != nil && errors.IsNotFound(err) {
		log.Info("creating new service", "service", cr.Name)
		svc := newDriverService(cr)
		if err = controllerutil.SetControllerReference(cr, svc, r.scheme); err != nil {
			return err
		}
		err = r.client.Create(context.TODO(), svc)
		if err != nil {
			return err
		}
		cr.Status.ServiceName = svc.Name
		return r.client.Status().Update(context.TODO(), cr)
	} else if err != nil {
		return err
	}
	log.Info("service exists", "service", found.Name)
	return nil
}
func ( r * ReconcileRethinkDBCluster ) reconcileDriverService ( cr * rethinkdbv1alpha1 . RethinkDBCluster ) error { found := & corev1 . Service { } err := r . client . Get ( context . TODO ( ) , types . NamespacedName { Name : cr . Name , Namespace : cr . Namespace } , found ) if err != nil && errors . IsNotFound ( err ) { log . Info ( " " , " " , cr . Name ) svc := newDriverService ( cr ) if err = controllerutil . SetControllerReference ( cr , svc , r . scheme ) ; err != nil { return err } err = r . client . Create ( context . TODO ( ) , svc ) if err != nil { return err } cr . Status . ServiceName = svc . Name return r . client . Status ( ) . Update ( context . TODO ( ) , cr ) } else if err != nil { return err } log . Info ( " " , " " , found . Name ) return nil }
reconcileDriverService ensures the driver Service is present.
reconcileDriverService ensures the driver Service is present .
// Set RethinkDBCluster instance as the owner and controller // Create the Service // Service created successfully, update status and return