From 6dffff6aa9a310faf1d147abdfa5e4226dea7ba2 Mon Sep 17 00:00:00 2001 From: Hugo Meyronneinc Date: Sat, 25 Oct 2025 17:33:19 +0200 Subject: [PATCH] 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 Signed-off-by: Andrey Smirnov --- network/zerotier/README.md | 15 ++++++++++++++- network/zerotier/zerotier-wrapper/main.go | 10 ++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/network/zerotier/README.md b/network/zerotier/README.md index e6ae531..0874b68 100644 --- a/network/zerotier/README.md +++ b/network/zerotier/README.md @@ -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= ``` +### 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=,, +``` + 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 diff --git a/network/zerotier/zerotier-wrapper/main.go b/network/zerotier/zerotier-wrapper/main.go index 4f236ad..48b083f 100644 --- a/network/zerotier/zerotier-wrapper/main.go +++ b/network/zerotier/zerotier-wrapper/main.go @@ -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.