mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-11-29 00:40:59 +01:00
refactor: simplify assignment to Service target list
This commit is contained in:
parent
4ee8bae85c
commit
039f1a91fb
@ -498,16 +498,15 @@ func (sc *serviceSource) generateEndpoints(svc *v1.Service, hostname string, pro
|
|||||||
switch svc.Spec.Type {
|
switch svc.Spec.Type {
|
||||||
case v1.ServiceTypeLoadBalancer:
|
case v1.ServiceTypeLoadBalancer:
|
||||||
if useClusterIP {
|
if useClusterIP {
|
||||||
targets = append(targets, extractServiceIps(svc)...)
|
targets = extractServiceIps(svc)
|
||||||
} else {
|
} else {
|
||||||
targets = append(targets, extractLoadBalancerTargets(svc, sc.resolveLoadBalancerHostname)...)
|
targets = extractLoadBalancerTargets(svc, sc.resolveLoadBalancerHostname)
|
||||||
}
|
}
|
||||||
case v1.ServiceTypeClusterIP:
|
case v1.ServiceTypeClusterIP:
|
||||||
if sc.publishInternal {
|
|
||||||
targets = append(targets, extractServiceIps(svc)...)
|
|
||||||
}
|
|
||||||
if svc.Spec.ClusterIP == v1.ClusterIPNone {
|
if svc.Spec.ClusterIP == v1.ClusterIPNone {
|
||||||
endpoints = append(endpoints, sc.extractHeadlessEndpoints(svc, hostname, ttl)...)
|
endpoints = append(endpoints, sc.extractHeadlessEndpoints(svc, hostname, ttl)...)
|
||||||
|
} else if sc.publishInternal {
|
||||||
|
targets = extractServiceIps(svc)
|
||||||
}
|
}
|
||||||
case v1.ServiceTypeNodePort:
|
case v1.ServiceTypeNodePort:
|
||||||
// add the nodeTargets and extract an SRV endpoint
|
// add the nodeTargets and extract an SRV endpoint
|
||||||
@ -518,7 +517,7 @@ func (sc *serviceSource) generateEndpoints(svc *v1.Service, hostname string, pro
|
|||||||
}
|
}
|
||||||
endpoints = append(endpoints, sc.extractNodePortEndpoints(svc, hostname, ttl)...)
|
endpoints = append(endpoints, sc.extractNodePortEndpoints(svc, hostname, ttl)...)
|
||||||
case v1.ServiceTypeExternalName:
|
case v1.ServiceTypeExternalName:
|
||||||
targets = append(targets, extractServiceExternalName(svc)...)
|
targets = extractServiceExternalName(svc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user