Use Sealos to deploy Kubernetes clusters with one click

Sealos is a cloud operating system distribution with Kubernetes as the core, allowing users to use the cloud as simply as using a personal computer.

At the same time, Sealos also provides a powerful set of tools to easily manage the life cycle of the entire Kubernetes cluster.

Sealos can not only install a single-node Kubernetes development environment with one click, but also build a production high-availability cluster with thousands of nodes.

Sealos can also assemble various upper-layer distributed applications, such as databases, message queues, etc., on top of Kubernetes through cluster mirroring capabilities.

In addition, Sealos also has functions such as freely scalable clusters, backup and recovery, and release clusters. Even in an offline environment, Sealos can provide an excellent Kubernetes operating experience.

This article will teach you step-by-step how to use Sealos to deploy a Kubernetes cluster with one click, including teaching and learning.

Original link: https://forum.laf.run/d/1076

Breaking through network difficulties

First we need to download the Sealos command line tool. The Sealos command line tool can be obtained from the Release page of Sealos:

  • https://github.com/labring/sealos/releases]

There are many ways to download the Sealos command line tool, butdue to the special domestic network environment, no matter which method requires magic. Each package provided on the Reelase page is either impossible to download or extremely slow.

To break through network limitations, we first need to solve the problem of link access to the Release page.

If you know how to use magic to access, then there is no need to read the following content. The following solutions are provided for students who do not know magic.

This requires the use of a browser plug-in: Violentmonkey. You can also install Tampermonkey. They are all user script managers and cannot play any role for us. They mainly rely on extension scripts (JavaScript code) written by major communities to run on the browser to change the functions of the visited web pages and improve our web browsing experience.

I recommend using Violentmonkey, which is lighter and updates more frequently. Let’s install it next.

Install browser plug-in

As we all know, the Chrome browser plug-in needs to be downloaded from the Chrome Web App Store, but you need to turn on magic to access this website. We need to find another way.

Method 1

The Edge browser produced by Microsoft comes with an extension store page, and this page is directly accessible. You can choose to use the Edge browser, and then open the Edge browser’s extension store:

  • https://microsoftedge.microsoft.com/addons/Microsoft-Edge-Extensions-Home]

Then search for violentmonkey and click Get to start the installation:

Method 2

For the Chrome browser, or other Chromium-based browsers, we can obtain Violentmonkey’s crx file from many Chrome App Store mirror sites. Here is a mirror site recommended:

  • https://crxdl.com/

Click to download the latest version:

After downloading and decompressing, you will get a xxx.crx file. You need to open the browser’s settings, open the extensions page, or directly search Chrome://extensions/ Enter. Then keep the pageDeveloper modeen on. Find the unzipped crx file, drag it to the Extensions page, release and agree to complete the installation.

GitHub enhanced script acquisition

The Violentmonkey plug-in implements functions by running user scripts. With the help of user scripts, various powerful functions can be realized. Here we need to install a GitHub enhancement script. This script will provide multiple CDN addresses for the files on the GitHub Release page. We can download files through the CDN addresses, no magic required.

The installation of the script is very simple and brainless. Just open this link in your browser:

  • https://cdn.jsdelivr.us/gh/XIU2/UserScript@master/GithubEnhanced-High-Speed-Download.user.js

Then click to confirm the installation:

After the installation is complete, click Close.

Open the settings page of the Violentmonkey extension and click the icon pointed by the arrow to open the script:

Add a line: // @match *://githubfast.com/*, then click Save and close.

Download Sealos command line tool

Now we open the Release page of Sealos: https://github.com/labring/sealos/releases. Given that GitHub will have convulsions from time to time, making it inaccessible. We can add fast after any github link, which is githubfast.com to access the GitHub page. For example the Release page can be accessed via the following link:

  • https://githubfast.com/labring/sealos/releases

There are many Sealos versions here. It is recommended to use the official version instead of downloading the alpha version or rc version. You can directly use the latest official version, which can be accessed through the following link:

  • https://github.com/labring/sealos/releases/latest

Now you can see that there are multiple CDN links provided behind each file. You only need to put the mouse on one of the links and then right-click to copy the CDN link.

This repository also provides multiple GitHub mirror websites: https://githubfast.com/runningcheese/MirrorSite

Binary download

Because the Sealos command line tool only has a binary file, all Linux distributions have the option to directly download the binary file to use the Sealos command line tool.

For x86 architecture, you can choose to download sealos_xxx_linux_amd64.tar.gz. Remember to use the CDN link on the right to download.

Once you have the CDN link, use the following command to start the download:

$ URL=<your CDN link>
$ wget $URL & amp; & amp; tar zxvf sealos_*_linux_amd64.tar.gz sealos & amp; & amp; chmod + x sealos & amp; & amp; mv sealos /usr/bin

You can try a few more links to find a faster link.

have a test:

