Documentation
¶
Overview ¶
Package mesh runs the controller side of private networking (§8): it allocates each node a WireGuard address and a container subnet (IPAM, §8.2) and sends every agent its view of the full mesh.
Index ¶
- Constants
- Variables
- func ConfigFor(self store.NodeNetwork, all []store.NodeNetwork, gen uint64) *agentv1.NetworkConfig
- func FirewallFor(self store.NodeNetwork, all []store.NodeNetwork, ...) *agentv1.Firewall
- func MeshAddr(i int) netip.Addr
- func Subnet(i int) netip.Prefix
- type Manager
- func (m *Manager) Changed(ctx context.Context)
- func (m *Manager) Hooks() agentgw.Hooks
- func (m *Manager) IsMember(nodeID string) bool
- func (m *Manager) List(ctx context.Context) ([]NodeView, error)
- func (m *Manager) NetworkReady(nodeID string) bool
- func (m *Manager) NodeConfig(ctx context.Context, nodeID string) (*agentv1.NetworkConfig, error)
- func (m *Manager) Run(ctx context.Context)
- type NodeView
- type Options
- type PeerView
- type PublicIP
- type PublicPort
Constants ¶
const ( // ListenPort is the WireGuard UDP port on every node. ListenPort = 51820 // ControllerNode always gets mesh index 1 (10.90.0.1). ControllerNode = "ctl-0" // Cooldown keeps released indexes out of the pool. Cooldown = time.Hour // TopicUpdated carries a NodeView when a node's mesh state changes. TopicUpdated = "mesh.updated" )
const ConfirmTimeout = 60
ConfirmTimeout is how long an agent waits for the controller to confirm a firewall change before rolling it back (§8.3).
Variables ¶
var ( MeshCIDR = netip.MustParsePrefix("10.90.0.0/16") ContainerCIDR = netip.MustParsePrefix("10.91.0.0/16") ServiceCIDR = netip.MustParsePrefix("10.92.0.0/16") )
Address plan (§8).
Functions ¶
func ConfigFor ¶
func ConfigFor(self store.NodeNetwork, all []store.NodeNetwork, gen uint64) *agentv1.NetworkConfig
ConfigFor builds self's view: every other member with a key is a peer.
func FirewallFor ¶
func FirewallFor(self store.NodeNetwork, all []store.NodeNetwork, policies []store.FirewallPolicy, opts Options) *agentv1.Firewall
FirewallFor builds a node's host firewall: built-in rules plus every policy that targets it.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func (*Manager) Changed ¶
Changed re-sends every node its configuration (e.g. after a firewall policy change).
func (*Manager) NetworkReady ¶
NetworkReady reports whether tasks can be placed on the node: either it is not a mesh member (single-node development), or its network is applied.
func (*Manager) NodeConfig ¶
NodeConfig returns the configuration a node would get now (for the effective-rules view).
type NodeView ¶
type NodeView struct {
NodeID string `json:"nodeId"`
Name string `json:"name"`
Address string `json:"address"`
Subnet string `json:"subnet"`
Endpoint string `json:"endpoint"`
PublicKey string `json:"publicKey"`
Mode string `json:"mode"`
Generation uint64 `json:"generation"`
AppliedGen uint64 `json:"appliedGeneration"`
Error string `json:"error"`
FirewallPending bool `json:"firewallPending"`
Drift uint64 `json:"driftCorrections"`
Peers []PeerView `json:"peers"`
StatusUpdatedAt *time.Time `json:"statusUpdatedAt"`
}
NodeView is a node's mesh state for the API.
type Options ¶
type Options struct {
// ControllerPorts are opened to everyone on ctl-0 (HTTP, HTTPS, agent gateway).
ControllerPorts []string
// Firewall turns the host firewall on.
Firewall bool
// IsEdge reports edge nodes, which open HTTP and HTTPS (§8.5).
IsEdge func(nodeID string) bool
// PublicPorts are extra ports Traefik serves publicly on the
// controller and edge nodes (public databases, Phase 12e; public
// service ports, Phase 15c).
PublicPorts func() []PublicPort
}
Options configure the firewall rules the controller adds by itself.
type PeerView ¶
type PeerView struct {
NodeID string `json:"nodeId"`
Name string `json:"name"`
Endpoint string `json:"endpoint"`
LastHandshake *time.Time `json:"lastHandshake"`
RxBytes uint64 `json:"rxBytes"`
TxBytes uint64 `json:"txBytes"`
RTTMillis float64 `json:"rttMs"`
}
PeerView is one peer link as reported by an agent.