Go-based network automation with YANG models, gRPC, Ansible, Terraform, and Kubernetes integration. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
48 lines
1.6 KiB
Go
48 lines
1.6 KiB
Go
package topology
|
|
|
|
// MeshTopology represents the current mesh state shared between
|
|
// the CNI plugin (reader) and DaemonSet (writer).
|
|
type MeshTopology struct {
|
|
// NodeID identifies this node in the mesh.
|
|
NodeID string `json:"node_id"`
|
|
|
|
// ClusterID identifies the cluster this node belongs to.
|
|
ClusterID string `json:"cluster_id"`
|
|
|
|
// Mode indicates the active modes: "overlay", "underlay", or "both".
|
|
Mode string `json:"mode"`
|
|
|
|
// Peers are the WireGuard mesh peers (overlay mode).
|
|
Peers []PeerInfo `json:"peers,omitempty"`
|
|
|
|
// OverlaySubnets are subnets reachable via WireGuard tunnels.
|
|
OverlaySubnets []SubnetRoute `json:"overlay_subnets,omitempty"`
|
|
|
|
// UnderlaySubnets are subnets reachable via VLAN bridges.
|
|
UnderlaySubnets []SubnetRoute `json:"underlay_subnets,omitempty"`
|
|
|
|
// WireGuard interface configuration (overlay).
|
|
WireGuard WireGuardConfig `json:"wireguard,omitempty"`
|
|
}
|
|
|
|
// PeerInfo describes a WireGuard mesh peer.
|
|
type PeerInfo struct {
|
|
PublicKey string `json:"public_key"`
|
|
Endpoint string `json:"endpoint"`
|
|
AllowedIPs []string `json:"allowed_ips"`
|
|
ClusterID string `json:"cluster_id,omitempty"`
|
|
}
|
|
|
|
// SubnetRoute maps a destination CIDR to an interface.
|
|
type SubnetRoute struct {
|
|
Dst string `json:"dst"` // e.g., "172.16.0.0/24"
|
|
Via string `json:"via"` // e.g., "vlan100" or "wg0"
|
|
Mode string `json:"mode"` // "overlay" or "underlay"
|
|
}
|
|
|
|
// WireGuardConfig holds the local node's WireGuard configuration.
|
|
type WireGuardConfig struct {
|
|
InterfaceName string `json:"interface_name"` // e.g., "wg0"
|
|
ListenPort int `json:"listen_port"`
|
|
PrivateKeyPath string `json:"private_key_path"`
|
|
}
|