mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-06 01:26:59 +02:00
source node: Skip unschedulable nodes
This commit is contained in:
parent
b336c524d0
commit
326ee0be69
@ -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)
|
||||
|
||||
```
|
||||
|
@ -102,6 +102,11 @@ func (ns *nodeSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, erro
|
||||
continue
|
||||
}
|
||||
|
||||
if node.Spec.Unschedulable {
|
||||
log.Debugf("Skipping node %s because it is unschedulable", node.Name)
|
||||
continue
|
||||
}
|
||||
|
||||
log.Debugf("creating endpoint for node %s", node.Name)
|
||||
|
||||
ttl := getTTLFromAnnotations(node.Annotations, fmt.Sprintf("node/%s", node.Name))
|
||||
|
@ -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,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user