feat: zerotier - add possible custom planet file

Add custom plant file for zerotier

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-08-27 17:35:35 +02:00 committed by Andrey Smirnov
parent df7a67dc8d
commit 5ccda4bdeb
No known key found for this signature in database
GPG Key ID: 322C6F63F594CE7C
2 changed files with 32 additions and 0 deletions

View File

@ -42,6 +42,7 @@ The extension can be configured through environment variables:
- `ZEROTIER_NETWORK`: The network ID to join (required)
- `ZEROTIER_IDENTITY_SECRET`: Optional pre-existing identity to use (format: "address:0:public:private")
- `ZEROTIER_PLANET`: Optional pre-existing planet file encoded in base64
### Using an existing identity
@ -58,3 +59,20 @@ environment:
```
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
If you want to specify custom planet file from a hosted planet, you can specify an custom planet:
```yaml
---
apiVersion: v1alpha1
kind: ExtensionServiceConfig
name: zerotier
environment:
- ZEROTIER_NETWORK=<your network id>
- ZEROTIER_IDENTITY_SECRET=<identity string>
- ZEROTIER_PLANET=<base64 encoded planet file>
```
If no planet is provided, the public planet file from ZeroTier will be used.

View File

@ -6,6 +6,7 @@ package main
import (
"bytes"
"encoding/base64"
"errors"
"fmt"
"log"
@ -20,6 +21,7 @@ import (
const (
zerotierPath = "/var/lib/zerotier-one"
identityPath = "/var/lib/zerotier-one/identity.secret"
planetPath = "/var/lib/zerotier-one/planet"
identityPubPath = "/var/lib/zerotier-one/identity.public"
zerotierBinPath = "/usr/local/bin/zerotier-one"
)
@ -39,6 +41,18 @@ func main() {
}
log.Printf("identity configured (source: %s)", identitySource)
// If ZEROTIER_PLANET env var is set, set the planet file.
if planet := os.Getenv("ZEROTIER_PLANET"); planet != "" {
planet, err := base64.StdEncoding.DecodeString(planet)
if err != nil {
log.Fatalf("failed to decode base64 planet from environment: %v", err)
}
if err := os.WriteFile(planetPath, planet, 0o644); err != nil {
log.Fatalf("failed to write planet file: %v", err)
}
log.Printf("custom planet file loaded")
}
// If ZEROTIER_NETWORK env var is set, join the network.
if network := os.Getenv("ZEROTIER_NETWORK"); network != "" {
log.Printf("joining network %s", network)