Microk8s up and running with ubuntu 18.04 fresh install
3 min readDec 3, 2020
在 ubuntu 18.04 server edition 安裝時, 選擇 Microk8s. (或是照這個官方文件安裝)
記得關掉 swap
ubuntu@ubuntu_server:~$ sudo swapoff -a
檢查 Microk8s 狀態, 咦, 怎麼沒權限. 照著提示設定一下 user 的 Microk8s group 權限
ubuntu@ubuntu_server:~$ microk8s status
Insufficient permissions to access MicroK8s.
You can either try again with sudo or add the user ubuntu to the ‘microk8s’ group:sudo usermod -a -G microk8s ubuntu
sudo chown -f -R ubuntu ~/.kubeThe new group will be available on the user’s next login.ubuntu@ubuntu_server:~$ sudo usermod -aG sudo ubuntu
還是沒跑起來, 乖乖用 ispect 看一下有沒有進一步 log
ubuntu@ubuntu_server:~$ microk8s statusmicrok8s is not running. Use microk8s inspect for a deeper inspection.ubuntu@ubuntu_server:~$ microk8s inspect...(skipped)
WARNING: This machine’s hostname contains capital letters and/or underscores.
This is not a valid name for a Kubernetes node, causing node registration to fail.
Please change the machine’s hostname or refer to the documentation for more details:
https://microk8s.io/docs/troubleshooting#heading--common-issues
Building the report tarball
Report tarball is at /var/snap/microk8s/1791/inspection-report-20201202_163221.tar.gz
原來是 hostname ubuntu_server
不符合 Kubernetest node naming
ubuntu@ubuntu_server:~$ hostname
ubuntu_server
ubuntu@ubuntu_server:~$ hostnamectl
Static hostname: ubuntu_server
設定一下 reboot
ubuntu@ubuntu_server:~$ sudo hostnamectl set-hostname testServer
ubuntu@ubuntu_server:~$ sudo vim /etc/hosts
ubuntu@ubuntu_server:~$ sudo reboot now
收工
ubuntu@testServer:~$ microk8s status
microk8s is running