-
Notifications
You must be signed in to change notification settings - Fork 550
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: import siderolink as
siderolink-launch
subcommand
This PR ensures that we can test our siderolink communication using embedded siderolink-agent. If `--with-siderolink` provided during `talos cluster create` talosctl will embed proper kernel string and setup `siderolink-agent` as a separate process. It should be used with combination of `--skip-injecting-config` and `--with-apply-config` (the latter will use newly generated IPv6 siderolink addresses which talosctl passes to the agent as a "pre-bind"). Fixes #8392 Signed-off-by: Dmitriy Matrenichev <dmitry.matrenichev@siderolabs.com>
- Loading branch information
Showing
18 changed files
with
534 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// 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/. | ||
|
||
//go:build linux | ||
|
||
package cluster | ||
|
||
import ( | ||
"fmt" | ||
"net/netip" | ||
|
||
"github.com/siderolabs/siderolink/pkg/wireguard" | ||
) | ||
|
||
type nodeAddrGenerator struct { | ||
prefix netip.Prefix | ||
nodeAddr netip.Addr | ||
} | ||
|
||
func makeNodeAddrGenerator() nodeAddrGenerator { | ||
prefix := wireguard.NetworkPrefix("") | ||
nodeAddr := prefix.Addr().Next() | ||
|
||
return nodeAddrGenerator{ | ||
prefix: prefix, | ||
nodeAddr: nodeAddr, | ||
} | ||
} | ||
|
||
func (ng *nodeAddrGenerator) GenerateRandomNodeAddr() (netip.Addr, error) { | ||
result, err := wireguard.GenerateRandomNodeAddr(ng.prefix) | ||
if err != nil { | ||
return netip.Addr{}, fmt.Errorf("failed to generate random node address: %w", err) | ||
} | ||
|
||
return result.Addr(), nil | ||
} | ||
|
||
func (ng *nodeAddrGenerator) GetAgentNodeAddr() string { | ||
return ng.nodeAddr.String() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// 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/. | ||
|
||
//go:build !linux | ||
|
||
package cluster | ||
|
||
import ( | ||
"errors" | ||
"net/netip" | ||
) | ||
|
||
type nodeAddrGenerator struct{} | ||
|
||
func (ng *nodeAddrGenerator) GenerateRandomNodeAddr() (netip.Addr, error) { | ||
return netip.Addr{}, errors.New("unsupported platform") | ||
} | ||
|
||
func (ng *nodeAddrGenerator) GetAgentNodeAddr() string { | ||
return "" | ||
} | ||
|
||
func makeNodeAddrGenerator() nodeAddrGenerator { | ||
return nodeAddrGenerator{} | ||
} |
Oops, something went wrong.