安裝snap

sudo apt update
sudo apt install snapd
snap version

部署 microk8s

snap info microk8s
sudo snap install microk8s --classic
#指定版本安裝
sudo snap install microk8s --classic --channel=1.17/stable

檢查狀態及設定

microk8s.status
microk8s.docker
microk8s.config

啟動及停止

microk8s.start
microk8s.stop 

設定alias (系統無原生kubectl使用)

sudo snap alias microk8s.kubectl kubectl
#解除alias
snap unalias kubectl

常用插件啟動

#開啟
microk8s.enable dns dashboard ingress
#關閉
microk8s.disable dns dashboard ingress

開啟dashboard

token=$(microk8s kubectl -n kube-system get secret | grep default-token | cut -d " " -f1)
microk8s kubectl -n kube-system describe secret $token
microk8s kubectl port-forward --address 0.0.0.0 -n kube-system service/kubernetes-dashboard 10443:443

開啟瀏覽器將token貼入

移除microk8s

microk8s.reset
snap remove microk8s

點閱: 52