Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Short script to automatically register a new Kubernetes node with the ZeroTier One API
set -e
[ -z ${ZT_API_TOKEN} ] && echo "Missing API token" && exit 1
[ -z ${ZT_NETWORK_ID} ] && echo "Missing network ID" && exit 1
which zerotier-cli # Check whether the zerotier-cli is installed...
if [ $? -ne 0 ]; then
curl -s '' | gpg --import && \
if z=$(curl -s '' | gpg); then echo "$z" | sudo bash; fi
nodeID=$(sudo zerotier-cli info | awk '{print $3}')
# Send request to preauthorize this node on our network
curl \
-H "Authorization: Bearer ${ZT_API_TOKEN}" \
-d "{\"name\":\"$(curl -s\",\"config\":{\"authorized\":true}}" \
sleep 1
sudo zerotier-cli join ${ZT_NETWORK_ID}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment