code: func (c *Controller) CreateOrUpdateMasterServiceIfNeeded(serviceName string, serviceIP net.IP, servicePorts []corev1.ServicePort, serviceType corev1.ServiceType, reconcile bool) error {
  	if s, err := c.ServiceClient.Services(metav1.NamespaceDefault).Get(serviceName, metav1.GetOptions{}); err == nil {
  		// The service already exists.
  		if reconcile {
  			if svc, updated := reconcilers.GetMasterServiceUpdateIfNeeded(s, servicePorts, serviceType); updated {
  				klog.Warningf("Resetting master service %q to %#v", serviceName, svc)
  				_, err := c.ServiceClient.Services(metav1.NamespaceDefault).Update(svc)
  				return err
  			}
  		}
  		return nil
  	}
  	svc := &corev1.Service{
  		ObjectMeta: metav1.ObjectMeta{
  			Name:      serviceName,
  			Namespace: metav1.NamespaceDefault,
  			Labels:    map[string]string{"provider": "kubernetes", "component": "apiserver"},
  		},
  		Spec: corev1.ServiceSpec{
  			Ports: servicePorts,
  			// maintained by this code, not by the pod selector
  			Selector:        nil,
  			ClusterIP:       serviceIP.String(),
  			SessionAffinity: corev1.ServiceAffinityNone,
  			Type:            serviceType,
  		},
  	}
  
  	_, err := c.ServiceClient.Services(metav1.NamespaceDefault).Create(svc)
  	if errors.IsAlreadyExists(err) {
  		return c.CreateOrUpdateMasterServiceIfNeeded(serviceName, serviceIP, servicePorts, serviceType, reconcile)
  	}
  	return err
  }
docs: // CreateMasterServiceIfNeeded will create the specified service if it
  // doesn't already exist.