1)需要先安装一个kubernetes集群
2)准备一个edge节点,安装docker
kubernetes集群和docker的安装教程网上有很多,此处不再详述。
mkdir -p /home/bluejoy/kubeedge/deploy-v1.2.0
cd /home/bluejoy/kubeedge/deploy-v1.2.0
git clone https://github.com/kubeedge/kubeedge.git
cd kubeedge
git checkout v1.2.0
cd /home/bluejoy/kubeedge/deploy-v1.2.0
wget https://github.com/kubeedge/kubeedge/releases/download/v1.2.0/kubeedge-v1.2.0-linux-amd64.tar.gz
tar -xzvf kubeedge-v1.2.0-linux-amd64.tar.gz
mv kubeedge-v1.2.0-linux-amd64 kubeedge-v1.2.0
cd /home/bluejoy/kubeedge/deploy-v1.2.0/kubeedge/build/tools/
bash certgen.sh genCertAndKey edge
cd /home/bluejoy/kubeedge/deploy-v1.2.0/kubeedge/build/crds/devices
kubectl create -f devices_v1alpha1_devicemodel.yaml
kubectl create -f devices_v1alpha1_device.yaml
cd /home/bluejoy/kubeedge/deploy-v1.2.0/kubeedge/build/crds/reliablesyncs
kubectl create -f cluster_objectsync_v1alpha1.yaml
kubectl create -f objectsync_v1alpha1.yaml
v1.2.0版本的配置文件是由 cloudcore 程序通过执行以下命令生成的:
mkdir -p /etc/kubeedge/config/
cloudcore --minconfig > /etc/kubeedge/config/cloudcore.yaml
修改配置文件:
vim /etc/kubeedge/config/cloudcore.yaml
# With --minconfig , you can easily used this configurations as reference.
# It's useful to users who are new to KubeEdge, and you can modify/create your own configs accordingly.
# This configuration is suitable for beginners.
apiVersion: cloudcore.config.kubeedge.io/v1alpha1
kind: CloudCore
kubeAPIConfig:
kubeConfig: /root/.kube/config
master: "https://192.168.56.105:6443"
modules:
cloudhub:
nodeLimit: 10
tlsCAFile: /etc/kubeedge/ca/rootCA.crt
tlsCertFile: /etc/kubeedge/certs/edge.crt
tlsPrivateKeyFile: /etc/kubeedge/certs/edge.key
unixsocket:
address: unix:///var/lib/kubeedge/kubeedge.sock
enable: true
websocket:
address: 0.0.0.0
enable: true
port: 10000
注意根据你的环境修改以下两处地方。
1)kubeConfig的值
2)master的值
cp kubeedge/cloud/cloudcore /usr/local/bin/
1)添加 apt-get 源:
add-apt-repository ppa:mosquitto-dev/mosquitto-ppa
apt-get update
2)安装:
apt-get install mosquitto
scp -r /etc/kubeedge/certs [email protected]:/etc/kubeedge/
scp -r /home/bluejoy/kubeedge/deploy-v1.2.0/kubeedge-v1.2.0 [email protected]:/home/bluejoy/kubeedge/deploy-v1.2.0/bin
cp /home/bluejoy/kubeedge/deploy-v1.2.0/bin/edgecore /usr/local/bin/
v1.2.0版本的配置文件由 edgecore 程序通过执行以下命令生成的:
edgecore --minconfig > /etc/kubeedge/config/edgecore.yaml
修改配置文件:
vim /etc/kubeedge/config/edgecore.yaml
# With --minconfig , you can easily used this configurations as reference.
# It's useful to users who are new to KubeEdge, and you can modify/create your own configs accordingly.
# This configuration is suitable for beginners.
apiVersion: edgecore.config.kubeedge.io/v1alpha1
database:
dataSource: /var/lib/kubeedge/edgecore.db
kind: EdgeCore
modules:
edged:
cgroupDriver: cgroupfs
clusterDNS: ""
clusterDomain: ""
devicePluginEnabled: false
dockerAddress: unix:///var/run/docker.sock
gpuPluginEnabled: false
hostnameOverride: bluejoy-jing
interfaceName: enp0s8
nodeIP: 192.168.56.111
podSandboxImage: kubeedge/pause:3.1
remoteImageEndpoint: unix:///var/run/dockershim.sock
remoteRuntimeEndpoint: unix:///var/run/dockershim.sock
runtimeType: docker
edgehub:
heartbeat: 15
tlsCaFile: /etc/kubeedge/ca/rootCA.crt
tlsCertFile: /etc/kubeedge/certs/edge.crt
tlsPrivateKeyFile: /etc/kubeedge/certs/edge.key
websocket:
enable: true
handshakeTimeout: 30
readDeadline: 15
server: 192.168.56.105:10000
writeDeadline: 15
eventbus:
mqttMode: 2
mqttQOS: 0
mqttRetain: false
mqttServerExternal: tcp://127.0.0.1:1883
mqttServerInternal: tcp://127.0.0.1:1884
注意修改以下几处地方。
1)修改modules.edgehub.websocket下的server,默认为127.0.0.1:10000,需改为实际云端IP地址,此处为192.168.56.105:10000。
2)podSandboxImage,X86平台为podSandboxImage: kubeedge/pause:3.1,ARM 平台根据位数不同,可设为kubeedge/pause-arm:3.1或ubeedge/pause-arm64:3.1。
3)cgroup 驱动默认值为:cgroupDriver: cgroupfs(是否需要修改,需要查看docker info命令,获取自己节点上的值)。
4)网络设备接口名称interfaceName及IP地址nodeIP,在运行上述配置文件生成命令时会自动检测获取,一般无须修改(但是我的虚拟机有两块网卡,所以需要修改)。
5)hostnameOverride需要修改为edge节点的主机名称。
cloudcore > /var/log/kubeedge/cloudcore.log 2>&1
edgecore > /var/log/kubeedge/edgecore.log 2>&1
cd /home/bluejoy/kubeedge/deploy-v1.2.0/kubeedge/build/
kubectl apply -f deployment.yaml
cd /home/bluejoy/kubeedge/deploy-v1.2.0/kubeedge/build/
kubectl delete -f deployment.yaml