Skip to content

Commit 96727f2

Browse files
committed
feature: automatically insert tailscale ip as node ip, and auto setup CPU pinning
1 parent 9527ca5 commit 96727f2

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

src/game-server-node/game-server-node.controller.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,39 @@ export class GameServerNodeController {
223223
echo "Installing k3s";
224224
curl -sfL https://get.k3s.io | K3S_URL=https://${process.env.TAILSCALE_NODE_IP}:6443 K3S_TOKEN=${process.env.K3S_TOKEN} sh -s - --node-name ${gameServerNodeId} --vpn-auth="name=tailscale,joinKey=${game_server_nodes_by_pk.token}";
225225
226+
echo "Waiting for Tailscale IP";
227+
228+
for i in {1..30}; do
229+
TS_IP=$(tailscale ip -4 2>/dev/null | head -n 1)
230+
if [ -n "$TS_IP" ]; then
231+
break
232+
fi
233+
sleep 2
234+
done
235+
236+
if [ -z "$TS_IP" ]; then
237+
echo "ERROR: Tailscale IP not assigned"
238+
exit 1
239+
fi
240+
241+
echo "Tailscale IP acquired: $TS_IP"
242+
243+
mkdir -p /etc/rancher/k3s
244+
245+
rm -f /etc/rancher/k3s/config.yaml
246+
247+
cat <<-EOF >/etc/rancher/k3s/config.yaml
248+
node-ip: $TS_IP
249+
250+
kubelet-arg:
251+
- "cpu-manager-policy=static"
252+
- "cpu-manager-reconcile-period=5s"
253+
- "system-reserved=cpu=1"
254+
- "kube-reserved=cpu=1"
255+
EOF
256+
257+
systemctl restart k3s-agent
258+
226259
mkdir -p /opt/5stack/demos
227260
mkdir -p /opt/5stack/steamcmd
228261
mkdir -p /opt/5stack/serverfiles

0 commit comments

Comments
 (0)