-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: tailscale correct node destroy
- Loading branch information
1 parent
c53aad0
commit a65fbd0
Showing
26 changed files
with
434 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
{ | ||
lib, | ||
pkgs, | ||
manifests ? [] | ||
manifest, | ||
... | ||
} : | ||
{ | ||
script = "mkdir -p /var/lib/rancher/k3s/server/manifests;" + | ||
lib.strings.concatMapStrings (manifest: | ||
with manifest; | ||
let namespaceExpr = if namespace != "" then "-n ${namespace}" else ""; in | ||
'' | ||
cp -fp ${file} /var/lib/rancher/k3s/server/manifests; | ||
${pkgs.k3s}/bin/kubectl wait --for='${condition}' ${toWait} ${namespaceExpr} --timeout=2m; | ||
'' | ||
) manifests; | ||
with manifest; | ||
let namespaceExpr = if namespace != "" then "-n ${namespace}" else ""; | ||
in { | ||
script = '' | ||
mkdir -p /var/lib/rancher/k3s/server/manifests; | ||
cp -fp ${file} /var/lib/rancher/k3s/server/manifests; | ||
sleep 30; | ||
${pkgs.k3s}/bin/kubectl wait --for='${condition}' ${toWait} ${namespaceExpr} --timeout=2m; | ||
''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
ENDPOINT=${ENDPOINT:-https://api.tailscale.com} | ||
API_KEY=$(curl -s -d "client_id=$OAUTH_CLIENT_ID" -d "client_secret=$OAUTH_CLIENT_SECRET" \ | ||
"${ENDPOINT}/api/v2/oauth/token" | jq -r '.access_token') | ||
NODE_HOSTNAMES=${NODE_HOSTNAMES:-} | ||
|
||
IFS=',' read -ra ADDR <<< "$NODE_HOSTNAMES" | ||
for NODE_HOSTNAME in "${ADDR[@]}"; do | ||
|
||
curl -s "${ENDPOINT}/api/v2/tailnet/$TAILNET/devices" -u "$API_KEY:" | jq -r '.devices[] | "\(.id) \(.name)"' | | ||
while read -r id name; do | ||
if [[ $name = *"$NODE_HOSTNAME.$TAILNET"* ]] | ||
then | ||
echo "$name matching $NODE_HOSTNAME.$TAILNET - getting rid of $id" | ||
curl -s -X DELETE "${ENDPOINT}/api/v2/device/$id" -u "$API_KEY:" | ||
else | ||
echo "$name not matching $NODE_HOSTNAME.$TAILNET, keeping it" | ||
fi | ||
done | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.