node

package
v1.15.0-pre.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2023 License: Apache-2.0 Imports: 28 Imported by: 91

Documentation

Overview

Package node provides functionality related to the local and remote node addresses

Index

Constants

This section is empty.

Variables

View Source
var LocalNodeStoreCell = cell.Module(
	"local-node-store",
	"Provides LocalNodeStore for observing and updating local node info",

	cell.Provide(NewLocalNodeStore),
)

LocalNodeStoreCell provides the LocalNodeStore instance. The LocalNodeStore is the canonical owner of `types.Node` for the local node and provides a reactive API for observing and updating it.

Functions

func AutoComplete added in v0.15.7

func AutoComplete() error

AutoComplete completes the parts of addressing that can be auto derived

func GetCiliumEndpointNodeIP added in v0.15.7

func GetCiliumEndpointNodeIP() string

GetCiliumEndpointNodeIP is the node IP that will be referenced by CiliumEndpoints with endpoints running on this node.

func GetEncryptKeyIndex added in v0.15.7

func GetEncryptKeyIndex() uint8

GetEncryptKeyIndex returns the encryption key value for the local node. With IPSec encryption, this is equivalent to GetIPsecKeyIdentity(). With WireGuard encryption, this function returns a non-zero static value if the local node has WireGuard enabled.

func GetEndpointHealthIPv4 added in v0.15.7

func GetEndpointHealthIPv4() net.IP

GetEndpointHealthIPv4 returns the IPv4 cilium-health endpoint address.

func GetEndpointHealthIPv6 added in v0.15.7

func GetEndpointHealthIPv6() net.IP

GetEndpointHealthIPv6 returns the IPv6 cilium-health endpoint address.

func GetEndpointID added in v0.15.7

func GetEndpointID() uint64

GetEndpointID returns the ID of the host endpoint for this node.

func GetExcludedIPs added in v0.15.7

func GetExcludedIPs() []net.IP

GetExcludedIPs returns a list of IPs from netdevices that Cilium needs to exclude to operate

func GetHostMasqueradeIPv4 added in v0.15.7

func GetHostMasqueradeIPv4() net.IP

GetHostMasqueradeIPv4 returns the IPv4 address to be used for masquerading any traffic that is being forwarded from the host into the Cilium cluster.

func GetHostMasqueradeIPv6 added in v0.15.7

func GetHostMasqueradeIPv6() net.IP

GetHostMasqueradeIPv6 returns the IPv6 address to be used for masquerading any traffic that is being forwarded from the host into the Cilium cluster.

func GetIPsecKeyIdentity added in v0.15.7

func GetIPsecKeyIdentity() uint8

GetIPsecKeyIdentity returns the IPsec key identity of the node

func GetIPv4 added in v0.15.7

func GetIPv4() net.IP

GetIPv4 returns one of the IPv4 node address available with the following priority: - NodeInternalIP - NodeExternalIP - other IP address type. It must be reachable on the network.

func GetIPv4AllocRange added in v0.15.7

func GetIPv4AllocRange() *cidr.CIDR

GetIPv4AllocRange returns the IPv4 allocation prefix of this node

func GetIPv4Loopback added in v0.15.7

func GetIPv4Loopback() net.IP

GetIPv4Loopback returns the loopback IPv4 address of this node.

func GetIPv6 added in v0.15.7

func GetIPv6() net.IP

GetIPv6 returns the IPv6 address of the node

func GetIPv6AllocRange added in v0.15.7

func GetIPv6AllocRange() *cidr.CIDR

GetIPv6AllocRange returns the IPv6 allocation prefix of this node

func GetIPv6Router added in v0.15.7

func GetIPv6Router() net.IP

GetIPv6Router returns the IPv6 address of the router, e.g. address of cilium_host device.

func GetIngressIPv4 added in v0.15.7

func GetIngressIPv4() net.IP

GetIngressIPv4 returns the local IPv4 source address for Cilium Ingress.

func GetIngressIPv6 added in v0.15.7

func GetIngressIPv6() net.IP

GetIngressIPv6 returns the local IPv6 source address for Cilium Ingress.

func GetInternalIPv4 added in v0.15.7

func GetInternalIPv4() net.IP

GetInternalIPv4 returns node internal ipv4 address else return nil.

func GetInternalIPv4Router added in v0.15.7

func GetInternalIPv4Router() net.IP

GetInternalIPv4Router returns the cilium internal IPv4 node address. This must not be conflated with k8s internal IP as this IP address is only relevant within the Cilium-managed network (this means within the node for direct routing mode and on the overlay for tunnel mode).

func GetInternalIPv6 added in v0.15.7

func GetInternalIPv6() net.IP

GetInternalIPv6 returns node internal ipv6 address else return nil.

func GetK8sExternalIPv4 added in v0.15.7

func GetK8sExternalIPv4() net.IP

