mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-10-29 17:51:03 +01:00
chore(source/node): added resouce labels for nodes (#5509)
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
This commit is contained in:
parent
3e0c509f1d
commit
28cac12dbe
@ -1460,6 +1460,11 @@ func testIngressEndpoints(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
validateEndpoints(t, res, ti.expected)
|
validateEndpoints(t, res, ti.expected)
|
||||||
|
|
||||||
|
// TODO; when all resources have the resource label, we could add this check to the validateEndpoints function.
|
||||||
|
for _, ep := range res {
|
||||||
|
require.Contains(t, ep.Labels, endpoint.ResourceLabelKey)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -102,7 +102,7 @@ func (ns *nodeSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, erro
|
|||||||
|
|
||||||
// create endpoints for all nodes
|
// create endpoints for all nodes
|
||||||
for _, node := range nodes {
|
for _, node := range nodes {
|
||||||
// Check controller annotation to see if we are responsible.
|
// Check the controller annotation to see if we are responsible.
|
||||||
if controller, ok := node.Annotations[controllerAnnotationKey]; ok && controller != controllerAnnotationValue {
|
if controller, ok := node.Annotations[controllerAnnotationKey]; ok && controller != controllerAnnotationValue {
|
||||||
log.Debugf("Skipping node %s because controller value does not match, found: %s, required: %s",
|
log.Debugf("Skipping node %s because controller value does not match, found: %s, required: %s",
|
||||||
node.Name, controller, controllerAnnotationValue)
|
node.Name, controller, controllerAnnotationValue)
|
||||||
@ -149,6 +149,8 @@ func (ns *nodeSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, erro
|
|||||||
|
|
||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
ep := endpoint.NewEndpointWithTTL(dns, suitableType(addr), ttl)
|
ep := endpoint.NewEndpointWithTTL(dns, suitableType(addr), ttl)
|
||||||
|
ep.WithLabel(endpoint.ResourceLabelKey, fmt.Sprintf("node/%s", node.Name))
|
||||||
|
|
||||||
log.Debugf("adding endpoint %s target %s", ep, addr)
|
log.Debugf("adding endpoint %s target %s", ep, addr)
|
||||||
key := endpoint.EndpointKey{
|
key := endpoint.EndpointKey{
|
||||||
DNSName: ep.DNSName,
|
DNSName: ep.DNSName,
|
||||||
|
|||||||
@ -573,6 +573,11 @@ func testNodeEndpointsWithIPv6(t *testing.T) {
|
|||||||
|
|
||||||
// Validate returned endpoints against desired endpoints.
|
// Validate returned endpoints against desired endpoints.
|
||||||
validateEndpoints(t, endpoints, tc.expected)
|
validateEndpoints(t, endpoints, tc.expected)
|
||||||
|
|
||||||
|
// TODO; when all resources have the resource label, we could add this check to the validateEndpoints function.
|
||||||
|
for _, ep := range endpoints {
|
||||||
|
require.Contains(t, ep.Labels, endpoint.ResourceLabelKey)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -605,9 +610,8 @@ func TestResourceLabelIsSetForEachNodeEndpoint(t *testing.T) {
|
|||||||
got, err := client.Endpoints(t.Context())
|
got, err := client.Endpoints(t.Context())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
for _, ep := range got {
|
for _, ep := range got {
|
||||||
// TODO: node source should always set the resource label key. currently not supported by the node source.
|
assert.NotEmpty(t, ep.Labels, "Labels should not be empty for endpoint %s", ep.DNSName)
|
||||||
assert.Empty(t, ep.Labels, "Labels should not be empty for endpoint %s", ep.DNSName)
|
assert.Contains(t, ep.Labels, endpoint.ResourceLabelKey)
|
||||||
assert.NotContains(t, ep.Labels, endpoint.ResourceLabelKey)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user