Documentation
¶
Index ¶
- Constants
- Variables
- func CNIConfigFile(dir string, nw Networker) string
- func Driver(t string) func() Networker
- func GetNodeAddr(nodename string, network string) (net.IP, error)
- func IPReachableFrom(peerIP net.IP) (net.IP, *net.IPNet, error)
- func IncIP(ip net.IP)
- func IncIPN(ip net.IP, n int)
- func IsDisabled(t Networker) bool
- func IsSameNetwork(localIP, peerIP net.IP) (bool, error)
- func IsValid(t Networker) bool
- func List(noder Noder) []string
- func MACFromIP4(ip net.IP) (net.HardwareAddr, error)
- func Setup(n *object.Node) error
- type By
- type CNIer
- type Networker
- type Noder
- type Route
- type Routes
- type Setuper
- type Status
- type StatusList
- type T
- func (t *T) AllowEmptyNetwork() bool
- func (t *T) Config() *xconfig.T
- func (t *T) FilterIPs(ips clusterip.L) clusterip.L
- func (t *T) GetBool(s string) bool
- func (t *T) GetInt(s string) int
- func (t *T) GetString(s string) string
- func (t *T) GetStrings(s string) []string
- func (t *T) GetSubnetAs(nodename string) string
- func (t *T) IPNet() (*net.IPNet, error)
- func (t *T) IPsPerNode() (int, error)
- func (t *T) IsIP6() bool
- func (t *T) IsImplicit() bool
- func (t *T) Kops() keyop.L
- func (t *T) Log() *plog.Logger
- func (t *T) Name() string
- func (t *T) NeedCommit() bool
- func (t *T) Network() string
- func (t *T) NodeSubnet(nodename string) (*net.IPNet, error)
- func (t *T) NodeSubnetIP(nodename string) (net.IP, error)
- func (t *T) Nodes() ([]string, error)
- func (t *T) Set(option, value string) error
- func (t *T) SetAllowEmptyNetwork(v bool)
- func (t *T) SetDriver(name string)
- func (t *T) SetImplicit(v bool)
- func (t *T) SetName(name string)
- func (t *T) SetNeedCommit(v bool)
- func (t *T) SetNetwork(s string)
- func (t *T) SetNoder(noder Noder)
- func (t *T) Tables() []string
- func (t *T) Type() string
- type Usage
Constants ¶
const (
// CNIVersion is the version we write in the generated CNI network configuration files
CNIVersion = "0.3.0"
)
Variables ¶
var (
ErrInvalidType = errors.New("invalid network type")
)
Functions ¶
func CNIConfigFile ¶
func IsDisabled ¶
IsDisabled returns true if the network keyword value is "none"
func MACFromIP4 ¶
func MACFromIP4(ip net.IP) (net.HardwareAddr, error)
MACFromIP4 returns a mac address using a 0a:58 prefix followed by the bridge ipv4 address converted to hexa (same algorithm used in k8s).
When the device with the lowest mac is removed from the bridge or when a new device with the lowest mac is added to the bridge, all containers can experience tcp hangs while the arp table resynchronizes.
Setting a mac address to the bridge explicitly avoids these mac address changes.
Types ¶
type Networker ¶
type Networker interface {
// SetDriver sets the driver name, which is obtained from the
// "type" keyword in the network configuration.
SetDriver(string)
// SetName sets the network name. See Name().
SetName(string)
// SetImplicit sets isImplicit. See IsImplicit().
SetImplicit(bool)
// SetNetwork sets the network CIDR. Normally read from the
// merged cluster configuration.
SetNetwork(string)
// SetNeedCommit can be called by drivers to signal network
// configuration changes are staged and // need to be written
// to file.
SetNeedCommit(bool)
// SetNoder stores the Noder
SetNoder(Noder)
// IsImplicit returns true if the network is a builtin with
// no override section in the configuration.
IsImplicit() bool
// IsIP6 returns true if the network is a CIDR representation
// of a IPv6 network.
IsIP6() bool
// Name returns the name of the network. Which is the part
// after the dash in the configuration section name.
Name() string
// Kops returns the list of cluster config changes queued by the
// driver upon Setup.
Kops() keyop.L
// Network returns the CIDR representation of the network.
Network() string
// IPNet returns the result of ParseCIDR() on the Network()
// CIDR string, without the net.IP
IPNet() (*net.IPNet, error)
// NeedCommit return true if the network configuration cache
// has staged changes. This can be used by Networks() users to
// do one commit per action instead of one per network.
NeedCommit() bool
// Type return the driver name.
Type() string
FilterIPs(clusterip.L) clusterip.L
AllowEmptyNetwork() bool
// Config is a wrapper for the noder MergedConfig
Config() *xconfig.T
// Log returns a zerolog Logger configured to add the network
// name to log entries.
Log() *plog.Logger
// Nodes is a wrapper for the noder Nodes, which returns the
// list of cluster nodes to make the network available on.
Nodes() ([]string, error)
NodeSubnet(nodename string) (*net.IPNet, error)
NodeSubnetIP(nodename string) (net.IP, error)
}
func NewFromNoder ¶
type Route ¶
type Status ¶
type StatusList ¶
type StatusList []Status
func NewStatusList ¶
func NewStatusList() StatusList
func ShowNetworks ¶
func ShowNetworks(noder Noder, ips clusterip.L) StatusList
func ShowNetworksByName ¶
func ShowNetworksByName(noder Noder, name string, ips clusterip.L) StatusList
func (StatusList) Add ¶
func (t StatusList) Add(p Networker, ips clusterip.L) StatusList
func (StatusList) Len ¶
func (t StatusList) Len() int
func (StatusList) Less ¶
func (t StatusList) Less(i, j int) bool
func (StatusList) Swap ¶
func (t StatusList) Swap(i, j int)
type T ¶
type T struct {
// contains filtered or unexported fields
}
func (*T) AllowEmptyNetwork ¶
AllowEmptyNetwork returns true if the driver supports empty "network" keyword value. For one, the loopback driver does support that.
func (*T) GetStrings ¶
func (*T) GetSubnetAs ¶
func (*T) IPsPerNode ¶
func (*T) IsImplicit ¶
func (*T) NeedCommit ¶
func (*T) NodeSubnet ¶
NodeSubnet returns the network subnet assigned to a cluster node, as a *net.IPNet. This subnet is usually found in the network configuration, as a subnet@<nodename> option. If not found there, allocate and write one.
The subnet allocator uses ips_per_node to compute a netmask (narrower than the network mask). The subnet first ip is computed using the position of the node in the cluster nodes list.
Example: With
cluster.nodes = n1 n2 n3 net1.network = 10.0.0.0/24 net1.ips_per_node = 64
=>
subnet@n1 = 10.0.0.0/26 subnet@n2 = 10.0.0.64/26 subnet@n3 = 10.0.0.128/26