func (r *ReconcileRethinkDBCluster) reconcileAdminService(cr *rethinkdbv1alpha1.RethinkDBCluster) error {
	found := &corev1.Service{}
	name := fmt.Sprintf("%s-%s", cr.ObjectMeta.Name, RethinkDBAdminKey)

	err := r.client.Get(context.TODO(), types.NamespacedName{Name: name, Namespace: cr.Namespace}, found)
	if err != nil && errors.IsNotFound(err) {
		if !cr.Spec.WebAdminEnabled {
			// Admin not enabled, do not create service
			return nil
		}

		log.Info("creating new service", "service", name)
		svc := newAdminService(cr)

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

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

	// Service exists, verify that it should...
	if !cr.Spec.WebAdminEnabled {
		log.Info("removing existing service", "service", name)
		return r.client.Delete(context.TODO(), found)
	}

	log.Info("service exists", "service", found.Name)
	return nil
}
// reconcileAdminService ensures the admin Service is created.
reconcileAdminService ensures the admin Service is created.
// reconcileAdminService ensures the admin Service is created .
func (r *ReconcileRethinkDBCluster) reconcileAdminService(cr *rethinkdbv1alpha1.RethinkDBCluster) error {
	found := &corev1.Service{}
	name := fmt.Sprintf("%s-%s", cr.ObjectMeta.Name, RethinkDBAdminKey)
	err := r.client.Get(context.TODO(), types.NamespacedName{Name: name, Namespace: cr.Namespace}, found)
	if err != nil && errors.IsNotFound(err) {
		if !cr.Spec.WebAdminEnabled {
			return nil
		}
		log.Info("creating new service", "service", name)
		svc := newAdminService(cr)
		if err = controllerutil.SetControllerReference(cr, svc, r.scheme); err != nil {
			return err
		}
		return r.client.Create(context.TODO(), svc)
	} else if err != nil {
		return err
	}
	if !cr.Spec.WebAdminEnabled {
		log.Info("removing existing service", "service", name)
		return r.client.Delete(context.TODO(), found)
	}
	log.Info("service exists", "service", found.Name)
	return nil
}
func ( r * ReconcileRethinkDBCluster ) reconcileAdminService ( cr * rethinkdbv1alpha1 . RethinkDBCluster ) error { found := & corev1 . Service { } name := fmt . Sprintf ( " " , cr . ObjectMeta . Name , RethinkDBAdminKey ) err := r . client . Get ( context . TODO ( ) , types . NamespacedName { Name : name , Namespace : cr . Namespace } , found ) if err != nil && errors . IsNotFound ( err ) { if ! cr . Spec . WebAdminEnabled { return nil } log . Info ( " " , " " , name ) svc := newAdminService ( cr ) if err = controllerutil . SetControllerReference ( cr , svc , r . scheme ) ; err != nil { return err } return r . client . Create ( context . TODO ( ) , svc ) } else if err != nil { return err } if ! cr . Spec . WebAdminEnabled { log . Info ( " " , " " , name ) return r . client . Delete ( context . TODO ( ) , found ) } log . Info ( " " , " " , found . Name ) return nil }
reconcileAdminService ensures the admin Service is created.
reconcileAdminService ensures the admin Service is created .
// Admin not enabled, do not create service // Set RethinkDBCluster instance as the owner and controller // Create the Service and return // Service exists, verify that it should...