func (kd *KubeDNS) addDNSUsingEndpoints(e *v1.Endpoints) error { svc, err := kd.getServiceFromEndpoints(e) if err != nil { return err } if svc == nil || v1.IsServiceIPSet(svc) { // No headless service found corresponding to endpoints object. return nil } return kd.generateRecordsForHeadlessService(e, svc) }
func (kd *KubeDNS) removeService(obj interface{}) { if s, ok := assertIsService(obj); ok { subCachePath := append(kd.domainPath, serviceSubdomain, s.Namespace, s.Name) kd.cacheLock.Lock() defer kd.cacheLock.Unlock() success := kd.cache.DeletePath(subCachePath...) glog.V(2).Infof("removeService %v at path %v. Success: %v", s.Name, subCachePath, success) // ExternalName services have no IP if v1.IsServiceIPSet(s) { delete(kd.reverseRecordMap, s.Spec.ClusterIP) delete(kd.clusterIPServiceMap, s.Spec.ClusterIP) } } }
func (kd *KubeDNS) newService(obj interface{}) { if service, ok := assertIsService(obj); ok { glog.V(2).Infof("New service: %v", service.Name) glog.V(4).Infof("Service details: %v", service) // ExternalName services are a special kind that return CNAME records if service.Spec.Type == v1.ServiceTypeExternalName { kd.newExternalNameService(service) return } // if ClusterIP is not set, a DNS entry should not be created if !v1.IsServiceIPSet(service) { kd.newHeadlessService(service) return } if len(service.Spec.Ports) == 0 { glog.Warningf("Service with no ports, this should not have happened: %v", service) } kd.newPortalService(service) } }