Skip to content

Commit 7ecae15

Browse files
Hugomesmira
authored andcommitted
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 <[email protected]> Signed-off-by: Andrey Smirnov <[email protected]>
1 parent fc85294 commit 7ecae15

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

network/zerotier/README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ mynode runtime ExtensionServiceConfig zerotier 1
4040

4141
The extension can be configured through environment variables:
4242

43-
- `ZEROTIER_NETWORK`: The network ID to join (required)
43+
- `ZEROTIER_NETWORK`: The network ID to join (required, you can also specify multiple network by separting them with ",")
4444
- `ZEROTIER_IDENTITY_SECRET`: Optional pre-existing identity to use (format: "address:0:public:private")
4545
- `ZEROTIER_PLANET`: Optional pre-existing planet file encoded in base64
4646

@@ -58,6 +58,19 @@ environment:
5858
- ZEROTIER_IDENTITY_SECRET=<identity string>
5959
```
6060
61+
### Join multiple network
62+
63+
If you want to join multiple zerotier network, you can use the following format:
64+
65+
```yaml
66+
---
67+
apiVersion: v1alpha1
68+
kind: ExtensionServiceConfig
69+
name: zerotier
70+
environment:
71+
- ZEROTIER_NETWORK=<your network id 1>,<your network id 2>,<your network id 3>
72+
```
73+
6174
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).
6275
6376
### Using an custom planet file

network/zerotier/zerotier-wrapper/main.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,13 @@ func main() {
5555

5656
// If ZEROTIER_NETWORK env var is set, join the network.
5757
if network := os.Getenv("ZEROTIER_NETWORK"); network != "" {
58-
log.Printf("joining network %s", network)
59-
if err := joinNetwork(network); err != nil {
60-
log.Fatalf("failed to join network: %v", err)
58+
for _, network := range strings.Split(network, ",") {
59+
log.Printf("joining network %s", network)
60+
if err := joinNetwork(network); err != nil {
61+
log.Fatalf("failed to join network: %v", err)
62+
}
63+
log.Printf("joined network %s", network)
6164
}
62-
log.Printf("joined network %s", network)
6365
}
6466

6567
// Start zerotier-one process.

0 commit comments

Comments
 (0)