func ClusterIPIsNone(clusterIP string) bool {
	return strings.ToLower(clusterIP) == "none"
}
ClusterIPIsNone checks to see whether the ClusterIP contains "None" which would indicate that it is headless
package utils
import (
	"strings"
	v1core "k8s.io/api/core/v1"
	"k8s.io/client-go/tools/cache"
)
const (
	IPInIPHeaderLength = 20
)
func ServiceForEndpoints(ci *cache.Indexer, ep *v1core.Endpoints) (interface{}, bool, error) {
	key, err := cache.MetaNamespaceKeyFunc(ep)
	if err != nil {
		return nil, false, err
	}
	item, exists, err := (*ci).GetByKey(key)
	if err != nil {
		return nil, false, err
	}
	if !exists {
		return nil, false, nil
	}
	return item, true, nil
}
func ServiceIsHeadless(obj interface{}) bool {
	if svc, _ := obj.(*v1core.Service); svc != nil {
		if svc.Spec.Type == v1core.ServiceTypeClusterIP {
			if ClusterIPIsNone(svc.Spec.ClusterIP) && containsOnlyNone(svc.Spec.ClusterIPs) {
				return true
			}
		}
	}
	return false
}