GetK8sExternalIPv4 returns the external IPv4 node address. It must be a public IP that is routable on the network as well as the internet. It can return nil if no External IPv4 address is assigned.

func GetK8sExternalIPv6 added in v0.15.7

func GetK8sExternalIPv6() net.IP

GetK8sExternalIPv6 returns the external IPv6 node address.

func GetK8sNodeIP added in v0.15.7

func GetK8sNodeIP() net.IP

GetK8sNodeIPs returns k8s Node IP addr.

func GetLabels added in v0.15.7

func GetLabels() map[string]string

GetLabels returns the labels of this node.

func GetMasqIPv4AddrsWithDevices added in v0.15.7

func GetMasqIPv4AddrsWithDevices() map[string]net.IP

GetMasqIPv4AddrsWithDevices returns the map iface => BPF masquerade IPv4.

func GetMasqIPv6AddrsWithDevices added in v0.15.7

func GetMasqIPv6AddrsWithDevices() map[string]net.IP

GetMasqIPv6AddrsWithDevices returns the map iface => BPF masquerade IPv6.

func GetNodeAddressing added in v0.15.7

func GetNodeAddressing() *models.NodeAddressing

GetNodeAddressing returns the NodeAddressing model for the local IPs.

func GetNodePortIPv4Addrs added in v0.15.7

func GetNodePortIPv4Addrs() []net.IP

GetNodePortIPv4Addrs returns the node-port IPv4 address for NAT

func GetNodePortIPv4AddrsWithDevices added in v0.15.7

func GetNodePortIPv4AddrsWithDevices() map[string]net.IP

GetNodePortIPv4AddrsWithDevices returns the map iface => NodePort IPv4.

func GetNodePortIPv6Addrs added in v0.15.7

func GetNodePortIPv6Addrs() []net.IP

GetNodePortIPv6Addrs returns the node-port IPv6 address for NAT

func GetNodePortIPv6AddrsWithDevices added in v0.15.7

func GetNodePortIPv6AddrsWithDevices() map[string]net.IP

GetNodePortIPv6AddrsWithDevices returns the map iface => NodePort IPv6.

func GetOptOutNodeEncryption added in v0.15.7

func GetOptOutNodeEncryption() bool

func GetWireguardPubKey added in v0.15.7

func GetWireguardPubKey() string

func InitBPFMasqueradeAddrs added in v0.15.7

func InitBPFMasqueradeAddrs(devices []string) error

InitBPFMasqueradeAddrs initializes BPF masquerade addrs for the given devices.

func InitDefaultPrefix added in v0.15.7

func InitDefaultPrefix(device string)

InitDefaultPrefix initializes the node address and allocation prefixes with default values derived from the system. device can be set to the primary network device of the system in which case the first address with global scope will be regarded as the system's node address.

func InitNodePortAddrs added in v0.15.7

func InitNodePortAddrs(devices []string, inheritIPAddrFromDevice string) error

InitNodePortAddrs initializes NodePort IPv{4,6} addrs for the given devices. If inheritIPAddrFromDevice is non-empty, then the IP addr for the devices will be derived from it.

func RestoreHostIPs added in v0.15.7

func RestoreHostIPs(ipv6 bool, fromK8s, fromFS net.IP, cidrs []*cidr.CIDR) net.IP

RestoreHostIPs restores the router IPs (`cilium_host`) from a previous Cilium run. Router IPs from the filesystem are preferred over the IPs found in the Kubernetes resource (Node or CiliumNode), because we consider the filesystem to be the most up-to-date source of truth. The chosen router IP is then checked whether it is contained inside node CIDR (pod CIDR) range. If not, then the router IP is discarded and not restored.

The restored IP is returned.

func SetAnnotations added in v0.15.7

func SetAnnotations(a map[string]string)

SetAnnotations sets the annotations for this node.

func SetDefaultPrefix added in v0.15.7

func SetDefaultPrefix(cfg *option.DaemonConfig, device string, node *LocalNode)

func SetEndpointHealthIPv4 added in v0.15.7

func SetEndpointHealthIPv4(ip net.IP)

SetEndpointHealthIPv4 sets the IPv4 cilium-health endpoint address.

func SetEndpointHealthIPv6 added in v0.15.7

func SetEndpointHealthIPv6(ip net.IP)

SetEndpointHealthIPv6 sets the IPv6 cilium-health endpoint address.

func SetEndpointID added in v0.15.7

func SetEndpointID(id uint64)

SetEndpointID sets the ID of the host endpoint this node.

func SetIPsecKeyIdentity added in v0.15.7

func SetIPsecKeyIdentity(id uint8)

SetIPsecKeyIdentity sets the IPsec key identity an opaque value used to identity encryption keys used on the node.

func SetIPv4AllocRange added in v0.15.7

func SetIPv4AllocRange(net *cidr.CIDR)

SetIPv4AllocRange sets the IPv4 address pool to use when allocating addresses for local endpoints

func SetIPv4Loopback added in v0.15.7

