Skip to content

Commit

Permalink
feat(NSC): honor headless label
Browse files Browse the repository at this point in the history
Abide the service.kubernetes.io/headless label as defined by the
upstream standard.

Resolves the failing e2e test:
should implement service.kubernetes.io/headless
  • Loading branch information
aauren committed Jan 5, 2024
1 parent 8afdee8 commit d757f49
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/controllers/proxy/network_services_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const (

// kubernetes standard labels / annotations
svcProxyNameLabel = "service.kubernetes.io/service-proxy-name"
svcHeadlessLabel = "service.kubernetes.io/headless"

// All IPSET names need to be less than 31 characters in order for the Kernel to accept them. Keep in mind that the
// actual formulation for this may be inet6:<setNameBase> depending on ip family, plus when we change ipsets we use
Expand Down Expand Up @@ -904,6 +905,15 @@ func (nsc *NetworkServicesController) buildServicesInfo() serviceInfoMap {
continue
}

// We handle headless service labels differently from a "None" or blank ClusterIP because ClusterIP is
// guaranteed to be immuteable whereas labels can be added / removed
_, err = getLabelFromMap(svcHeadlessLabel, svc.Labels)
if err == nil {
klog.V(2).Infof("Skipping service name:%s namespace:%s due to headless label being set", svc.Name,
svc.Namespace)
continue
}

for _, port := range svc.Spec.Ports {
svcInfo := serviceInfo{
clusterIP: net.ParseIP(svc.Spec.ClusterIP),
Expand Down

0 comments on commit d757f49

Please sign in to comment.