2020/11/27
今回できたこと
Raspberry Pi K8sクラスタのインストール作業。
FreeBSD jailで内部ネットワークインタフェースの設定を行う。
未解決
FreeBSDでjail内部からインターネットにアクセスできる設定。
今後の作業
Raspberry Pi K8sクラスタの実稼働。
お約束
この文章は、日本仮想化技術株式会社の社会人インターシップ制度を利用して作業した結果をまとめたものです。
定例作業
2020/11/26作業日報作成。
2020/11/27作業日報作成。
参考文献
復習 FreeBSD Jail: jailの基本を実習を交えて簡潔に記述している。
Raspberry Pi K8s クラスタ温度性能
現状の全クラスタノードの高負荷稼動時の温度特性を調べる。
無負荷状態は、起動してそのままの状態で、測定温度が安定するまで調べ、これを表に示した。
以下のように、各ノードで高負荷状態を作り、安定した状態の温度測定をする。
code:shell
$ stress -c 4 &
2 18435
stress: info: 18435 dispatching hogs: 4 cpu, 0 io, 0 vm, 0 hdd
$ while true; do vcgencmd measure_temp; sleep 10; done
temp=62.0'C
temp=65.0'C
temp=67.0'C
(snip)
今回のテストの結果をまとめると以下の表のようになる。
最上段のファンがかなり効いているいることがわかる。
table:温度性能
機器 hostname 段数(上から) 無負荷時温度 高負荷時温度 備考
Raspberry Pi 4B (4GB) master-rpi4 1段目 38度前後 56度強 上部にファンあり
Raspberry Pi 4B (4GB) worker-rpi4 2段目 54度前後 82度強
Raspberry Pi 3B+ worker-rpi3p 3段目 48度前後 73度強
2段目以降にも同じファンを追加することは可能であるが、上段のマシンに熱風をかけることになるので、再度温度性能評価が必要になる。
Raspberry Piの最高温度設定についてによると、最高温度85度に向かって性能を落としていくようなので、worker-rpi4に関しては性能が落ちている可能性がある。
以下のように確認すると、82-83度前後でCPUクロックが落ちていることがわかる。
code:shell
$ while true; do vcgencmd measure_temp;vcgencmd measure_clock arm; vcgencmd get_throttled;sleep 10; done
temp=82.0'C
frequency(48)=1500345728
throttled=0x20000
temp=83.0'C
frequency(48)=1000265600
throttled=0x20000
temp=82.0'C
frequency(48)=1000212864
throttled=0x20002
temp=82.0'C
frequency(48)=1500345728
throttled=0x20000
temp=83.0'C
frequency(48)=1000265600
throttled=0x20002
temp=82.0'C
frequency(48)=1000265600
Raspberry Pi でのDocker環境の構築
まだDocker環境が構築できていない master-rpi4, worker-rpi3pで、Dockerの設定を行う。
Raspberry PiでおうちKubernetes構築【論理編】の手順に従った。
code:shell
$ sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
(snip)
$ curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | sudo apt-key add -
OK
$ echo "deb arch=armhf https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
$(lsb_release -cs) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list
deb arch=armhf https://download.docker.com/linux/raspbian buster stable
$ sudo apt-get update
(snip)
$ sudo apt-get install docker-ce
(snip)
dockerコマンドをsudoを使わずに実行するために、以下のように/etc/groupを変更する。
code:/etc/group.diff
$ diff -u /etc/group{.org,}
--- /etc/group.org 2020-11-27 10:14:54.956558875 +0900
+++ /etc/group 2020-11-27 10:15:10.016213378 +0900
@@ -58,4 +58,4 @@
systemd-coredump:x:996:
rdma:x:115:
netdata:x:995:
-docker:x:994:
+docker:x:994:pi
Raspberry Piクラスタ用K8s環境の初期設定
同じく、Raspberry PiでおうちKubernetes構築【論理編】の手順に従って、K8s環境を構築する。
本来は、フルのK8sを使うか軽量なK3sを使うか選択肢はあるが、とりあえずフルのK8sを導入し、パフォーマンスの問題があった場合は、K3sを導入することとする。
code:shell
$ curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg|sudo apt-key add -
OK
$ echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kube.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
$ sudo apt-get update
(snip)
$ sudo apt-get install kubelet kubeadm kubectl
(snip)
すでにK8s環境を構築していたworker-rpi4では、以下のように実習を行なっていた作業の残りがあったため、一度K8sのリセットを行う。
これらのdockerプロセスは、K8sの自動復旧が効いているせいか、docker rmを使って停止することはできない(2020/11/10)。
code:shell
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7aaf52308230 20bc29abb875 "kube-controller-man…" 16 hours ago Up 16 hours k8s_kube-controller-manager_kube-controller-manager-worker-rpi4_kube-system_e62b2227a6ec5a736f0cde5142d3e382_30
937450f5bc33 k8s.gcr.io/pause:3.2 "/pause" 16 hours ago Up 16 hours k8s_POD_kube-controller-manager-worker-rpi4_kube-system_e62b2227a6ec5a736f0cde5142d3e382_18
2a2da68fc8d6 82bf37d955bb "kube-scheduler --au…" 16 hours ago Up 16 hours k8s_kube-scheduler_kube-scheduler-worker-rpi4_kube-system_ee4c94eb845abf1878fb3c4c489b1365_28
8b1b6d116e93 k8s.gcr.io/pause:3.2 "/pause" 16 hours ago Up 16 hours k8s_POD_kube-scheduler-worker-rpi4_kube-system_ee4c94eb845abf1878fb3c4c489b1365_20
5277b63582b0 k8s.gcr.io/pause:3.2 "/pause" 16 hours ago Up 16 hours k8s_POD_kube-apiserver-worker-rpi4_kube-system_a124ef93b19097b3b82f77f115bea234_18
d9c92253eb11 k8s.gcr.io/pause:3.2 "/pause" 16 hours ago Up 16 hours k8s_POD_etcd-worker-rpi4_kube-system_8e10a808e3a10251878719ed9a902b7d_18
現状のK8s関係はテストで使っていただけなので、一度この環境をkubeadm resetを使って削除する。
code:shell
$ sudo kubeadm reset
reset Reading configuration from the cluster...
reset FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -oyaml'
W1127 10:18:19.823086 26520 reset.go:99] reset Unable to fetch the kubeadm-config ConfigMap from cluster: failed to get config map: Get "https://192.168.3.175:6443/api/v1/namespaces/kube-system/configmaps/kubeadm-config?timeout=10s": dial tcp 192.168.3.175:6443: connect: no route to host
reset WARNING: Changes made to this host by 'kubeadm init' or 'kubeadm join' will be reverted.
reset Are you sure you want to proceed? y/N: y
preflight Running pre-flight checks
W1127 10:18:27.287132 26520 removeetcdmember.go:79] reset No kubeadm config, using etcd pod spec to get data directory
reset Stopping the kubelet service
reset Unmounting mounted directories in "/var/lib/kubelet"
reset Deleting contents of config directories: /etc/kubernetes/manifests /etc/kubernetes/pki
reset Deleting files: /etc/kubernetes/admin.conf /etc/kubernetes/kubelet.conf /etc/kubernetes/bootstrap-kubelet.conf /etc/kubernetes/controller-manager.conf /etc/kubernetes/scheduler.conf
reset Deleting contents of stateful directories: /var/lib/etcd /var/lib/kubelet /var/lib/dockershim /var/run/kubernetes /var/lib/cni
The reset process does not clean CNI configuration. To do so, you must remove /etc/cni/net.d
The reset process does not reset or clean up iptables rules or IPVS tables.
If you wish to reset iptables, you must do so manually by using the "iptables" command.
If your cluster was setup to utilize IPVS, run ipvsadm --clear (or similar)
to reset your system's IPVS tables.
The reset process does not clean your kubeconfig files and you must remove them manually.
Please, check the contents of the $HOME/.kube/config file.
docker psで確認すると、全てのコンテナが停止してることが確認できた。
code:shell
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
次回以降、実際にK8sクラスタの稼働を行う。
FreeBSD jailコンテナの実習
コンテナ型仮想化概論(内容見本PDF)にしたがって、FreeBSD jailの実習を行う。
必要に応じて、復習 FreeBSD Jailも参照した。
設定は、以下の通り。
ここで注意が必要なのは、ネットワークインタフェースが複数ある場合は、ip4.addr="wlan0|192.168.100.71";のように、明示的にネットワークインタフェース(wlan0)を指定する必要がある。
code:/etc/rc.conf
# jail
jail_enable="YES"
code:/etc/jail.conf
sample {
path= /jail/sample;
ip4.addr= "wlan0|192.168.100.71";
host.hostname= sample-jail;
allow.raw_sockets;
exec.clean;
exec.start= "/bin/sh /etc/rc";
exec.stop= "/bin/sh /etc/rc.shutdown";
mount.devfs;
}
ホストとjailとの間で通信を行うために、wlan0にalias(192.168.100.1)を設定し、jailを起動する。
code:shell
% ifconfig wlan0
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 00:13:e8:8e:96:d7
inet 192.168.3.10 netmask 0xffffff00 broadcast 192.168.3.255
groups: wlan
ssid xxxx channel 11 (2462 MHz 11g ht/20) bssid 1c:b7:96:dc:c0:09
regdomain FCC country US authmode WPA2/802.11i privacy ON
deftxkey UNDEF AES-CCM 2:128-bit txpower 30 bmiss 10 scanvalid 60
protmode CTS ampdulimit 64k ampdudensity 8 -amsdutx amsdurx shortgi
-stbc -ldpc -uapsd wme roaming MANUAL
parent interface: iwn0
media: IEEE 802.11 Wireless Ethernet MCS mode 11ng
status: associated
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
% sudo ifconfig wlan0 alias 192.168.100.1 netmask 255.255.255.0
% ifconfig wlan0
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 00:13:e8:8e:96:d7
inet 192.168.3.10 netmask 0xffffff00 broadcast 192.168.3.255
inet 192.168.100.1 netmask 0xffffff00 broadcast 192.168.100.255
groups: wlan
ssid xxxx channel 11 (2462 MHz 11g ht/20) bssid 1c:b7:96:dc:c0:09
regdomain FCC country US authmode WPA2/802.11i privacy ON
deftxkey UNDEF AES-CCM 2:128-bit txpower 30 bmiss 10 scanvalid 60
protmode CTS ampdulimit 64k ampdudensity 8 -amsdutx amsdurx shortgi
-stbc -ldpc -uapsd wme roaming MANUAL
parent interface: iwn0
media: IEEE 802.11 Wireless Ethernet MCS mode 11ng
status: associated
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
% sudo service jail start
Starting jails:sample.
jailが起動したことを確認し、jail内部に入り、ネットワークの状況を確認する。
ホスト側の192.168.100.1にpingできていることがわかる。
code:shell
% jls
JID IP Address Hostname Path
11 192.168.100.71 sample-jail /jail/sample
% sudo jexec 11 tcsh
root@sample-jail:/ # ifconfig wlan0
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 00:13:e8:8e:96:d7
inet 192.168.100.71 netmask 0xffffffff broadcast 192.168.100.71
groups: wlan
ssid xxxx channel 11 (2462 MHz 11g ht/20) bssid 1c:b7:96:dc:c0:09
regdomain FCC country US authmode WPA2/802.11i privacy ON
deftxkey UNDEF AES-CCM 2:128-bit txpower 30 bmiss 10 scanvalid 60
protmode CTS ampdulimit 64k ampdudensity 8 -amsdutx amsdurx shortgi
-stbc -ldpc -uapsd wme roaming MANUAL
parent interface: iwn0
media: IEEE 802.11 Wireless Ethernet MCS mode 11ng
status: associated
root@sample-jail:/ # ping 192.168.100.1
PING 192.168.100.1 (192.168.100.1): 56 data bytes
64 bytes from 192.168.100.1: icmp_seq=0 ttl=64 time=0.125 ms
64 bytes from 192.168.100.1: icmp_seq=1 ttl=64 time=0.112 ms
64 bytes from 192.168.100.1: icmp_seq=2 ttl=64 time=0.432 ms
^C
--- 192.168.100.1 ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.112/0.223/0.432/0.148 ms
この時、ホスト側のNICには、以下のように新たにjailのIPアドレス(192.168.100.71)のaliasが設定されている。
jail内のアドレスにpingすると、応答が帰ってくる。
code:shell
% ifconfig wlan0
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 00:13:e8:8e:96:d7
inet 192.168.3.10 netmask 0xffffff00 broadcast 192.168.3.255
inet 192.168.100.1 netmask 0xffffff00 broadcast 192.168.100.255
inet 192.168.100.71 netmask 0xffffffff broadcast 192.168.100.71
groups: wlan
ssid xxxx channel 11 (2462 MHz 11g ht/20) bssid 1c:b7:96:dc:c0:09
regdomain FCC country US authmode WPA2/802.11i privacy ON
deftxkey UNDEF AES-CCM 2:128-bit txpower 30 bmiss 10 scanvalid 60
protmode CTS ampdulimit 64k ampdudensity 8 -amsdutx amsdurx shortgi
-stbc -ldpc -uapsd wme roaming MANUAL
parent interface: iwn0
media: IEEE 802.11 Wireless Ethernet MCS mode 11ng
status: associated
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
% ping 192.168.100.71
PING 192.168.100.71 (192.168.100.71): 56 data bytes
64 bytes from 192.168.100.71: icmp_seq=0 ttl=64 time=0.113 ms
64 bytes from 192.168.100.71: icmp_seq=1 ttl=64 time=0.118 ms
64 bytes from 192.168.100.71: icmp_seq=2 ttl=64 time=0.098 ms
^C
--- 192.168.100.71 ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.098/0.110/0.118/0.008 ms
jail内部でルーティング情報を確認すると、デフォルトルートは設定されていないのがわかる。
また、手動で設定しようとしても、エラーとなる。
code:shell
root@sample-jail:/ # netstat -nr
Routing tables
Internet:
Destination Gateway Flags Netif Expire
192.168.100.71 link#3 UHS lo0
root@sample-jail:/ # route add default 192.168.100.1
route: writing to routing socket: Operation not permitted
この状態では、インターネットに出ていけない状態であるため、次はルーティング情報を与える方法を調べる必要がある。
このためには、vimageやepairを使うのだと思われる。
次回以降、jail内部からインターネットにルーティングする方法について調べる。
#diary
#Docker #Kubernetes
#FreeBSD #jail
#macOS #Linux
#RaspberryPi