0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

KubernetesやOpenvSwitchがラズパイで動かないのでググりまくった ※無事成功

Last updated at Posted at 2022-07-17

↓これ道理に進めようとしたけど kubectl get podsとか全然通らないので無茶苦茶あれこれしたので備忘録
https://phoenixnap.com/kb/install-kubernetes-on-ubuntu

openvswitch-switch.service: Job openvswitch-switch.service/start failed with result 'dependency'.
$sudo apt install qemu qemu-kvm libvirt-clients libvirt-daemon-system virtinst bridge-utils

OpenvSwitchがKubernetesの裏で働いてるみたいだけど、全然動かないからなんでかなーって思ったらこれら入ってないと動かないらしい。納得、ってかエラーメッセージわかりづらいわ!
https://askubuntu.com/questions/1225216/failed-to-connect-socket-to-var-run-libvirt-libvirt-sock

$ sudo /usr/share/openvswitch/scripts/ovs-ctl            --no-ovsdb-server --no-monitor --system-id=random --no-record-hostname  start
modprobe: FATAL: Module openvswitch not found in directory /lib/modules/5.15.0-1011-raspi
 * Inserting openvswitch module
 * not removing bridge module because bridges exist (docker0 lxdbr0)
$sudo apt install linux-modules-extra-raspi

マシンがラズパイだからか↑のようなエラーメッセージ発生
https://bugs.launchpad.net/ubuntu/+source/linux-raspi/+bug/1979846

sudo /usr/share/openvswitch/scripts/ovs-ctl            --no-ovsdb-server --no-monitor --system-id=random --no-record-hostname  start
 * Inserting openvswitch module
 * Starting ovs-vswitchd
ovs-appctl: cannot read pidfile "/usr/local/var/run/openvswitch/ovsdb-server.pid" (No such process)
 * Enabling remote OVSDB managers
$ sudo pstree -p |grep ovs
           |-ovs-testcontrol(248047)
           |-ovs-vswitchd(291520)
           |-ovsdb-server(269488)

ようやくOpenvSwitchの主要コンポネント動いた。

[ERROR FileContent--proc-sys-net-bridge-bridge-nf-call-iptables]: /proc/sys/net/bridge/bridge-nf-call-iptables does not exist
[ERROR FileContent--proc-sys-net-ipv4-ip_forward]: /proc/sys/net/ipv4/ip_forward contents are not set to 1
[ERROR FileContent--proc-sys-net-ipv6-conf-default-forwarding]: /proc/sys/net/ipv6/conf/default/forwarding contents are not set to 1

dockerを入れるのを忘れていたようで、インストール。
後ipv6のフォワーディングが設定されてないと怒られたので設定。

#apt install docker.io
#echo 1 > /proc/sys/net/ipv6/conf/default/forwarding 

--cgroup-driver=systemd をkubeletのサービスに追記
https://github.com/kubernetes/kubernetes/issues/82988#issuecomment-534626704

$sudo vim /usr/lib/systemd/system/kubelet.service

[Unit]
Description=kubelet: The Kubernetes Node Agent
Documentation=https://kubernetes.io/docs/home/
Wants=network-online.target
After=network-online.target
[Service]
ExecStart=/usr/bin/kubelet --cgroup-driver=systemd
Restart=always
StartLimitInterval=0
RestartSec=10
[Install]
WantedBy=multi-user.target

まだこれでもダメみたいだったので

$ sudo vim /var/lib/kubelet/config.yaml
address: "192.168.0.12"
port: 6443
serializeImagePulls: false
evictionHard:
    memory.available:  "200Mi"

↓なお、これを元にしたけど、エントリーの末尾の','を入れるとエラーでkubeletが動かないのでコピペで入れないよう注意
https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/

/run/flannel/subnet.env が無いよって怒られたので、該当ファイルを以下内容で作成

FLANNEL_NETWORK=10.244.0.0/16
FLANNEL_SUBNET=10.244.0.1/24
FLANNEL_MTU=1450
FLANNEL_IPMASQ=true

今度は証明書がなんか問題起こしました・・・

$ kubectl get pods 
Unable to connect to the server: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kubernetes")

↓やったらようやく通りました。。。長かった・・・

$sudo kubeadm reset
$sudo kubeadm init --pod-network-cidr=10.244.0.0/16
$mkdir $HOME/.kube
buntu@master-node:~$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
ubuntu@master-node:~$ sudo chown $(id -u):$(id -g) $HOME/.kube/config
ubuntu@master-node:~$ export KUBECONFIG=$HOME/.kube/config
ubuntu@master-node:~$ kubectl get pods --all-namespaces
NAMESPACE     NAME                                  READY   STATUS             RESTARTS       AGE
kube-system   coredns-6d4b75cb6d-5b7cg              0/1     Pending            0              80s
kube-system   coredns-6d4b75cb6d-llz97              0/1     Pending            0              80s
kube-system   etcd-master-node                      1/1     Running            2 (59s ago)    2m35s
kube-system   kube-apiserver-master-node            1/1     Running            1 (2m1s ago)   2m37s
kube-system   kube-controller-manager-master-node   0/1     Running            29 (32s ago)   34s
kube-system   kube-proxy-rbn7f                      0/1     CrashLoopBackOff   1 (12s ago)    80s
kube-system   kube-scheduler-master-node            0/1     CrashLoopBackOff   24 (11s ago)   2m33s

Worker NodeからMaster Nodeにつながる時のTokenとかどうすりゃいいんだよってわからなかったけど、以下コマンドで生成してくれる模様

$kubeadm token create --print-join-command
https://zaki-hmkc.hatenablog.com/entry/2020/04/05/103651

後は、下のはてぶの内容を途中まで実施。
https://none06.hatenadiary.org/entry/2022/05/28/025115

0
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?