Help us shape the future of Go! Take the 2026 Go Developer Survey

types

package
v1.21.0-pre.4 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 18 Imported by: 33

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAbsoluteNodeName

func GetAbsoluteNodeName() string

GetAbsoluteNodeName returns the absolute node name combined of both (prefixed)cluster name and the local node name in case of clustered environments otherwise returns the name of the local node.

func GetClusterName

func GetClusterName() string

func GetKeyNodeName

func GetKeyNodeName(cluster, node string) string

GetKeyNodeName constructs the API name for the given cluster and node name.

func GetName

func GetName() string

GetName returns the name of the local node. The value returned was either previously set with SetName(), retrieved via `os.Hostname()`, or as a last resort is hardcoded to "localhost".

func SetName

func SetName(name string)

SetName sets the name of the local node. This will overwrite the value that is automatically retrieved with `os.Hostname()`.

Note: This function is currently designed to only be called during the bootstrapping procedure of the agent where no parallelism exists. If you want to use this function in later stages, a mutex must be added first.

Types

type Address

type Address struct {
	Type addressing.AddressType
	IP   iputil.Addr
}

Address is a node address which contains an IP and the address type.

IP is always stored unmapped, i.e. an IPv4 address is held as a 4-byte netip.Addr and never as its IPv4-mapped IPv6 form. Build addresses with NewAddress, which enforces this, rather than with a struct literal: the readers of IPAddresses compare addresses with == and derive prefixes from their bit length, so a mapped value would silently compare unequal to every other copy of the same address and yield a /128 prefix for an IPv4 address.

+k8s:deepcopy-gen=true

func NewAddress

func NewAddress(typ addressing.AddressType, addr netip.Addr) Address

NewAddress returns a node address of the given type, normalizing addr so that the invariant documented on Address holds.

func (Address) Addr

func (a Address) Addr() netip.Addr

Addr returns the address, implementing addressing.Address.

func (Address) AddrType added in v1.15.0

func (a Address) AddrType() addressing.AddressType

func (*Address) DeepCopy

func (in *Address) DeepCopy() *Address

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Address.

func (*Address) DeepCopyInto

func (in *Address) DeepCopyInto(out *Address)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*Address) DeepEqual added in v1.17.0

func (a *Address) DeepEqual(other *Address) bool

type Identity

type Identity struct {
	Name    string
	Cluster string
}

Identity represents the node identity of a node.

func (Identity) String

func (nn Identity) String() string

String returns the string representation on NodeIdentity.

type Node

type Node struct {
	// Name is the name of the node. This is typically the hostname of the node.
	Name string

	// Cluster is the name of the cluster the node is associated with
	Cluster string

	IPAddresses []Address

	// IPv4AllocCIDR if set, is the IPv4 address pool out of which the node
	// allocates IPs for local endpoints from
	IPv4AllocCIDR Prefix

	// IPv4SecondaryAllocCIDRs contains additional IPv4 CIDRs from which this
	// node allocates IPs for its local endpoints from
	IPv4SecondaryAllocCIDRs []Prefix

	// IPv6AllocCIDR if set, is the IPv6 address pool out of which the node
	// allocates IPs for local endpoints from
	IPv6AllocCIDR Prefix

	// IPv6SecondaryAllocCIDRs contains additional IPv6 CIDRs from which this
	// node allocates IPs for its local endpoints from
	IPv6SecondaryAllocCIDRs []Prefix

	// IPv4HealthIP if set, this is the IPv4 address of the
	// cilium-health endpoint located on the node.
	IPv4HealthIP iputil.Addr

	// IPv6HealthIP if set, this is the IPv6 address of the
	// cilium-health endpoint located on the node.
	IPv6HealthIP iputil.Addr

	// IPv4IngressIP if set, this is the IPv4 address of the
	// Ingress listener on the node.
	IPv4IngressIP iputil.Addr

	// IPv6IngressIP if set, this is the IPv6 address of the
	// Ingress listener located on the node.
	IPv6IngressIP iputil.Addr

	// ClusterID is the unique identifier of the cluster
	ClusterID uint32

	// Source is the source where the node configuration was generated / created.
	Source source.Source

	// Key index used for transparent encryption or 0 for no encryption
	EncryptionKey uint8

	// Node labels
	Labels map[string]string

	// Node annotations
	Annotations map[string]string

	// WireguardPubKey is the WireGuard public key of this node
	WireguardPubKey string

	// BootID is a unique node identifier generated on boot
	BootID string
}

Node contains the nodes name, the list of addresses to this address

+k8s:deepcopy-gen=true +deepequal-gen=true

func (*Node) DeepCopy

func (in *Node) DeepCopy() *Node

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Node.

func (*Node) DeepCopyInto

func (in *Node) DeepCopyInto(out *Node)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*Node) DeepEqual added in v1.17.0

func (in *Node) DeepEqual(other *Node) bool

DeepEqual is an autogenerated deepequal function, deeply comparing the receiver with other. in must be non-nil.

func (*Node) Fullname

func (n *Node) Fullname() string

Fullname returns the node's full name including the cluster name if a cluster name value other than the default value has been specified

func (*Node) GetCiliumInternalIPv4

func (n *Node) GetCiliumInternalIPv4() netip.Addr

GetCiliumInternalIPv4 returns the IPv4 CiliumInternalIP e.g. the IP associated with cilium_host on the node.

func (*Node) GetCiliumInternalIPv6

