From a2a449fdd6b468c0646237e32e335b68e27fb9ed Mon Sep 17 00:00:00 2001 From: Egor Date: Mon, 5 Feb 2024 18:06:38 +0400 Subject: [PATCH] Add check for ignored nodes (#3) --- main.go | 2 +- swarm/client.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index bc74d07..125ff88 100644 --- a/main.go +++ b/main.go @@ -167,7 +167,7 @@ func answerForNodes(domain string) []dns.RR { } for _, node := range nodes { - if node.IsManager || returnWorkers { + if (node.IsManager || returnWorkers) && !node.Ignore { rr := new(dns.A) rr.Hdr = dns.RR_Header{Name: domain, Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: uint32(TTL)} rr.A = net.ParseIP(node.Ip) diff --git a/swarm/client.go b/swarm/client.go index ddfa6ae..09bb2cf 100644 --- a/swarm/client.go +++ b/swarm/client.go @@ -13,6 +13,7 @@ type SwarmNode struct { Ip string Hostname string IsManager bool + Ignore bool DnsNames []string } @@ -55,11 +56,14 @@ func (client swarmClient) ListActiveNodes() ([]SwarmNode, error) { ip = node.Status.Addr } + _, ignore := node.Spec.Annotations.Labels["swarmdns-ignore"] + nodes = append(nodes, SwarmNode{ Ip: ip, Hostname: getHostname(node), IsManager: node.ManagerStatus != nil, + Ignore: ignore, DnsNames: getDnsNames(node), }) }