マスター側のVMですべて操作
m=192.168.33.11 # IPアドレス of マスターVM
a=192.168.33.12 # IPアドレス of エージェントVM
u="https://$m:6443" # マスターのエンドポイント
# マスター構築
sudo ufw disable
curl -sfL https://get.k3s.io | sh -s - --write-kubeconfig-mode 644 --node-ip=$m
# エージェント接続用トークン取得
t=$(sudo cat /var/lib/rancher/k3s/server/node-token | tee /dev/stderr)
# ssh経由でエージェント構築
ssh $a sh -x <<...
sudo ufw disable
curl -sfL https://get.k3s.io | K3S_URL=$u K3S_TOKEN=$t sh -s - --node-ip=$a
...
helm入れる(masterで実行)
#eval $(echo export KUBECONFIG=/etc/rancher/k3s/k3s.yaml | tee -a ~/.bashrc) # これだと helm version でエラーが出る
mkdir ~/.kube 2>/dev/null; sudo cat /etc/rancher/k3s/k3s.yaml >~/.kube/config; chmod 600 ~/.kube/config
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash -x