Documentation ¶
Index ¶
- Constants
- Variables
- type Backend
- type EventType
- type Granularity
- type Mesh
- type Node
- type NodeBackend
- type NodeEvent
- type Peer
- type PeerBackend
- type PeerEvent
- type Topology
- func (t *Topology) AsPeer() *wireguard.Peer
- func (t *Topology) Conf() *wireguard.Conf
- func (t *Topology) Dot() (string, error)
- func (t *Topology) PeerConf(name string) *wireguard.Conf
- func (t *Topology) PeerRoutes(name string, kiloIface int, additionalAllowedIPs []net.IPNet) ([]*netlink.Route, []*netlink.Rule)
- func (t *Topology) Routes(kiloIfaceName string, kiloIface, privIface, tunlIface int, local bool, ...) ([]*netlink.Route, []*netlink.Rule)
- func (t *Topology) Rules(cni, iptablesForwardRule bool) iptables.RuleSet
Constants ¶
const ( // DefaultKiloInterface is the default interface created and used by Kilo. DefaultKiloInterface = "kilo0" // DefaultKiloPort is the default UDP port Kilo uses. DefaultKiloPort = 51820 // DefaultCNIPath is the default path to the CNI config file. DefaultCNIPath = "/etc/cni/net.d/10-kilo.conflist" )
Variables ¶
var DefaultKiloSubnet = &net.IPNet{IP: []byte{10, 4, 0, 0}, Mask: []byte{255, 255, 0, 0}}
DefaultKiloSubnet is the default CIDR for Kilo.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface { Nodes() NodeBackend Peers() PeerBackend }
Backend can create clients for all of the primitive types that Kilo deals with, namely: * nodes; and * peers.
type EventType ¶
type EventType string
EventType describes what kind of an action an event represents.
type Granularity ¶
type Granularity string
Granularity represents the abstraction level at which the network should be meshed.
const ( // LogicalGranularity indicates that the network should create // a mesh between logical locations, e.g. data-centers, but not between // all nodes within a single location. LogicalGranularity Granularity = "location" // FullGranularity indicates that the network should create // a mesh between every node. FullGranularity Granularity = "full" // AutoGranularity can be used with kgctl to obtain // the granularity automatically. AutoGranularity Granularity = "auto" )
type Mesh ¶
type Mesh struct { Backend // contains filtered or unexported fields }
Mesh is able to create Kilo network meshes.
func New ¶
func New(backend Backend, enc encapsulation.Encapsulator, granularity Granularity, hostname string, port int, subnet *net.IPNet, local, cni bool, cniPath, iface string, cleanup bool, cleanUpIface bool, createIface bool, mtu uint, resyncPeriod time.Duration, prioritisePrivateAddr, iptablesForwardRule bool, serviceCIDRs []*net.IPNet, logger log.Logger, registerer prometheus.Registerer) (*Mesh, error)
New returns a new Mesh instance.
type Node ¶
type Node struct { Endpoint *wireguard.Endpoint Key wgtypes.Key NoInternalIP bool InternalIP *net.IPNet // LastSeen is a Unix time for the last time // the node confirmed it was live. LastSeen int64 // Leader is a suggestion to Kilo that // the node wants to lead its segment. Leader bool Location string Name string PersistentKeepalive time.Duration Subnet *net.IPNet WireGuardIP *net.IPNet // DiscoveredEndpoints cannot be DNS endpoints, only net.UDPAddr. DiscoveredEndpoints map[string]*net.UDPAddr AllowedLocationIPs []net.IPNet Granularity Granularity }
Node represents a node in the network.
type NodeBackend ¶
type NodeBackend interface { CleanUp(context.Context, string) error Get(string) (*Node, error) Init(context.Context) error List() ([]*Node, error) Set(context.Context, string, *Node) error Watch() <-chan *NodeEvent }
NodeBackend can get nodes by name, init itself, list the nodes that should be meshed, set Kilo properties for a node, clean up any changes applied to the backend, and watch for changes to nodes.
type PeerBackend ¶
type PeerBackend interface { CleanUp(context.Context, string) error Get(string) (*Peer, error) Init(context.Context) error List() ([]*Peer, error) Set(context.Context, string, *Peer) error Watch() <-chan *PeerEvent }
PeerBackend can get peers by name, init itself, list the peers that should be in the mesh, set fields for a peer, clean up any changes applied to the backend, and watch for changes to peers.
type Topology ¶
type Topology struct {
// contains filtered or unexported fields
}
Topology represents the logical structure of the overlay network.
func NewTopology ¶
func NewTopology(nodes map[string]*Node, peers map[string]*Peer, granularity Granularity, hostname string, port int, key wgtypes.Key, subnet *net.IPNet, serviceCIDRs []*net.IPNet, persistentKeepalive time.Duration, logger log.Logger) (*Topology, error)
NewTopology creates a new Topology struct from a given set of nodes and peers.
func (*Topology) AsPeer ¶
AsPeer generates the WireGuard peer configuration for the local location of the given Topology. This configuration can be used to configure this location as a peer of another WireGuard interface.
func (*Topology) PeerConf ¶
PeerConf generates a WireGuard configuration file for a given peer in a Topology.
func (*Topology) PeerRoutes ¶
func (t *Topology) PeerRoutes(name string, kiloIface int, additionalAllowedIPs []net.IPNet) ([]*netlink.Route, []*netlink.Rule)
PeerRoutes generates a slice of routes and rules for a given peer in the Topology.