Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to get started with MicroK8s

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

How to get started with MicroK8s, I believe that many inexperienced people are at a loss about it. Therefore, this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

MiroK8s is the smallest and fastest cluster system that is fully compatible with Kubernetes. It is mainly used for workstations and small teams. However, the image is not packaged with snap and is still on gcr.io. There are still problems with domestic downloads. MicroK8s is suitable for offline development, prototyping, and testing, especially running VM as a small, cheap, reliable k8s for CI/CD. It supports arm architecture and is also suitable for developing IoT applications, which can be deployed to small Linux devices through MicroK8s.

Operation environment

Operating system Ubuntu 18.04LTS or 16.04LTS environment (or other snapd-enabled operating system-see the snapd documentation).

At least 20g of disk space, (recommended) 4G of memory.

Internet connection (need to be able to access gcr.io)

Note: if you do not have the above hardware environment, other ways to install MicroK8s, including other operating systems and offline deployment, refer to the alternative install page.

Install MicroK8s

MicroK8s will install a lightweight Kubernetes that can be used on any machine. Install via snap, as follows:

Sudo snap install microk8s-classic-channel=1.17/stable

For more information on how to set up, refer to: channel >

Raspberry Pi/ARM

Running MicroK8s on some ARM hardware may run into difficulties because cgroups (required!) Are not enabled by default. This can be remedied on the Rasberry Pi by editing the boot parameters:

Sudo vi / boot/firmware/nobtcmd.txt

Note:In older Raspberry Pi versions the boot parameters are in / boot/firmware/cmdline.txt.

Plus:

Cgroup_enable=memory cgroup_memory=1 add group

MicroK8s creates a group for commands operations, which requires admin permission. Add as follows:

Sudo usermod-a-G microk8s $USER

You need to reopen the current console:

Su-$USER check status

MicroK8s has built-in command display status. The parameter, wait-ready, is used during installation to wait for Kubernetes services to initialize.

Microk8s.status-wait-ready visits Kubernetes

MicroK8s binds its own version of kubectl to access the Kubernetes cluster.

Microk8s.kubectl get nodes

View services:

Microk8s.kubectl get services

MicroK8s uses namespaced kubectl commands to prevent conflicts with other kubectl installations. If there is no other installation, you can also add an alias (append to ~ / .bash_aliases), such as:

Alias kubectl='microk8s.kubectl' deploys applications

Use the kubectl command to access Kuberenetes, such as (switch to other images in China, because gcr.io cannot access them):

Microk8s.kubectl create deployment kubernetes-bootcamp-image=gcr.io/google-samples/kubernetes-bootcamp:v1

Check status:

Microk8s.kubectl get pods

It is much easier to deploy applications using helm, and it is convenient to deploy large applications. However, I haven't tried it in MicroK8s yet, and I don't know if it's all compatible.

Reference for Helm usage:

Helm hub, https://hub.helm.sh

Introduction to Helm 3, https://www.oschina.net/news/111342/helm-3-0-released

Helm source code, https://github.com/helm/helm

Use add-ons

MicroK8s uses as few lightweight Kubernetes components as possible. But through "add-ons" >

There are still some problems with KubeFlow support:

The current KubeFlow0.7.1 can only support the following versions of Kubernetes1.16, but version 1.16 of MicroK8s does not have the integration of KubeFlow. There are still some problems with running KubeFlow in version 1.16 of K8s and above.

Reference: KubeFlow- deployment and application in Microk8s

It is recommended to add DNS management to facilitate the communication of services. For applications that need to be stored, 'storage' add-on provides directory space for the host. It is easier to set up:

Microk8s.enable dns storage

For a complete list of plug-ins, refer to:

See the full list of addons >

Start and stop MicroK8s

MicroK8s will run all the time, using the following command to start or stop:

Microk8s.stop

... MicroK8s and its services will be stopped. You can start it again, using:

Microk8s.start about Services

In MicroK8s, containers such as apiserver are no longer started by kubelet, but all apiserver/scheduler/controller-manager is managed by systemd, and containers are managed by containerd (not docker). You can view container-related information through microk8s.ctr.

Services:

Ubuntu@ubuntu:/etc/systemd/system$ ls-1 root root Apr 8 10:38 snap-microk8s-1295.mount-rw-r--r-- 1 root root 509 Apr 8 10:38 snap.microk8s.daemon-apiserver-kicker.service-rw-r--r-- 1 root root 488 Apr 8 10:38 snap.microk8s.daemon-apiserver.service-rw-r--r-- 1 root root 500 Apr 8 10:38 snap.microk8s.daemon-cluster- Agent.service-rw-r--r-- 1 root root 491 Apr 8 10:38 snap.microk8s.daemon-containerd.service-rw-r--r-- 1 root root 515 Apr 8 10:38 snap.microk8s.daemon-controller-manager.service-rw-r--r-- 1 root root 473 Apr 8 10:38 snap.microk8s.daemon-etcd.service-rw-r--r-- 1 root root 485 Apr 8 10:38 snap.microk8s.daemon-flanneld.service-rw-r--r -- 1 root root 482 Apr 8 10:38 snap.microk8s.daemon-kubelet.service-rw-r--r-- 1 root root 476 Apr 8 10:38 snap.microk8s.daemon-proxy.service-rw-r--r-- 1 root root 488 Apr 8 10:38 snap.microk8s.daemon-scheduler.service

View information about the service:

Ubuntu@ubuntu:/etc/systemd/system$ sudo systemctl status snap.microk8s.daemon-kubelet ● snap.microk8s.daemon-kubelet.service-Service for snap application microk8s.daemon-kubelet Loaded: loaded (/ etc/systemd/system/snap.microk8s.daemon-kubelet.service; enabled; vendor preset: enabled) Active: active (running) since Thu 2020-04-16 11:35:59 UTC 30ms ago Main PID: 18351 (snap) Tasks: 6 (limit: 4441) CGroup: / system.slice/snap.microk8s.daemon-kubelet.service └─ 18351 / usr/bin/snap run microk8s.daemon-kubeletApr 16 11:35:59 ubuntu systemd [1]: Started Service for snap application microk8s.daemon-kubelet.

View container information:

Ubuntu@ubuntu:/etc/systemd/system$ sudo microk8s.ctrNAME: ctr-_ _ / / _ / _ / / _ _ /\ _ _ /\ _ _ / / containerd CLIUSAGE: ctr [global options] command [command options] [arguments...] VERSION: v1.2.5COMMANDS: plugins Plugin provides information about containerd plugins version print the client and server versions containers, c, container manage containers content manage content events, event display containerd events images, image, i manage images leases manage leases namespaces Namespace manage namespaces pprof provide golang pprof outputs for containerd run run a container snapshots, snapshot manage snapshots tasks, t, task manage tasks install install a new package shim interact with a shim directly cri interact with cri plugin help H Shows a list of commands or help for one commandGLOBAL OPTIONS:-- debug enable debug output in logs-- address value,-a value address for containerd's GRPC server (default: "/ run/containerd/containerd.sock")-- timeout value total timeout for ctr commands (default: 0s)-- connect-timeout value timeout for connecting to containerd (default: 0s)-- namespace value -n value namespace to use with commands (default: "default") [$CONTAINERD_NAMESPACE]-- help,-h show help-- version,-v print the version

Where images and containers correspond to docker's images and ps commands, respectively.

After reading the above, have you mastered how to get started with MicroK8s? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report