Delve deeper into networking of Talos Linux.
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.
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
.
*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:
*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.
network-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:
default
configuration layer which defines the hostname as talos-172-20-0-2
(default driven by the default node address);operator
that defines the hostname as talos-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.
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:
NodeAddress
resource presents node addresses excluding link-local and loopback addresses:
default
is the node default address;current
is the set of addresses a node currently has;accumulative
is 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:
*StatusController
populates *Status
resources observing the Linux kernel state.*ConfigController
produces the initial unmerged *Spec
resources in the network-config
namespace based on defaults, kernel command line, and machine configuration.*MergeController
merges *Spec
resources into the final representation in the network
namespace.*SpecController
applies merged *Spec
resources to the kernel state.OperatorConfigController
produces OperatorSpec
resources based on machine configuration and deafauls.OperatorSpecController
runs network operators watching OperatorSpec
resources and producing various *Spec
resources in the network-config
namespace.lo
interface is assigned addresses 127.0.0.1/8
and ::1/128
;talos-<IP>
where IP
is the default node address;8.8.8.8
, 1.1.1.1
;pool.ntp.org
;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./system/state/platform-network.yaml
.
.machine.network
configuration can be applied in immediate mode.
debug
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.