talosctl get command.
Network machine configuration can be modified using talosctl edit mc command (also variants talosctl patch mc, talosctl apply-config) without a reboot.
As API access requires network connection, --mode=try
can be used to test the configuration with automatic rollback to avoid losing network access to the node.
Resources
There are six basic network configuration items in Talos:Address(IP address assigned to the interface/link);Route(route to a destination);Link(network interface/link configuration);Resolver(list of DNS servers);Hostname(node hostname and domainname);TimeServer(list of NTP servers).
*Status(e.g.LinkStatus) describes the current state of the system (Linux kernel state);*Spec(e.g.LinkSpec) defines the desired configuration.
| Resource | Status | Spec |
|---|---|---|
Address | AddressStatus | AddressSpec |
Route | RouteStatus | RouteSpec |
Link | LinkStatus | LinkSpec |
Resolver | ResolverStatus | ResolverSpec |
Hostname | HostnameStatus | HostnameSpec |
TimeServer | TimeServerStatus | TimeServerSpec |
Status suffix removed, so for example
AddressStatus is also available as Address.
Talos networking controllers reconcile the state so that *Status equals the desired *Spec.
Observing State
The current network configuration state can be observed by querying*Status resources via
talosctl:
eth0/172.20.0.2/24) and
addresses set up by other facilities (e.g. flannel.1/10.244.4.0/32 set up by CNI).
Talos networking controllers watch the kernel state and update resources
accordingly.
Additional details about the address can be accessed via the YAML output:
--watch flag to see how configuration changes over time.
Other networking status resources can be inspected with talosctl get routes, talosctl get links, etc.
For example:
Inspecting Configuration
The desired networking configuration is combined from multiple sources and presented as*Spec resources:
AddressSpecs are applied to the Linux kernel to reach the desired state.
If, for example, an AddressSpec is removed, the address is removed from the Linux network interface as well.
*Spec resources canβt be manipulated directly, they are generated automatically by Talos
from multiple configuration sources (see a section below for details).
If a *Spec resource is queried in YAML format, some additional information is available:
layer field, which describes a configuration layer this spec is coming from: in this case, itβs generated by a network operator (see below) and is set by the DHCPv4 operator.
Configuration Merging
Spec resources described in the previous section show the final merged configuration state, while initial specs are put to a different unmerged namespacenetwork-config.
Spec resources in the network-config namespace are merged with conflict resolution to produce the final merged representation in the network namespace.
Letβs take HostnameSpec as an example.
The final merged representation is:
talos-default-controlplane-1.
And this is the hostname that was actually applied.
This can be verified by querying a HostnameStatus resource:
network-config namespace is:
- one from the
defaultconfiguration layer which defines the hostname astalos-172-20-0-2(default driven by the default node address); - another one from the layer
operatorthat defines the hostname astalos-default-controlplane-1(DHCP).
HostnameSpec based on the configuration layer and merge rules.
Here is the order of precedence from low to high:
default(defaults provided by Talos);cmdline(from the kernel command line);platform(driven by the cloud provider);operator(various dynamic configuration options: DHCP, Virtual IP, etc);configuration(derived from the machine configuration).
operator layer HostnameSpec overrides the default layer producing the final hostname talos-default-controlplane-1.
The merge process applies to all six core networking specs.
For each spec, the layer controls the merge behavior
If multiple configuration specs
appear at the same layer, they can be merged together if possible, otherwise merge result
is stable but not defined (e.g. if DHCP on multiple interfaces provides two different hostnames for the node).
LinkSpecs are merged across layers, so for example, machine configuration for the interface MTU overrides an MTU set by the DHCP server.
Network Operators
Network operators provide dynamic network configuration which can change over time as the node is running:- DHCPv4
- DHCPv6
- Virtual IP
OperatorSpec resources which describe when operators
should run and additional configuration for the operator:
OperatorSpec resources are generated by Talos based on machine configuration mostly.
DHCP4 operator is created automatically for all physical network links which are not configured explicitly via the kernel command line or the machine configuration.
This also means that on the first boot, without a machine configuration, a DHCP request is made on all physical network interfaces by default.
Specs generated by operators are prefixed with the operator ID (dhcp4/eth0 in the example above) in the unmerged network-config namespace:
Other Network Resources
There are some additional resources describing the network subsystem state. TheNodeAddress resource presents node addresses excluding link-local and loopback addresses:
defaultis the node default address;currentis the set of addresses a node currently has;accumulativeis the set of addresses a node had over time (it might include virtual IPs which are not owned by the node at the moment).
NodeAddress resources are used to pick up the default address for etcd peer URL, to populate SANs field in the generated certificates, etc.
Another important resource is Nodename which provides Node name in Kubernetes:
nodename might be just a hostname or the FQDN of the node.
NetworkStatus aggregates the current state of the network configuration:
Network Controllers
For each of the six basic resource types, there are several controllers:*StatusControllerpopulates*Statusresources observing the Linux kernel state.*ConfigControllerproduces the initial unmerged*Specresources in thenetwork-confignamespace based on defaults, kernel command line, and machine configuration.*MergeControllermerges*Specresources into the final representation in thenetworknamespace.*SpecControllerapplies merged*Specresources to the kernel state.
OperatorConfigControllerproducesOperatorSpecresources based on machine configuration and deafauls.OperatorSpecControllerruns network operators watchingOperatorSpecresources and producing various*Specresources in thenetwork-confignamespace.
Configuration Sources
There are several configuration sources for the network configuration, which are described in this section.Defaults
lointerface is assigned addresses127.0.0.1/8and::1/128;- hostname is set to the
talos-<IP>whereIPis the default node address; - resolvers are set to
8.8.8.8,1.1.1.1; - time servers are set to
pool.ntp.org; - DHCP4 operator is run on any physical interface which is not configured explicitly.
Cmdline
The kernel command line is parsed for the following options:ip=option is parsed for node IP, default gateway, hostname, DNS servers, NTP servers;bond=option is parsed for bonding interfaces and their options;talos.hostname=option is used to set node hostname;talos.network.interface.ignore=can be used to make Talos skip network interface configuration completely.
Platform
Platform configuration delivers cloud environment-specific options (e.g. the hostname). Platform configuration is specific to the environment metadata: for example, on Equinix Metal, Talos automatically configures public and private IPs, routing, link bonding, hostname. Platform configuration is cached across reboots in/system/state/platform-network.yaml.
Operator
Network operators provide configuration for all basic resource types.Machine Configuration
The machine configuration is parsed for link configuration, addresses, routes, hostname, resolvers and time servers. Any changes to.machine.network configuration can be applied in immediate mode.
Network Configuration Debugging
Most of the network controller operations and failures are logged to the kernel console, additional logs withdebug level are available with talosctl logs controller-runtime command.
If the network configuration canβt be established and the API is not available, debug level
logs can be sent to the console with debug: true option in the machine configuration.