mirror of
https://github.com/siderolabs/talos.git
synced 2025-11-06 11:21:13 +01:00
This controller queries addresses of all the interfaces in the system
and presents them as resources. The idea is that can be a source for
many decisions - e.g. whether network is ready (physical interface has
scope global address assigned).
This is also good for debugging purposes.
Examples:
```
$ talosctl -n 172.20.0.2 get addresses
NODE NAMESPACE TYPE ID VERSION
172.20.0.2 network AddressStatus cni0/10.244.0.1/24 1
172.20.0.2 network AddressStatus cni0/fe80::9c87:cdff:fe8e:5fdc/64 2
172.20.0.2 network AddressStatus eth0/172.20.0.2/24 1
172.20.0.2 network AddressStatus eth0/fe80::ac1b:9cff:fe19:6b47/64 2
172.20.0.2 network AddressStatus flannel.1/10.244.0.0/32 1
172.20.0.2 network AddressStatus flannel.1/fe80::440b:67ff:fe99:c18f/64 2
172.20.0.2 network AddressStatus lo/127.0.0.1/8 1
172.20.0.2 network AddressStatus lo/::1/128 1
172.20.0.2 network AddressStatus veth178e9b31/fe80::6040:1dff:fe5b:ae1a/64 2
172.20.0.2 network AddressStatus vethb0b96a94/fe80::2473:86ff:fece:1954/64 2
```
```
$ talosctl -n 172.20.0.2 get addresses -o yaml eth0/172.20.0.2/24
node: 172.20.0.2
metadata:
namespace: network
type: AddressStatuses.net.talos.dev
id: eth0/172.20.0.2/24
version: 1
owner: network.AddressStatusController
phase: running
spec:
address: 172.20.0.2/24
local: 172.20.0.2
broadcast: 172.20.0.255
linkIndex: 4
linkName: eth0
family: inet4
scope: global
flags: permanent
```
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
27 lines
781 B
Go
27 lines
781 B
Go
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
package nethelpers
|
|
|
|
import "golang.org/x/sys/unix"
|
|
|
|
//go:generate stringer -type=Scope -linecomment
|
|
|
|
// Scope is an address scope.
|
|
type Scope uint8
|
|
|
|
// MarshalYAML implements yaml.Marshaler.
|
|
func (scope Scope) MarshalYAML() (interface{}, error) {
|
|
return scope.String(), nil
|
|
}
|
|
|
|
// Scope constants.
|
|
const (
|
|
ScopeGlobal Scope = unix.RT_SCOPE_UNIVERSE // global
|
|
ScopeSite Scope = unix.RT_SCOPE_SITE // site
|
|
ScopeLink Scope = unix.RT_SCOPE_LINK // link
|
|
ScopeHost Scope = unix.RT_SCOPE_HOST // host
|
|
ScopeNowhere Scope = unix.RT_SCOPE_NOWHERE // nowhere
|
|
)
|