Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add zerotier extension to Talos #596

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ TARGETS += v4l-uvc-drivers
TARGETS += vmtoolsd-guest-agent
TARGETS += wasmedge
TARGETS += xen-guest-agent
TARGETS += zerotier
TARGETS += zfs
NONFREE_TARGETS = nonfree-kmod-nvidia-lts
NONFREE_TARGETS += nonfree-kmod-nvidia-production
Expand Down Expand Up @@ -248,4 +249,3 @@ release-notes: $(ARTIFACTS)
conformance:
@docker pull $(CONFORMANCE_IMAGE)
@docker run --rm -it -v $(PWD):/src -w /src $(CONFORMANCE_IMAGE) enforce

2 changes: 2 additions & 0 deletions network/vars.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ TAILSCALE_VERSION: 1.78.1
LLDPD_VERSION: 1.0.19
# renovate: datasource=github-releases depName=cloudflare/cloudflared
CLOUDFLARED_VERSION: 2024.12.1

ZEROTIER_VERSION: 1.14.2
10 changes: 10 additions & 0 deletions network/zerotier/manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: v1alpha1
metadata:
name: zerotier
version: "$VERSION"
author: Hive Technologies
description: |
Connect your Talos cluster into a zerotier network
compatibility:
talos:
version: ">= v1.8.0"
50 changes: 50 additions & 0 deletions network/zerotier/pkg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: zerotier
variant: alpine
shell: /toolchain/bin/bash
dependencies:
- stage: base
install:
- libstdc++
steps:
-
sources:
- url: https://github.com/zerotier/ZeroTierOne/archive/refs/tags/{{ .ZEROTIER_VERSION }}.tar.gz
destination: zerotier.tar.gz
sha256: c2f64339fccf5148a7af089b896678d655fbfccac52ddce7714314a59d7bddbb
sha512: 9d022afcf81543d6ee938219a3712da846fe895b0fd65cfd6ec8ed173f0e208516031b6d2303ab42fd21806d9ba5ff6fdb0d850a0cbb32b268d53accb093cdf5
env:
CXXFLAGS: '-Os -fstack-protector -std=c++17 -pthread'
LDFLAGS: '-static'
prepare:
- |
sed -i 's#$VERSION#{{ .VERSION }}#' /pkg/manifest.yaml
- |
tar -xzvf zerotier.tar.gz --strip-components=1
build:
- |
sed -i '2i #include <cmath>' ext/prometheus-cpp-lite-1.0/core/include/prometheus/text_serializer.h
make ONE_THREAD=1 ZT_SSO_SUPPORTED=0 STATIC=1 -j $(nproc)
install:
- |
mkdir -p /rootfs/usr/local/lib/containers/zerotier/usr/local/bin/
cp -pr zerotier-one /rootfs/usr/local/lib/containers/zerotier/usr/local/bin/
chmod +x /rootfs/usr/local/lib/containers/zerotier/usr/local/bin/zerotier-*
cd /rootfs/usr/local/lib/containers/zerotier/usr/local/bin
ln -sf zerotier-one zerotier-cli
ln -sf zerotier-one zerotier-idtool
- |
mkdir -p /rootfs/usr/local/etc/containers/zerotier/usr/local/etc/zerotier/state
cp /pkg/zerotier.yaml /rootfs/usr/local/etc/containers/
test:
- |
mkdir -p /extensions-validator-rootfs
cp -r /rootfs/ /extensions-validator-rootfs/rootfs
cp /pkg/manifest.yaml /extensions-validator-rootfs/manifest.yaml
/extensions-validator validate --rootfs=/extensions-validator-rootfs --pkg-name="${PKG_NAME}"
- |
[[ $(/rootfs/usr/local/lib/containers/zerotier/usr/local/bin/zerotier-cli -v) == *{{ .ZEROTIER_VERSION }}* ]]
finalize:
- from: /rootfs
to: /rootfs
- from: /pkg/manifest.yaml
to: /
1 change: 1 addition & 0 deletions network/zerotier/vars.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VERSION: "{{ .ZEROTIER_VERSION }}"
55 changes: 55 additions & 0 deletions network/zerotier/zerotier.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: zerotier
depends:
- service: cri
- network:
- addresses
- connectivity
- etcfiles
- configuration: true
container:
entrypoint: /usr/local/bin/zerotier-one
args:
- /var/lib/zerotier-one
environment:
- PATH=/sbin:/usr/local/bin
security:
writeableRootfs: false
writeableSysfs: true
mounts:
# libs
- source: /lib
destination: /lib
type: bind
options:
- bind
- ro
# more libs
- source: /usr/lib
destination: /usr/lib
type: bind
options:
- bind
- ro
## Required for zerotier. Ip addr and other commands
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

talos doesn't ship any of those commands so I'm not sure sbin mount has any effect

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fair, i took it straight from the WG extension, but will remove

- source: /sbin
destination: /sbin
type: bind
options:
- bind
- ro
## Zerotier needs to write to this to create the interfaces
- source: /dev/net/tun
destination: /dev/net/tun
type: bind
options:
- bind
- rw
## Zerotier state.
frezbo marked this conversation as resolved.
Show resolved Hide resolved
- source: /var/lib/zerotier-one/
destination: /var/lib/zerotier-one/
type: bind
options:
- bind
- rw
restart: always
logToConsole: true
ht-danielgo marked this conversation as resolved.
Show resolved Hide resolved