func (n *Node) GetCiliumInternalIPv6() netip.Addr

GetCiliumInternalIPv6 returns the IPv6 CiliumInternalIP e.g. the IP associated with cilium_host on the node.

func (*Node) GetIPv4AllocCIDRs

func (n *Node) GetIPv4AllocCIDRs() []netip.Prefix

func (*Node) GetIPv6AllocCIDRs

func (n *Node) GetIPv6AllocCIDRs() []netip.Prefix

func (*Node) GetK8sNodeIP

func (n *Node) GetK8sNodeIP() netip.Addr

GetK8sNodeIP returns k8s Node IP (either InternalIP or ExternalIP or the zero value, the former is preferred).

func (*Node) GetKeyName

func (n *Node) GetKeyName() string

GetKeyName returns the kvstore key to be used for the node

func (*Node) GetModel

func (n *Node) GetModel() *models.NodeElement

GetModel returns the API model representation of a node.

func (*Node) GetNodeExternalIPv4

func (n *Node) GetNodeExternalIPv4() netip.Addr

GetNodeExternalIPv4 returns the IPv4 ExternalIP of the k8s Node, or the zero value if the node holds no such address.

func (*Node) GetNodeExternalIPv6

func (n *Node) GetNodeExternalIPv6() netip.Addr

GetNodeExternalIPv6 returns the IPv6 ExternalIP of the k8s Node, or the zero value if the node holds no such address.

func (*Node) GetNodeIP

func (n *Node) GetNodeIP(ipv6 bool) netip.Addr

GetNodeIP returns one of the node's IP addresses available with the following priority: - NodeInternalIP - NodeExternalIP - other IP address type The zero value is returned if GetNodeIP fails to extract an IP from the Node based on the provided address family.

func (*Node) GetNodeInternalIPv4

func (n *Node) GetNodeInternalIPv4() netip.Addr

GetNodeInternalIPv4 returns the InternalIPv4 of the k8s Node or the zero value.

func (*Node) GetNodeInternalIPv6

func (n *Node) GetNodeInternalIPv6() netip.Addr

GetNodeInternalIPv6 returns the InternalIPv6 of the k8s Node or the zero value.

func (*Node) Identity

func (n *Node) Identity() Identity

Identity returns the identity of the node

func (*Node) IsLocal

func (n *Node) IsLocal() bool

IsLocal returns true if this is the node on which the agent itself is running on

func (*Node) IsNodeIP added in v1.17.0

func (n *Node) IsNodeIP(addr netip.Addr) addressing.AddressType

IsNodeIP determines if addr is one of the node's IP addresses, and returns which type of address it is. "" is returned if addr is not one of the node's IP addresses.

func (*Node) LogRepr added in v1.12.18

func (n *Node) LogRepr() string

LogRepr returns a representation of the node to be used for logging

func (*Node) Marshal

func (n *Node) Marshal() ([]byte, error)

Marshal returns the node object as JSON byte slice

func (*Node) SetCiliumInternalIP

func (n *Node) SetCiliumInternalIP(newAddr netip.Addr)

SetCiliumInternalIP sets the CiliumInternalIP e.g. the IP associated with cilium_host on the node. 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 (*Node) SetNodeExternalIP

func (n *Node) SetNodeExternalIP(newAddr netip.Addr)

SetNodeExternalIP sets the NodeExternalIP.

func (*Node) SetNodeInternalIP

func (n *Node) SetNodeInternalIP(newAddr netip.Addr)

SetNodeInternalIP sets the NodeInternalIP.

func (*Node) Unmarshal

func (n *Node) Unmarshal(key string, data []byte) error

Unmarshal parses the JSON byte slice and updates the node receiver

type Prefix

type Prefix struct {
	ip.Prefix
}

Prefix is a transitional wrapper used for the Node kvstore CIDR fields that were previously *cidr.CIDR. It embeds ip.Prefix (the canonical netip.Prefix wrapper this migration converges on) so it inherits String/IsValid and the generated-code DeepCopy/DeepEqual pattern, while overriding JSON marshaling to preserve backward compatibility on the wire.

See issue https://github.com/cilium/cilium/issues/46924 for the full context and motivation behind this type and why it is needed.

+k8s:deepcopy-gen=false +deepequal-gen=false

func PrefixFrom

func PrefixFrom(p netip.Prefix) Prefix

PrefixFrom wraps a netip.Prefix, canonicalizing it to its masked network address so the emitted legacy object matches what net.ParseCIDR produced.

func (*Prefix) DeepCopy

func (p *Prefix) DeepCopy() *Prefix

func (*Prefix) DeepCopyInto

func (p *Prefix) DeepCopyInto(out *Prefix)

DeepCopyInto is a hand-written copy: netip.Addr's hidden zone pointer references interned, immutable data, so a value copy is safe. It is declared here (rather than inherited from ip.Prefix) so deepcopy-gen'd callers, which emit in.Field.DeepCopyInto(&out.Field), type-check against *Prefix.

func (*Prefix) DeepEqual

func (p *Prefix) DeepEqual(other *Prefix) bool

func (Prefix) MarshalJSON

func (p Prefix) MarshalJSON() ([]byte, error)

MarshalJSON emits the legacy net.IPNet object form for backward compatibility.

func (*Prefix) UnmarshalJSON

func (p *Prefix) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts both the legacy object form and the target string form, as well as JSON null (a previously-unset *cidr.CIDR).

Jump to

Keyboard shortcuts

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