This article started on my personal blog:Using snap to build Microk8s on ubuntu, using kubectl to deploy the personal blog of zhang0peter
Recently, I am learning k8s, that is, the use of Kubernetes.
When logging in the terminal of ubuntu, the advertisement of Microk8s appears:
* Overheard at KubeCon: "microk8s.status just blew my mind". https://microk8s.io/docs/commands#microk8s.status
So I wanted to try Microk8s
Official website: MicroK8s - Fast, Light, Upstream Developer Kubernetes
Official documents for installation: Quick start | MicroK8s
By 2020-1-26, the latest version of MicroK8s is 1.17, which needs to be installed with snap. Snap is installed on ubuntu natively and runs directly:
-> % sudo snap install microk8s --classic Download snap "microk8s" (1107) from channel "stable" 0% 1B/s ages!
It can be seen that the download progress is very slow, it will take a century, but snap does not have a domestic image. Google searches snap ubuntu mirror china and finds that there is no image.
I wrote an article before: Next generation package manager: introduction and use of snap: installation, agent, disable
There are two solutions:
1. Download by proxy
2. Use snap download to download the installation package, and then transfer the file to the required machine.
I download it for installation:
-> % sudo snap download microk8s Fetching snap "microk8s" Fetching assertions for "microk8s" Install the snap with: snap ack microk8s_1107.assert snap install microk8s_1107.snap
-> % sudo snap ack microk8s_1107.assert -> % sudo snap install microk8s_1107.snap --classic Warning: /snap/bin was not found in your $PATH. If you've not restarted your session since you installed snapd, try doing that. Please see https://forum.snapcraft.io/t/9469 for more details. microk8s v1.17.0 from Canonical✓ installed
After installation, you need to add a path, otherwise an error will be reported:
root@ubuntu:/home/ubuntu# microk8s.status --wait-ready Command 'microk8s.status' is available in '/snap/bin/microk8s.status' The command could not be located because '/snap/bin' is not included in the PATH environment variable.
echo "export PATH=$PATH:/snap/bin" >> ~/.bashrc #bash source ~/.bashrc
echo "export PATH=$PATH:/snap/bin" >> ~/.zshrc #zsh source ~/.zshrc
In order to not use the root user, it is recommended to add a user group:
-> % sudo usermod -a -G microk8s $USER -> % su - $USER
Check service status:
-> # microk8s.status --wait-ready microk8s is running addons: cilium: disabled dashboard: disabled dns: disabled fluentd: disabled gpu: disabled helm: disabled ingress: disabled istio: disabled jaeger: disabled juju: disabled knative: disabled kubeflow: disabled linkerd: disabled metallb: disabled metrics-server: disabled prometheus: disabled rbac: disabled registry: disabled storage: disabled
Check kubectl status:
-> # microk8s.kubectl get nodes NAME STATUS ROLES AGE VERSION ubuntu Ready <none> 114m v1.17.0 -> # microk8s.kubectl get services NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.152.183.1 <none> 443/TCP 114m
-> # microk8s.kubectl create deployment kubernetes-bootcamp --image=gcr.io/google-samples/kubernetes-bootcamp:v1 deployment.apps/kubernetes-bootcamp created -> # microk8s.kubectl get pods NAME READY STATUS RESTARTS AGE kubernetes-bootcamp-69fbc6f4cf-ktpcm 0/1 ContainerCreating 0 38s -> # microk8s.kubectl get pods NAME READY STATUS RESTARTS AGE kubernetes-bootcamp-69fbc6f4cf-ktpcm 1/1 Running 0 3m10s
The deployment process takes about a few minutes, and it should be noted that the download requires a network.
-> # microk8s.stop Stopped. -> # microk8s.start Started. Enabling pod scheduling node/ubuntu already uncordoned
More, to be continued.