diff --git a/docs/sources/nodes.md b/docs/sources/nodes.md index 0db1c99c7e..ca88b44f5a 100644 --- a/docs/sources/nodes.md +++ b/docs/sources/nodes.md @@ -7,6 +7,9 @@ The node source adds an `A` record per each node `externalIP` (if not found, any It also adds an `AAAA` record per each node IPv6 `internalIP`. The TTL of the records can be set with the `external-dns.alpha.kubernetes.io/ttl` node annotation. +Nodes marked as **Unschedulable** as per [core/v1/NodeSpec](https://pkg.go.dev/k8s.io/api@v0.31.1/core/v1#NodeSpec) are excluded. +This avoid exposing Unhealthy, NotReady or SchedulingDisabled (cordon) nodes. + ## Manifest (for cluster without RBAC enabled) ``` diff --git a/source/node_test.go b/source/node_test.go index 9ce4591dfb..bf047bae84 100644 --- a/source/node_test.go +++ b/source/node_test.go @@ -101,6 +101,7 @@ func testNodeSourceEndpoints(t *testing.T) { nodeAddresses []v1.NodeAddress labels map[string]string annotations map[string]string + unschedulable bool // default to false expected []*endpoint.Endpoint expectError bool }{ @@ -321,6 +322,13 @@ func testNodeSourceEndpoints(t *testing.T) { {RecordType: "A", DNSName: "node1", Targets: endpoint.Targets{"1.2.3.4"}, RecordTTL: endpoint.TTL(10)}, }, }, + { + title: "unschedulable node return nothing", + nodeName: "node1", + nodeAddresses: []v1.NodeAddress{{Type: v1.NodeExternalIP, Address: "1.2.3.4"}}, + unschedulable: true, + expected: []*endpoint.Endpoint{}, + }, } { tc := tc t.Run(tc.title, func(t *testing.T) { @@ -342,6 +350,9 @@ func testNodeSourceEndpoints(t *testing.T) { Labels: tc.labels, Annotations: tc.annotations, }, + Spec: v1.NodeSpec{ + Unschedulable: tc.unschedulable, + }, Status: v1.NodeStatus{ Addresses: tc.nodeAddresses, },