引言:本文是主要介绍部署edgecore基于token认证注册到cloudcore的过程,关于如何部署cloudcore的内容请点击另一篇文章:使用kubectl搭建kubeedge集群v1.5.0
1.环境准备总览
文件名称 | 说明 |
edgecore | edgecore的运行文件 |
edgecore.yaml | 路径/etc/kubeedge/config |
docker环境 | docker容器安装,注意native.cgroupdriver=cgroupfs |
mqtt客户端 | 推荐使用mosquito,或者emq,二选一 |
2.开始安装
2.1 edgecore
wget https://github.com/kubeedge/kubeedge/releases/download/v1.5.0/kubeedge-v1.5.0-linux-amd64.tar.gz
tar -zxvf kubeedge-v1.5.0-linux-amd64.tar.gz
下载edgecore文件,注意是amd64还是arm64。
2.2 edgecore.yaml
有两个要注意的地方:一是下面的ip和port,都要修改成cloudcore的ip和port;二是token,需要从云端获取,当EdgeHub启动时,其先从CloudCore申请证书(若正确配置本地证书,则直接使用本地证书)
在云端master节点执行下面的命令获取token:
[root@k8smaster ~]# kubectl get secret -n kubeedge tokensecret -oyaml -o jsonpath={".data.tokendata"} | base64 -d
059b9a099904738743701669329a8a516994839d05cd27dcc1cbf3530a9.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MTYyOTU5Ofd9.CY33w6-aY8nwhh82-y61jtJXWSFnFA99K-Hg0QNQnz8
[root@k8smaster ~]#
typemeta:
kind: EdgeCore
apiversion: edgecore.config.kubeedge.io/v1alpha1
database:
aliasname: default
datasource: /var/lib/kubeedge/edgecore.db
drivername: sqlite3
modules:
dbtest:
enable: false
devicetwin:
enable: true
edgehub:
enable: true
heartbeat: 15
httpserver: https://192.168.1.183:10002
projectid: e632aba927ea4ac2b575ec1603d56f10
quic:
enable: false
handshaketimeout: 30
readdeadline: 15
server: 192.168.1.183:10001
writedeadline: 15
tlscafile: /etc/kubeedge/ca/rootCA.crt
tlscertfile: /etc/kubeedge/certs/server.crt
tlsprivatekeyfile: /etc/kubeedge/certs/server.key
token: 059b9a0999098308b4b2a78901669329a8a51690975cd27dcc1cbf3530a9.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MTYyOTU5ODN9.CY33w6-aY8nkkhh82-y61jtJXWSFnFA99K-Hg0QNQnz8
websocket:
enable: true
handshaketimeout: 30
readdeadline: 15
server: 192.168.1.183:10000
writedeadline: 15
edgemesh:
enable: true
lbstrategy: RoundRobin
listeninterface: docker0
listenport: 40001
subnet: 9.251.0.0/16
edgestream:
enable: false
handshaketimeout: 30
readdeadline: 15
server: 127.0.0.1:✔
tlstunnelcafile: /etc/kubeedge/ca/rootCA.crt
tlstunnelcertfile: /etc/kubeedge/certs/server.crt
tlstunnelprivatekeyfile: /etc/kubeedge/certs/server.key
writedeadline: 15
edged:
cgroupdriver: cgroupfs
cgrouproot: ""
cgroupsperqos: true
clusterdns: ""
clusterdomain: ""
cnibindir: /opt/cni/bin
cnicachedir: /var/lib/cni/cache
cniconfdir: /etc/cni/net.d
concurrentconsumers: 5
devicepluginenabled: false
dockeraddress: unix:///var/run/docker.sock
edgedmemorycapacity: 7852396000
enable: true
enablemetrics: true
gpupluginenabled: false
hostnameoverride: edge129
imagegchighthreshold: 80
imagegclowthreshold: 40
imagepullprogressdeadline: 60
interfacename: eth0
maximumdeadcontainersperpod: 1
networkpluginmtu: 1500
nodeip: 192.168.1.176
nodestatusupdatefrequency: 10
podsandboximage: kubeedge/pause:3.1
registernode: true
registernodenamespace: default
remoteruntimeendpoint: unix:///var/run/dockershim.sock
remoteimageendpoint: unix:///var/run/dockershim.sock
runtimerequesttimeout: 2
runtimetype: docker
volumestatsaggperiod: 60000000000
eventbus:
enable: true
mqttmode: 2
mqttqos: 0
mqttretain: false
mqttserverinternal: tcp://127.0.0.1:1884
mqttserverexternal: tcp://127.0.0.1:1883
mqttsessionqueuesize: 100
metamanager:
contextsendgroup: hub
contextsendmodule: websocket
enable: true
podstatussyncinterval: 60
servicebus:
enable: false
2.3 安装MQTT客户端
安装mosquito
docker run -d --name mosquito -p 1883:1883 eclipse-mosquitto:2.0.7
安装emq,国内开源项目,非常厉害哦
docker run -d --name emqx -p 1883:1883 emqx/emqx:4.2.8
3.执行edgecore
#找到第一步下载的文件,edgecore的路径下
chmod u+x edgecore
./edgecore
执行完成后,在云端可以查看到加入的边缘节点。
恭喜你,已经成功部署edgecore并且连接到云端cloudcore!
支持开源,拥抱开源,为开发者赋能