Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add label for nodes to be ignored #3

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions swarm/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type SwarmNode struct {
Ip string
Hostname string
IsManager bool
Ignore bool
DnsNames []string
}

Expand Down Expand Up @@ -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),
})
}
Expand Down
Loading