pkg/mesh,cmd: add WireGuard IP to Nodes

This allows admins or users to have some easy visibility into the
configuration of the Kilo cluster.
This commit is contained in:
Lucas Servén Marín
2019-05-10 02:05:57 +02:00
parent b04264ecc1
commit 4d9c203603
8 changed files with 84 additions and 57 deletions

View File

@@ -35,17 +35,22 @@ func runGraph(_ *cobra.Command, _ []string) error {
return fmt.Errorf("failed to list nodes: %v", err)
}
var hostname string
subnet := mesh.DefaultKiloSubnet
nodes := make(map[string]*mesh.Node)
for _, n := range ns {
if n.Ready() {
nodes[n.Name] = n
hostname = n.Name
}
if n.WireGuardIP != nil {
subnet = n.WireGuardIP
}
}
subnet.IP = subnet.IP.Mask(subnet.Mask)
if len(nodes) == 0 {
return fmt.Errorf("did not find any valid Kilo nodes in the cluster")
}
t, err := mesh.NewTopology(nodes, nil, opts.granularity, hostname, 0, []byte{}, opts.subnet)
t, err := mesh.NewTopology(nodes, nil, opts.granularity, hostname, 0, []byte{}, subnet)
if err != nil {
return fmt.Errorf("failed to create topology: %v", err)
}