進捗¶
- VM作成:🔴
- STNS:🔴4/3完了
- k3s:△
- kubectl の config:✖
VM作成¶
構成: マスターノード1台 ワーカーノード2台
VM作成方法: https://cdsl-tut.esa.io/wiki/491#4.%20Ubuntu%EF%BC%88ubuntu-20.04.2%EF%BC%89%20%E3%81%AE%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB-%E3%81%8A%E3%81%BE%E3%81%91 VMの情報は以下のリンク: https://docs.google.com/spreadsheets/d/1ueNWYsETszUv5JIVIq1Wq6FCd7U5RTVvofBo7QivGsw/edit#gid=0 各VMリソース: - CPU:3(Core) - Memory:16(GB) - SSD:64(GB)
UbuntuにSTNS clientをインストールする¶
STNS Clientの設定: https://cdsl-tut.esa.io/wiki/449 作成した各VMに以下のshellscriptファイルを作成し、実行した。 しかし現状STNSによる鍵なしでのsshはできていない。
#!/bin/bash
set -eux
curl -fsSL https://repo.stns.jp/scripts/apt-repo.sh | sed "s:apt-key add -:tee /etc/apt/trusted.gpg.d/stns.asc:" | sh
sudo apt install -y stns-v2 libnss-stns-v2 cache-stnsd
sudo cp /etc/stns/client/stns.conf{,.org}
cat <<EOF | sudo tee /etc/stns/client/stns.conf
api_endpoint = "http://192.168.100.25:31104/v1"
[cached]
enable = true
EOF
sudo service cache-stnsd restart
sudo systemctl enable cache-stnsd
sudo sed -i "s/passwd: files systemd/passwd: compat stns systemd/" /etc/nsswitch.conf
sudo sed -i "s/group: files systemd/group: compat stns systemd/" /etc/nsswitch.conf
sudo sed -i "s/shadow: files/shadow: compat stns/" /etc/nsswitch.conf
sudo sed -i "s/#PubkeyAuthentication yes/PubkeyAuthentication yes/" /etc/ssh/sshd_config
sudo sed -i "s|#AuthorizedKeysCommand none|AuthorizedKeysCommand /usr/lib/stns/stns-key-wrapper|" /etc/ssh/sshd_config
sudo sed -i "s/#AuthorizedKeysCommandUser nobody/AuthorizedKeysCommandUser root/" /etc/ssh/sshd_config
sudo service sshd restart
echo 'session required pam_mkhomedir.so skel=/etc/skel/ umask=0022' | sudo tee -a /etc/pam.d/sshd
sudo sed -i '$ a %cdsl ALL=(ALL:ALL) NOPASSWD:NOPASSWD:ALL' /etc/sudoers
k3sクラスター作成¶
https://k3s.io/ 現状うまくできたかどうかはまだわかってない。 1. マスターノード(k3sを実行するVM)にする予定のVMで以下のコマンドを順に実行する。 - https://get.k3s.io からスクリプトをダウンロードし、シェルに渡して実行
$ curl -sfL https://get.k3s.io | sh -
$ cat /var/lib/rancher/k3s/server/node-token
$ hostname -I
$ curl -sfL https://get.k3s.io | K3S_URL=https://〇〇〇:6443 K3S_TOKEN=△△△ sh -
Kubectlコマンドインストール(事前済)¶
https://qiita.com/tororoMeshi/items/07049c18f91d8eebcbdc
Kubectl config¶
現状うまくいってない configのある場所参考: https://cdsl-tut.esa.io/wiki/1585 - ノードにssh後、以下のコマンドを実行する。k3s.yamlが各ノードのconfigである。 ※k3s.yamlは好きな名前にしておっけ
$ cd /etc/rancher/k3s
$ hostname -I
$ export KUBECONFIG=~/.kube/[configファイル名]