Edged:一个运行在 edge 节点的 agent 程序,管理边缘的容器化应用程序
EdgeHub:边缘的通信接口模块。这是一个 Web 套接字客户端,负责边缘计算与云服务的交互。包括同步云端资源到边缘端,以及报告边缘端 host 和 device 状态到云端
CloudHub:云端通讯接口模块。一个 Web 套接字服务器,负责监视云端的更改、缓存以及向 EdgeHub 发送消息
EdgeController:管理边缘节点。它是一个扩展的 Kubernetes 控制器,管理边缘节点和 pod 元数据,以便数据可以面向特定的边缘节点
EventBus:使用 MQTT 处理内部边缘通信。MQTT 客户端与 MQTT 服务器(mosquitto)交互,为其他组件提供发布和订阅功能
DeviceTwin:处理设备元数据的设备软件镜像。该模块有助于处理设备状态并将其同步到云上。它还为应用程序提供查询接口,它连接到一个轻量级数据库(SQLite)
MetaManager:管理边缘节点上的元数据。这是 Edged 和 Edgehub 之间的消息处理器。负责在轻量级数据库(SQLite)中存储 / 检索元数据
kubeEdge 包括 cloud 和 edge 部分,在 kubernetes 构建,在 cloud 与 edge 端提供核心的基础支持,比如网络,应用,部署以及元数据的同步等。
安装kubeEdge 需要安装 kubernetes 集群,cloud 与 edge 部分
Install docker on cloud and edge side (you can also run other runtime, such as containerd)
Install kubeadm/kubectl on cloud side
Creating kubernetes cluster with kubeadm on cloud side
Go The minimum required go version is 1.12. You can install this version by using this website.
Install mosquitto on every edge side
git clone https://github.com/kubeedge/kubeedge.git $GOPATH/src/github.com/kubeedge/kubeedge cd $GOPATH/src/github.com/kubeedge/kubeedge
KubeEdge 需要 RootCA 证书和一个证书/密钥对。cloud 和 edge 端都可以使用相同的证书/密钥对
$GOPATH/src/github.com/kubeedge/kubeedge/build/tools/certgen.sh genCertAndKey edge
/etc/kubeedge/ca
和 /etc/kubeedge/certs
生成,可以拷贝至 edge 服务端
cd $GOPATH/src/github.com/kubeedge/kubeedge/ make all WHAT=cloudcore
cd $GOPATH/src/github.com/kubeedge/kubeedge/build/crds/devices kubectl create -f devices_v1alpha1_devicemodel.yaml kubectl create -f devices_v1alpha1_device.yaml
cd $GOPATH/src/github.com/kubeedge/kubeedge/cloud # run edge controller # `conf/` should be in the same directory as the cloned KubeEdge repository # verify the configurations before running cloud(cloudcore) mkdir -p /opt/kubeedge/conf cp cloudcore /opt/kubeedge cp -rf conf/* /opt/kubeedge/conf/
1.4.1 controller.yaml 内容
controller:
kube:
master: # kube-apiserver address (such as:http://localhost:8080)
content_type: "application/vnd.kubernetes.protobuf"
qps: 5
burst: 10
node_update_frequency: 10
kubeconfig: "~/.kube/config" #Enter path to kubeconfig file to enable https connection to k8s apiserver, if master and kubeconfig are both set, master will override any value in kubeconfig.
cloudhub:
protocol_websocket: true # enable websocket protocol
port: 10000 # open port for websocket server
protocol_quic: true # enable quic protocol
quic_port: 10001 # open prot for quic server
max_incomingstreams: 10000 # the max incoming stream for quic server
enable_uds: true # enable unix domain socket protocol
uds_address: unix:///var/lib/kubeedge/kubeedge.sock # unix domain socket address
address: 0.0.0.0
ca: /etc/kubeedge/ca/rootCA.crt
cert: /etc/kubeedge/certs/edge.crt
key: /etc/kubeedge/certs/edge.key
keepalive-interval: 30
write-timeout: 30
node-limit: 10
devicecontroller:
kube:
master: # kube-apiserver address (such as:http://localhost:8080)
content_type: "application/vnd.kubernetes.protobuf"
qps: 5
burst: 10
kubeconfig: "~/.kube/config" #Enter path to kubeconfig file to enable https connection to k8s apiserver,if master and kubeconfig are both set, master will override any value in kubeconfig.
简单粗暴运行 nohup ./cloudcore &
1.5.1 可以使用 systemd 挂历 cloudcore服务
sudo ln build/tools/cloudcore.service /etc/systemd/system/cloudcore.service sudo systemctl daemon-reload sudo systemctl start cloudcore
kube edge 提供了示例 node.json 在 kubernetes 中添加一个节点。请确保在Kubernetes中添加了Edge节点。运行以下步骤以添加边缘节点
$GOPATH/src/github.cbiom/kubeedge/kubeedge/build/node.json
更改 metadata.name 为自己的边缘节点名称
cd $GOPATH/src/github.com/kubeedge/kubeedge make all WHAT=edgecore
# cat /opt/kubeedge/conf/edge.yaml
mqtt: server: tcp://127.0.0.1:1883 # external mqtt broker url. internal-server: tcp://127.0.0.1:1884 # internal mqtt broker url. mode: 0 # 0: internal mqtt broker enable only. 1: internal and external mqtt broker enable. 2: external mqtt broker enable only. qos: 0 # 0: QOSAtMostOnce, 1: QOSAtLeastOnce, 2: QOSExactlyOnce. retain: false # if the flag set true, server will store the message and can be delivered to future subscribers. session-queue-size: 100 # A size of how many sessions will be handled. default to 100. edgehub: websocket: url: wss://0.0.0.0:10000/e632aba927ea4ac2b575ec1603d56f10/edge-node/events certfile: /etc/kubeedge/certs/edge.crt keyfile: /etc/kubeedge/certs/edge.key handshake-timeout: 30 #second write-deadline: 15 # second read-deadline: 15 # second quic: url: 127.0.0.1:10001 cafile: /etc/kubeedge/ca/rootCA.crt certfile: /etc/kubeedge/certs/edge.crt keyfile: /etc/kubeedge/certs/edge.key handshake-timeout: 30 #second write-deadline: 15 # second read-deadline: 15 # second controller: protocol: websocket # websocket, quic heartbeat: 15 # second project-id: e632aba927ea4ac2b575ec1603d56f10 node-id: edge-node edged: register-node-namespace: default hostname-override: edge-node interface-name: eth0 edged-memory-capacity-bytes: 7852396000 node-status-update-frequency: 10 # second device-plugin-enabled: false gpu-plugin-enabled: false image-gc-high-threshold: 80 # percent image-gc-low-threshold: 40 # percent maximum-dead-containers-per-container: 1 docker-address: unix:///var/run/docker.sock runtime-type: docker remote-runtime-endpoint: unix:///var/run/dockershim.sock remote-image-endpoint: unix:///var/run/dockershim.sock runtime-request-timeout: 2 podsandbox-image: kubeedge/pause:3.1 # kubeedge/pause:3.1 for x86 arch , kubeedge/pause-arm:3.1 for arm arch, kubeedge/pause-arm64 for arm64 arch image-pull-progress-deadline: 60 # second cgroup-driver: cgroupfs node-ip: "" cluster-dns: "" cluster-domain: "" mesh: loadbalance: strategy-name: RoundRobin
cp $GOPATH/src/github.com/kubeedge/kubeedge/edge/edgecore /opt/kubeedge cd /opt/kubeedge ./edgecore # or nohup ./edgecore > edgecore.log 2>&1 &
sudo ln build/tools/edgecore.service /etc/systemd/system/edgecore.service sudo systemctl daemon-reload sudo systemctl start edgecore
kubectl apply -f $GOPATH/src/github.com/kubeedge/kubeedge/build/deployment.yaml
参考:
https://github.com/kubeedge/kubeedge
https://docs.kubeedge.io/en/latest/setup/setup.html