feat: add the ability to have multiple zerotier network to join

Simple addition to be able to join multiple zerotier networks.

Signed-off-by: Hugo Meyronneinc <hugo@lxc.lu>
Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
This commit is contained in:
Hugo Meyronneinc 2025-10-25 17:33:19 +02:00 committed by Andrey Smirnov
parent 9d7136bdd8
commit 6dffff6aa9
No known key found for this signature in database
GPG Key ID: 322C6F63F594CE7C
2 changed files with 20 additions and 5 deletions

View File

@ -40,7 +40,7 @@ mynode runtime ExtensionServiceConfig zerotier 1
The extension can be configured through environment variables:
- `ZEROTIER_NETWORK`: The network ID to join (required)
- `ZEROTIER_NETWORK`: The network ID to join (required, you can also specify multiple network by separting them with ",")
- `ZEROTIER_IDENTITY_SECRET`: Optional pre-existing identity to use (format: "address:0:public:private")
- `ZEROTIER_PLANET`: Optional pre-existing planet file encoded in base64
@ -58,6 +58,19 @@ environment:
- ZEROTIER_IDENTITY_SECRET=<identity string>
```
### Join multiple network
If you want to join multiple zerotier network, you can use the following format:
```yaml
---
apiVersion: v1alpha1
kind: ExtensionServiceConfig
name: zerotier
environment:
- ZEROTIER_NETWORK=<your network id 1>,<your network id 2>,<your network id 3>
```
If no identity is provided, a new one will be generated automatically. (You may need to authorize this node in your Zerotier network according to your network policies before it will recieve an IP address).
### Using an custom planet file

View File

@ -55,11 +55,13 @@ func main() {
// If ZEROTIER_NETWORK env var is set, join the network.
if network := os.Getenv("ZEROTIER_NETWORK"); network != "" {
log.Printf("joining network %s", network)
if err := joinNetwork(network); err != nil {
log.Fatalf("failed to join network: %v", err)
for _, network := range strings.Split(network, ",") {
log.Printf("joining network %s", network)
if err := joinNetwork(network); err != nil {
log.Fatalf("failed to join network: %v", err)
}
log.Printf("joined network %s", network)
}
log.Printf("joined network %s", network)
}
// Start zerotier-one process.