#author("2023-09-01T10:56:53+09:00","default:nobuoki","nobuoki") #author("2023-09-01T11:02:18+09:00","default:nobuoki","nobuoki") * 想定環境 [#d6498786] - UbuntuのVMを2つ立てて、k3sで運用する - VMのNICが複数あって、k3sの通信アドレスを固定したい - VM同士はsshでパスワード不要で接続できる(鍵認証など) * 手順 [#pdb4f3eb] マスター側のVMですべて操作 #prism(bash){{{ 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 ... }}} * 参考 [#h0ff77db] - [[ラズパイでK8s…は重そうなのでK3sしてみた話>https://zenn.dev/kuma3303/articles/21d5725a94fcc1]] - [[Quick-Start Guide | K3s>https://docs.k3s.io/quick-start]] - [[error: error loading config file "/etc/rancher/k3s/k3s.yaml": open /etc/rancher/k3s/k3s.yaml: permission denied を解消する - /var/www/yatta47.log>https://yatta47.hateblo.jp/entry/2020/01/09/090000]] * さらに・・・ [#jcf8480b] helm入れる(masterで実行) - [[Helm | クイックスタートガイド>https://helm.sh/ja/docs/intro/quickstart/]] - [[Raspberry pi に k3s と helm 入れるのに四苦八苦 - Qiita>https://qiita.com/TakashiAihara/items/511979d08a791e3c76d9]] #prism(bash){{{ eval $(echo export KUBECONFIG=/etc/rancher/k3s/k3s.yaml | tee -a ~/.bashrc) #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 }}}