mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-06 17:46:57 +02:00
Merge pull request #3938 from johngmyers/internal-service
Use ServiceIP for ClusterIP Services with internal-hostname annotation
This commit is contained in:
commit
9ad15cf76f
@ -25,7 +25,7 @@ The following table documents which sources support which annotations:
|
|||||||
| Traefik | | Yes | | Yes | Yes | Yes |
|
| Traefik | | Yes | | Yes | Yes | Yes |
|
||||||
|
|
||||||
[^1]: Unless the `--ignore-hostname-annotation` flag is specified.
|
[^1]: Unless the `--ignore-hostname-annotation` flag is specified.
|
||||||
[^2]: Only behaves differently than `hostname` for `Service`s of type `LoadBalancer`.
|
[^2]: Only behaves differently than `hostname` for `Service`s of type `ClusterIP` or `LoadBalancer`.
|
||||||
[^3]: Also supported on `Pods` referenced from a headless `Service`'s `Endpoints`.
|
[^3]: Also supported on `Pods` referenced from a headless `Service`'s `Endpoints`.
|
||||||
[^4]: The annotation should be on the `Gateway`
|
[^4]: The annotation should be on the `Gateway`
|
||||||
|
|
||||||
|
@ -75,7 +75,8 @@ or the `--publish-host-ip` flag was specified, uses the Pod's `status.hostIP` fi
|
|||||||
|
|
||||||
### ClusterIP (not headless)
|
### ClusterIP (not headless)
|
||||||
|
|
||||||
1. If the `--publish-internal-services` flag is specified, uses the `spec.ServiceIP`.
|
1. If the hostname came from an `external-dns.alpha.kubernetes.io/internal-hostname` annotation
|
||||||
|
or the `--publish-internal-services` flag was specified, uses the `spec.ServiceIP`.
|
||||||
|
|
||||||
2. Otherwise, does not create any targets.
|
2. Otherwise, does not create any targets.
|
||||||
|
|
||||||
|
@ -505,7 +505,7 @@ func (sc *serviceSource) generateEndpoints(svc *v1.Service, hostname string, pro
|
|||||||
case v1.ServiceTypeClusterIP:
|
case v1.ServiceTypeClusterIP:
|
||||||
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 {
|
} else if useClusterIP || sc.publishInternal {
|
||||||
targets = extractServiceIps(svc)
|
targets = extractServiceIps(svc)
|
||||||
}
|
}
|
||||||
case v1.ServiceTypeNodePort:
|
case v1.ServiceTypeNodePort:
|
||||||
|
@ -910,7 +910,25 @@ func testServiceSourceEndpoints(t *testing.T) {
|
|||||||
expected: []*endpoint.Endpoint{},
|
expected: []*endpoint.Endpoint{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "internal-host annotated services return an endpoint with Cluster IP",
|
title: "internal-host annotated and host annotated clusterip services return an endpoint with Cluster IP",
|
||||||
|
svcNamespace: "testing",
|
||||||
|
svcName: "foo",
|
||||||
|
svcType: v1.ServiceTypeClusterIP,
|
||||||
|
labels: map[string]string{},
|
||||||
|
annotations: map[string]string{
|
||||||
|
hostnameAnnotationKey: "foo.example.org.",
|
||||||
|
internalHostnameAnnotationKey: "foo.internal.example.org.",
|
||||||
|
},
|
||||||
|
clusterIP: "1.1.1.1",
|
||||||
|
externalIPs: []string{},
|
||||||
|
lbs: []string{"1.2.3.4"},
|
||||||
|
serviceTypesFilter: []string{},
|
||||||
|
expected: []*endpoint.Endpoint{
|
||||||
|
{DNSName: "foo.internal.example.org", RecordType: endpoint.RecordTypeA, Targets: endpoint.Targets{"1.1.1.1"}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "internal-host annotated loadbalancer services return an endpoint with Cluster IP",
|
||||||
svcNamespace: "testing",
|
svcNamespace: "testing",
|
||||||
svcName: "foo",
|
svcName: "foo",
|
||||||
svcType: v1.ServiceTypeLoadBalancer,
|
svcType: v1.ServiceTypeLoadBalancer,
|
||||||
@ -927,7 +945,7 @@ func testServiceSourceEndpoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "internal-host annotated and host annotated services return an endpoint with Cluster IP and an endpoint with lb IP",
|
title: "internal-host annotated and host annotated loadbalancer services return an endpoint with Cluster IP and an endpoint with lb IP",
|
||||||
svcNamespace: "testing",
|
svcNamespace: "testing",
|
||||||
svcName: "foo",
|
svcName: "foo",
|
||||||
svcType: v1.ServiceTypeLoadBalancer,
|
svcType: v1.ServiceTypeLoadBalancer,
|
||||||
|
Loading…
Reference in New Issue
Block a user