mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2026-05-04 22:26:11 +02:00
respect controller annotation for node source
This commit is contained in:
parent
16194ca9cf
commit
4325d7368b
@ -107,6 +107,14 @@ func (ns *nodeSource) Endpoints() ([]*endpoint.Endpoint, error) {
|
||||
|
||||
// create endpoints for all nodes
|
||||
for _, node := range nodes {
|
||||
// Check controller annotation to see if we are responsible.
|
||||
controller, ok := node.Annotations[controllerAnnotationKey]
|
||||
if ok && controller != controllerAnnotationValue {
|
||||
log.Debugf("Skipping node %s because controller value does not match, found: %s, required: %s",
|
||||
node.Name, controller, controllerAnnotationValue)
|
||||
continue
|
||||
}
|
||||
|
||||
log.Debugf("creating endpoint for node %s", node.Name)
|
||||
|
||||
// create new endpoint with the information we already have
|
||||
|
||||
@ -207,6 +207,34 @@ func testNodeSourceEndpoints(t *testing.T) {
|
||||
[]*endpoint.Endpoint{},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"our controller type is dns-controller",
|
||||
"",
|
||||
"",
|
||||
"node1",
|
||||
[]v1.NodeAddress{{v1.NodeExternalIP, "1.2.3.4"}},
|
||||
map[string]string{},
|
||||
map[string]string{
|
||||
controllerAnnotationKey: controllerAnnotationValue,
|
||||
},
|
||||
[]*endpoint.Endpoint{
|
||||
{RecordType: "A", DNSName: "node1", Targets: endpoint.Targets{"1.2.3.4"}},
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"different controller types are ignored",
|
||||
"",
|
||||
"",
|
||||
"node1",
|
||||
[]v1.NodeAddress{{v1.NodeExternalIP, "1.2.3.4"}},
|
||||
map[string]string{},
|
||||
map[string]string{
|
||||
controllerAnnotationKey: "not-dns-controller",
|
||||
},
|
||||
[]*endpoint.Endpoint{},
|
||||
false,
|
||||
},
|
||||
} {
|
||||
t.Run(tc.title, func(t *testing.T) {
|
||||
// Create a Kubernetes testing client
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user