$ sealos version
SealosVersion:
  buildDate: "2023-10-09T10:07:15Z"
  compiler: gc
  gitCommit: 881c10cb
  gitVersion: 4.3.5
  goVersion: go1.20.8
  platform: linux/amd64

Similarly, you can download sealos_xxx_linux_arm64.tar.gz for arm64 architecture.

Package management tool installation

Sealos also provides DEB packages and RPM packages. For Debian/Ubuntu systems or Centos/RHEL systems, you can choose to use the package management tool to install them.

Taking Ubuntu as an example, for x86 architecture, you can choose to download sealos_xxx_linux_amd64.deb. After the download is complete, you can install it using the package management tool. The command is as follows:

$ URL=<your CDN link>
$ wget $URL & amp; & dpkg -i sealos_*_linux_amd64.deb

For Centos/RHEL systems, you can use the following command:

$ URL=<your CDN link>
$ wget $URL & amp; & yum localinstall -y sealos_*_linux_amd64.rpm

Install Kubernetes cluster

Finally getting to the point, let’s start the formal installation of the Kubernetes cluster.

Here are some basic installation requirements:

  • Each cluster node should have a different hostname. Do not use underscores in the hostname.
  • The time of all nodes needs to be synchronized.
  • You need to run the sealos run command on the first master node of the Kubernetes cluster. Currently, nodes outside the cluster do not support cluster installation.
  • It is recommended to use a clean operating system to create the cluster. Don’t install Docker yourself!
  • Supports most Linux distributions, such as: Ubuntu, CentOS, Rocky linux.
  • All Kubernetes versions in Docker Hub are supported.
  • Support for using Containerd as a container runtime.
  • Please use Private IP when installing on public cloud.

Before the formal installation, let’s briefly understand a unique concept in Sealos: Cluster Mirroring.

Sealos absorbs the essence of Docker’s ideas, and derives Docker’s ideas to the cluster dimension to realize the construction, packaging, delivery, operation, etc. of distributed software.

Similar to operating system ISO images or Docker images, a cluster image is a resource package that uses certain technical means to package all the files of the entire cluster into a certain format.

Taking the Kubernetes cluster image as an example, it contains all files except the operating system:

  • Containerd relies on binaries and systemd configuration, Containerd configuration, and a private container image repository.
  • Kubernetes core component binaries, container images, kubelet system configuration, etc.
  • All dependencies required for the application to run, such as other scripts, configurations, and binary tools.

The packaging format of the cluster image is compatible with the OCI standard and can be pushed directly to the Docker image warehouse. When installing the cluster, you only need to use the sealos pull command to pull the image from the mirror warehouse, and then execute the sealos run command, and the entire Kubernetes cluster will be installed. . .

Docker solves the problem of mirroring a single container, and Sealos enables distributed software to be built in one place and run anywhere by packaging the entire cluster.

Due to the limited space of this article, I will not introduce the specific principles of cluster mirroring. I will write an article later when I have the opportunity. Interested students can refer to Sealos’ official documentation:

  • https://sealos.run/docs/category/advanced-guide-1

Cluster image version support instructions

It is recommended to use Containerd as the cluster image version of the Container Runtime (CRI). Containerd is a lightweight, high-performance container runtime that is compatible with Docker. Kubernetes images using Containerd can provide higher performance and resource utilization. The following are support instructions for cluster image versions that support Containerd:

K8s version Sealos version CRI version Cluster image version
<1.25 >=v4.0.0 v1alpha2 labring/kubernetes:v1.24.0
>=1.25 >=v4 .1.0 v1alpha2 labring/kubernetes:v1.25.0
>=1.26 >=v4.1.4-rc3 v1 labring/kubernetes:v1.26.0
>=1.27 >=v4.2.0-alpha3 v1 labring/kubernetes:v1.27.0

Depending on the Kubernetes version, you can choose different Sealos versions and CRI versions. For example, if you want to use Kubernetes v1.26.0 version, you can select sealos v4.1.4-rc3 and higher and use the v1 CRI version.

Of course, you can also choose to use Docker as the container runtime. The following are the support instructions for cluster image versions that support Docker:

K8s version Sealos version CRI version Cluster image version
<1.25 >=v4.0.0 v1alpha2 labring/kubernetes-docker:v1.24.0
>=1.25 > =v4.1.0 v1alpha2 labring/kubernetes-docker:v1.25.0
> =1.26 >=v4.1.4-rc3 v1 labring/kubernetes-docker:v1. 26.0
>=1.27 >=v4.2.0-alpha3 v1 labring/kubernetes-docker:v1.27.0

Similar to Kubernetes images that support Containerd, you can choose different Sealos versions and CRI versions depending on the Kubernetes version. For example, if you want to use Kubernetes v1.26.0 version, you can select sealos v4.1.4-rc3 and higher and use the v1 cri version.

View cluster image