func SetIPv4Loopback(ip net.IP)

SetIPv4Loopback sets the loopback IPv4 address of this node.

func SetIPv6NodeRange added in v0.15.7

func SetIPv6NodeRange(net *cidr.CIDR)

SetIPv6NodeRange sets the IPv6 address pool to be used on this node

func SetIPv6Router added in v0.15.7

func SetIPv6Router(ip net.IP)

SetIPv6Router sets the IPv6 address of the router address, e.g. address of cilium_host device.

func SetIngressIPv4 added in v0.15.7

func SetIngressIPv4(ip net.IP)

SetIngressIPv4 sets the local IPv4 source address for Cilium Ingress.

func SetIngressIPv6 added in v0.15.7

func SetIngressIPv6(ip net.IP)

SetIngressIPv6 sets the local IPv6 source address for Cilium Ingress.

func SetInternalIPv4Router added in v0.15.7

func SetInternalIPv4Router(ip net.IP)

SetInternalIPv4Router sets the cilium internal IPv4 node address, it is allocated from the node prefix. This must not be conflated with k8s internal IP as this IP address is only relevant within the Cilium-managed network (this means within the node for direct routing mode and on the overlay for tunnel mode).

func SetLabels added in v0.15.7

func SetLabels(l map[string]string)

SetLabels sets the labels of this node.

func SetMultiAttributes added in v0.15.7

func SetMultiAttributes(f func(n *LocalNode))

SetMultiAttributes allows the caller to set multiple attributes on the LocalNode by passing a function which modifies LocalNode directly.

This is useful when you need to update more then one attribute at once but do not want to trigger Observers more then once.

func SetOptOutNodeEncryption added in v0.15.7

func SetOptOutNodeEncryption(b bool)

func SetRouterInfo added in v0.15.7

func SetRouterInfo(info RouterInfo)

SetRouterInfo sets additional information for the router, the cilium_host interface.

func SetTestLocalNodeStore added in v0.15.7

func SetTestLocalNodeStore()

func UnsetTestLocalNodeStore added in v0.15.7

func UnsetTestLocalNodeStore()

func UpdateLocalNodeInTest added in v0.15.7

func UpdateLocalNodeInTest(mod func(n *LocalNode))

UpdateLocalNodeInTest provides access to modifying the local node information from tests that are not yet using hive and the LocalNodeStoreCell.

func ValidatePostInit added in v0.15.7

func ValidatePostInit() error

ValidatePostInit validates the entire addressing setup and completes it as required

func WithTestLocalNodeStore added in v0.15.7

func WithTestLocalNodeStore(runTest func())

WithTestLocalNodeStore sets the 'localNode' to a temporary instance and runs the given test. Afterwards the 'localNode' is restored to nil. This is a temporary workaround for tests until the LocalNodeStoreCell can be used.

Types

type LocalNode added in v0.15.7

type LocalNode struct {
	types.Node
	// OptOutNodeEncryption will make the local node opt-out of node-to-node
	// encryption
	OptOutNodeEncryption bool
}

type LocalNodeInitializer added in v0.15.7

type LocalNodeInitializer interface {
	InitLocalNode(context.Context, *LocalNode) error
}

LocalNodeInitializer specifies how to build the initial local node object.

type LocalNodeStore added in v0.15.7

type LocalNodeStore struct {
	// Changes to the local node are observable.
	stream.Observable[LocalNode]
	// contains filtered or unexported fields
}

LocalNodeStore is the canonical owner for the local node object and provides a reactive API for observing and updating the state.

func NewLocalNodeStore added in v0.15.7

func NewLocalNodeStore(params LocalNodeStoreParams) (*LocalNodeStore, error)

func NewTestLocalNodeStore added in v0.15.7

func NewTestLocalNodeStore(mockNode LocalNode) *LocalNodeStore

func (*LocalNodeStore) Get added in v0.15.7

func (s *LocalNodeStore) Get(ctx context.Context) (LocalNode, error)

Get retrieves the current local node. Use Get() only for inspecting the state, e.g. in API handlers. Do not assume the value does not change over time. Blocks until the store has been initialized.

func (*LocalNodeStore) Update added in v0.15.7

func (s *LocalNodeStore) Update(update func(*LocalNode))

Update modifies the local node with a mutator. The updated value is passed to observers.

type LocalNodeStoreParams added in v0.15.7

type LocalNodeStoreParams struct {
	cell.In

	Lifecycle hive.Lifecycle
	Init      LocalNodeInitializer `optional:"true"`
}

LocalNodeStoreParams are the inputs needed for constructing LocalNodeStore.

type RouterInfo added in v0.15.7

type RouterInfo interface {
	GetIPv4CIDRs() []net.IPNet
	GetMac() mac.MAC
	GetInterfaceNumber() int
}

func GetRouterInfo added in v0.15.7

func GetRouterInfo() RouterInfo

GetRouterInfo returns additional information for the router, the cilium_host interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL