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 install and deploy Edge Computing system KubeEdge

2025-03-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article is about how to install and deploy the edge computing system KubeEdge. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

KubeEdge is an open source edge cloud computing system, which can extend native containerized business processes and device management to hosts on Edge. It has been incorporated into the CNCF system and entered the incubation stage. This article describes the process of deploying KubeEdge 1.1.0 cluster from the source code under two Ubuntu 18.04.3 LTS virtual machines. The cloud Kubernetes version is 1.16.0 Magi Golang version 1.12.4.

1. Overview

1.1 Environment

Cloud: Ubuntu 18.04.3 LTS, user name k8smaster. Ip is 192.168.179.131

Edge end: Ubuntu 18.04.3 LTS, user name k8slave1. Ip is 192.168.179.142

Components required for KubeEdge deployment: (note that this installation tutorial assumes that you have installed the K8s cluster and docker on the cloud machine, and installed docker on the edge machine)

Cloud: docker, kubernetes cluster and KubeEdge cloud core modules.

Edge end: docker, mqtt and KubeEdge edge side core module.

1.2 dependence

Golang: version 1.12.14, move to https://studygolang.com/dl download (golang is required because it is compiled by source code)

K8s version: v1.16.0

Mosquitto: install directly through apt-get

KubeEdge:v1.1.0

two。 Prepare 2.1 to create a deployment file directory

This installation method is mainly suitable for beginners, because beginners are often unfamiliar with building clusters. This article will first create a directory to store the files needed during the installation process.

Create a deployment project directory:

# mkdir / home/kkbill/kubeedge

Create a subdirectory:

# cd / home/kkbill/kubeedge# mkdir cloud edge certs yamls src

Description:

Cloud: cloud-related files, including cloudcore and configuration files.

Edge: edge-side related files, including edgecore and configuration files.

Certs: certificate file.

Yamls: some yamls files.

Src: source code directory, which stores the kubeedge source code.

2.2 KubeEdge binary

There are two ways to obtain KubeEdge, one is to download it directly from the official website (kubeedge-v1.1.0-linux-amd64.tar.gz in this experimental version), and the other is to compile it through source code. Here is an introduction to the method of compiling the source code (um, toss.)

2.2.1 Building a Golang environment

(1) download golang and decompress it

# wget https://studygolang.com/dl/golang/go1.12.14.linux-amd64.tar.gz# tar-C / usr/local-xzf go1.12.14.linux-amd64.tar.gz

(2) add environment variables

Add: at the end of the ~ / .bashrc file:

# vim ~ / .bashrcexport GOPATH=/home/kkbill/kubeedgeexport PATH=$PATH:/usr/local/go/bin

Remember to execute source ~ / .bashrc to take effect after saving. Verify:

# go version# go version go1.12.14 linux/amd64

2.2.2 download the kubeedge source code

# git clone https://github.com/kubeedge/kubeedge.git $GOPATH/src/github.com/kubeedge/kubeedge

2.2.3 detect if gcc is installed

# gcc-version

If not, install it yourself.

2.2.4 compiling the cloud

# cd $GOPATH/src/github.com/kubeedge/kubeedge/# make all WHAT=cloudcore

The generated binary cloudcore file is located in the cloud directory. Copy cloudcore and the configuration file in the same directory (conf directory) to the deployment project directory:

# cp-a cloud/cloudcore $GOPATH/cloud/# cp-a cloud/conf/ $GOPATH/cloud/

The first pit encountered during compilation is the problem with the version. Since the latest version of clone is no longer v1.1.0, we need to switch the code back to v1.1.0 as follows: (if you have no exception at this step, skip)

Under the $GOPATH/src/github.com/kubeedge/kubeedge directory, execute git tag and select v1.1.0

# git tag...v1.1.0...# git checkout v1.1.0

After executing this sentence, the code goes back to v1.1.0.

2.2.5 compilation edge

# cd $GOPATH/src/github.com/kubeedge/kubeedge/# make all WHAT=edgecore

The generated binary edgecore file is located in the edge directory. Copy the binary and configuration files to the deployment project directory:

# cp-an edge/edgecore $GOPATH/edge/# cp-an edge/conf/ $GOPATH/edge/

The second pit is encountered here, that is, the following error occurs:

/ usr/local/go/pkg/tool/linux_amd64/link: signal: killed

This is because the compilation requires a large amount of memory, and there is not enough memory, resulting in OOM. Corresponding solution: increase memory

(1) create a file to be a swap partition: increase the 1GB size of the swap partition, then the command is written as follows, where the count is equal to the number of blocks you want (bs*count= file size).

# dd if=/dev/zero of=/root/swapfile bs=1M count=1024

(2) format to swap partition file:

Mkswap / root/swapfile # build the file system of swap

(3) enable swapping partition files:

Swapon / root/swapfile # enable swap files

To solve this problem, refer to:

Https://forum.golangbridge.org/t/go-build-exits-with-signal-killed/513https://segmentfault.com/a/1190000012219689https://www.cnblogs.com/spjy/p/7085389.html2.3 generates certificate # $GOPATH/src/github.com/kubeedge/kubeedge/build/tools/certgen.sh genCertAndKey edge# cp-a / etc/kubeedge/* $GOPATH/certs

The generated ca and certs are located in the / etc/kubeedge/ca and / etc/kubeedge/certs directories, respectively, and copied to the certs directory of the deployment project directory. Note that this is performed on the cloud machine, so the cloud already has a certificate and copies it to the certs directory to facilitate distribution to edge nodes.

2.4 copy the device module and device CRD yaml file # cp? /? /? ℎ? ? / ∗ GOPATH/yamls2.5 copy node.json# cp? ? /? /? ℎ?.? /?? /? ? /? /?.? GOPATH/cloud

Interpretation: node.json is the configuration information of the node, which needs to be executed on the cloud machine, and its function is to add the edge end to the cluster (but in fact, it only lets k8s know that this node exists, not in the real sense).

2.6 configure cloud nodes

Open the configuration file $GOPATH/cloud/conf/controller.yaml, modify the value of two master, and change master to the address of k8s apiserver. In my configuration, change it to: https://192.168.179.131:6443

This address is, of course, the ip of this machine in the cloud, so how did the port come from? You can find the answer in / etc/kubernetes/manifests/kube-apiserver.yaml, as shown in the following figure:

(of course, the premise here is that you have installed kubernetes, but installing kubernetes is beyond the scope of this tutorial. )

Let me remind you that when I installed for the first time, I didn't know much about K8s and didn't know it was to check kube-apiserver.yaml, so I wrote it as http by mistake. This error took me a long time to solve.

In addition, you need to change the value of kubeconfig to: / root/.kube/config

In addition, since the edge node is called fb4ebb70-2783-42b8-b3ef-63e2fd6d242e in v1.1.0, which is not easy to read, we changed it to edge-node. Replace the values of all fb4ebb70-2783-42b8-b3ef-63e2fd6d242e with edge-node in the edge.yaml file.

In addition, it is very important to note that the value of the cgroup-driver field in this file, which is cgroupfs by default, is irresponsible for some articles that ask you to change it to sysemd without giving a specific reason. Whether you need to change the value of this field here depends on what the cgroup-driver of the docker you installed is. The principle is to keep the two always, and if they are not consistent, there will be a fatal problem.

You can view the cgroup-driver of the installed docker through the docker info command, and then decide whether to modify the value of cgroup-driver in the edge.yaml file.

I also stepped on the pit here and blindly modified the value of this field without checking during the first installation, so that the status of the final edge node is always NotReady. This problem is also discussed in the issue list, as detailed in https://github.com/kubeedge/kubeedge/issues/1243.

2.8Install mqtt

Mqtt only needs to be installed on the edge side. Since I am using the ubuntu system, I use apt-get directly, as follows:

# add-apt-repository ppa:mosquitto-dev/mosquitto-ppa / / add Source

# apt-get update / / Update

# apt-get install mosquitto / / install

3. Deployment

Now that you have the required configuration files ready, you just need to copy the certificate and the files on the edge side to the edge machine and use the scp command to copy them. (of course, you can also complete Section 2.7 above on the edge machine. )

Operating on the cloud host, 192.168.179.142 is the ip at the edge.

# ssh 192.168.179.142 "mkdir-p / etc/kubeedge / home/kkbill/kubeedge/edge" # scp-rGOPATH/ certs/* 192.168.179.142:/etc/kubeedge # scp-rGOPATH/edge/* 192.168.179.142:/home/kkbill/kubeedge/edge

Some permission deny problems may be involved here, which is caused by the scp command. It is not difficult to solve this problem by yourself.

3.1 Cloud

First, go to the deployment project directory: cd / home/kkbill/kubeedge

3.1.1 add edge end to cluster

# kubectl apply-f cloud/node.json

Note: before executing this command, be sure to modify the value of the node.json file, as follows, replace the value of the name field with the value of fb4ebb70-2783-42b8-b3ef-63e2fd6d242e with edge-node.

At this point, check the node status, and the edge end is not ready. As follows:

# kubectl get nodes NAME STATUS ROLES AGE VERSIONedge-node NotReady edge 9sk8smaster Ready master 15h v1.16.0

3.1.2 create device modules and device CRD

# kubectl apply-f yamls

Note that there are 2 yaml files in the yamls directory. If you specify the directory here, all the files in the directory will be executed automatically.

3.1.3 run cloudcore

# cd cloud#. / cloudcore

The following error may occur:

Github.com/kubeedge/kubeedge/cloud/pkg/edgecontroller/manager/secret.go:31: Failed to list * v1.Secret: Get https://192.168.179.131:6443/api/v1/secrets?limit=500&resourceVersion=0: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kubernetes")

Referring to the discussion here, https://github.com/kubernetes/kubernetes/issues/48378, I forgot how to solve this problem at that time.

3.2 Edge end

This part is carried out on the edge machine.

First, run mqtt on the edge:

# mosquitto-d-p 1883

Then go to the deployment project directory: cd / home/kkbill/kubeedge/edge, and run edgecore:

#. / edgecore3.3 verification

View status in the cloud:

# kubectl get nodesNAME STATUS ROLES AGE VERSIONedge-node Ready edge 8h v1.15.3-kubeedge-v1.1.0k8smaster Ready master 173d v1.16.0

At this point, the state of edge-node becomes Ready. At this point, the building is basically completed.

Thank you for reading! This is the end of the article on "how to install and deploy the edge computing system KubeEdge". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

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