All Sealos cluster images can be found in this repository:

  • https://github.com/labring-actions/cluster-image-docs

In addition to being pushed to Docker Hub, these images are also synchronized to Alibaba Cloud's image warehouse. You can view all Sealos cluster images on Docker Hub through the following link:

  • https://hub.docker.com/u/labring

But there are too many cluster images. If I want to see all versions of the Kubernetes cluster image, is there a more efficient way to view it?

This requires the use of a tool called Registry Explorer, the link is as follows:

  • https://explore.ggcr.dev/

Directly enter registry.cn-shanghai.aliyuncs.com/labring/kubernetes, and then click “Submit Query”:

You will see all the tags of this cluster image.

The same applies to Docker Hub. Enter docker.io/labring/kubernetes to view all tags.

Install the cluster

The higher the Kubernetes minor version number, the more stable the cluster is. For example, v1.28.x, where x is the minor version number. It is recommended to use a Kubernetes version with a higher minor version number. As of the deadline of this article, the highest version number of v1.27 is v1.27.7, and the highest version number of v1.28 is v1.28.3, so it is recommended to use v1.27.7. You need to choose the best Kubernetes version based on your actual situation, do not copy this article.

It is recommended to use Containerd as the runtime, which is the cluster image labring/kubernetes. If you must use Docker as the runtime, you can use the cluster image labring/kubernetes-docker.

If you only have one node, you can install it using the following command:

$ sealos run registry.cn-shanghai.aliyuncs.com/labring/kubernetes:v1.27.7 registry.cn-shanghai.aliyuncs.com/labring/helm:v3.9.4 registry.cn-shanghai.aliyuncs.com/ labring/cilium:v1.13.4 --single

Remember to check the latest version numbers of helm and cilium through Registry Explorer.

If you have multiple nodes, you can install them using the following command:

$ sealos run registry.cn-shanghai.aliyuncs.com/labring/kubernetes:v1.27.7 registry.cn-shanghai.aliyuncs.com/labring/helm:v3.9.4 registry.cn-shanghai.aliyuncs.com/ labring/cilium:v1.13.4 \
     --masters <master1's IP>,<master2's IP>,... \
     --nodes <node1's IP>,<node1's IP>,... -p [your-ssh-passwd]

For example, suppose you have two nodes. The IP of the master node is 192.168.64.10 and the IP of the node is 192.168.64.11. The command is as follows:

$ sealos run registry.cn-shanghai.aliyuncs.com/labring/kubernetes:v1.27.7 registry.cn-shanghai.aliyuncs.com/labring/helm:v3.9.4 registry.cn-shanghai.aliyuncs.com/ labring/cilium:v1.13.4 \
     --masters 192.168.64.10 \
     --nodes 192.168.64.11 -p [your-ssh-passwd]

Gone. Just wait quietly for the installation to complete. After the installation is complete, you can use the following command to check the cluster status:

$ kubectl get node
NAME STATUS ROLES AGE VERSION
ycs-master-1 Ready control-plane 18h v1.27.7
ycs-node-1 Ready <none> 18h v1.27.7

$ kubectl -n kube-system get pod
NAME READY STATUS RESTARTS AGE
cilium-fmgcw 1/1 Running 1 (48m ago) 18h
cilium-operator-86666d88cb-6h5kx 1/1 Running 1 (52m ago) 18h
cilium-skggs 1/1 Running 0 18h
coredns-5d78c9869d-j4kkj 1/1 Running 0 18h
coredns-5d78c9869d-snlt7 1/1 Running 0 18h
etcd-ycs-master-1 1/1 Running 9 18h
kube-apiserver-ycs-master-1 1/1 Running 9 18h
kube-controller-manager-ycs-master-1 1/1 Running 9 18h
kube-proxy-g45vv 1/1 Running 0 18h
kube-proxy-vz4dk 1/1 Running 1 (48m ago) 18h
kube-scheduler-ycs-master-1 1/1 Running 9 18h
kube-sealos-lvscare-ycs-node-1 1/1 Running 10 (48m ago) 18h
metrics-server-84c9bd846f-mwfbx 1/1 Running 0 47m

Principle of image distribution

Sealos does not copy the image to all nodes during the installation of Kubernetes, but uses a more elegant solution. Sealos will start a private image warehouse on the first master node (the first master node refers to the address of the first master node entered when creating the cluster), and then synchronize the registry directory in the Kubernetes cluster image to the private image. In the warehouse.

At the same time, each node will run an image-cri-shim daemon, and kubelet will initiate a grpc interactive command to image-cri-shim when pulling the image. The process will search the private repository based on the image name. If the image exists, it will be pulled from the local image repository, otherwise it will be pulled from the remote end.

This perfectly solves the image distribution problem.

For detailed principles, please refer to the relevant documentation of the Sealos mirror warehouse:

  • https://sealos.run/docs/self-hosting/lifecycle-management/operations/registry/