KubeEdge requires configuration on both Cloud side (KubeEdge Master) and Edge side (KubeEdge Worker Node)
Setting up cloud side requires two steps
- Modification of the configuration files
- Edge node will be auto registered by default. Users can still choose to register manually.
Cloudcore requires changes in cloudcore.yaml
configuration file.
Create and set cloudcore config file
Create the /etc/kubeedge/config
folder
# the default configuration file path is '/etc/kubeedge/config/cloudcore.yaml'
# also you can specify it anywhere with '--config'
mkdir -p /etc/kubeedge/config/
Either create a minimal configuration with command ~/kubeedge/cloudcore --minconfig
~/kubeedge/cloudcore --minconfig > /etc/kubeedge/config/cloudcore.yaml
or a full configuration with command ~/kubeedge/cloudcore --defaultconfig
~/kubeedge/cloudcore --defaultconfig > /etc/kubeedge/config/cloudcore.yaml
Edit the configuration file
vim /etc/kubeedge/config/cloudcore.yaml
Verify the configurations before running cloudcore
In the cloudcore.yaml, modify the below settings.
-
Either
kubeAPIConfig.kubeConfig
orkubeAPIConfig.master
: This would be the path to your kubeconfig file. It might be either/root/.kube/config
or
/home/<your_username>/.kube/config
depending on where you have setup your kubernetes by performing the below step:
To start using your cluster, you need to run the following as a regular user: mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config
By default, cloudcore use https connection to Kubernetes apiserver. If
master
andkubeConfig
are both set,master
will override any value in kubeconfig. -
Check whether the cert files for
modules.cloudhub.tlsCAFile
,modules.cloudhub.tlsCertFile
,modules.cloudhub.tlsPrivateKeyFile
exists.
Node registration can be completed in two ways:
- Node - Automatic Registration
- Node - Manual Registration
Edge node can be registered automatically if the value of field modules.edged.registerNode
in edgecore's config edgecore config file is set to true.
modules:
edged:
registerNode: true
Refer here to add edge nodes.
RootCA certificate and a cert/key pair is required to have a setup for KubeEdge. Same cert/key pair can be used in both cloud and edge.
cert/key should exist in /etc/kubeedge/ca and /etc/kubeedge/certs. Otherwise please refer to generate certs to generate them. You need to copy these files to the corresponding directory on edge side.
Create the certs.tgz
by
cd /etc/kubeedge
tar -cvzf certs.tgz certs/
Transfer certificate files to the edge node, because edgecore
uses these certificate files to connect to cloudcore
This can be done by utilising scp
cd /etc/kubeedge/
scp certs.tgz username@destination:/etc/kubeedge
Here, we are copying the certs.tgz from the cloud side to the edge node in the /etc/kubeedge directory. You may copy in any directory and then move the certs to /etc/kubeedge folder.
At this point we have completed all configuration changes related to cloudcore.
On edge host
mkdir -p /etc/kubeedge
On edge host untar the certs.tgz file
cd /etc/kubeedge
tar -xvzf certs.tgz
Create the /etc/kubeedge/config
folder
# the default configration file path is '/etc/kubeedge/config/edgecore.yaml'
# also you can specify it anywhere with '--config'
mkdir -p /etc/kubeedge/config/
Either create a minimal configuration with command ~/kubeedge/edgecore --minconfig
~/kubeedge/edgecore --minconfig > /etc/kubeedge/config/edgecore.yaml
or a full configuration with command ~/kubeedge/edgecore --defaultconfig
~/kubeedge/edgecore --defaultconfig > /etc/kubeedge/config/edgecore.yaml
Edit the configuration file
vim /etc/kubeedge/config/edgecore.yaml
Verify the configurations before running edgecore
-
Check
modules.edged.podSandboxImage
: This is very important and must be set correctly.To check the architecture of your machine run the following
getconf LONG_BIT
kubeedge/pause-arm:3.1
for arm archkubeedge/pause-arm64:3.1
for arm64 archkubeedge/pause:3.1
for x86 arch
-
Check whether the cert files for
modules.edgehub.tlsCaFile
andmodules.edgehub.tlsCertFile
andmodules.edgehub.tlsPrivateKeyFile
exists. If those files not exist, you need to copy them from cloud side. -
Update the IP address and port of the KubeEdge CloudCore in the
modules.edgehub.websocket.server
andmodules.edgehub.quic.server
field. You need set cloudcore ip address. -
Configure the desired container runtime to be used as either docker or remote (for all CRI based runtimes including containerd). If this parameter is not specified docker runtime will be used by default
runtimeType: docker
or
runtimeType: remote
-
If your runtime-type is remote, specify the following parameters for remote/CRI based runtimes
remoteRuntimeEndpoint: /var/run/containerd/containerd.sock remoteImageEndpoint: /var/run/containerd/containerd.sock runtimeRequestTimeout: 2 podSandboxImage: k8s.gcr.io/pause kubelet-root-dir: /var/run/kubelet/
The Edge part of KubeEdge uses MQTT for communication between deviceTwin and devices. KubeEdge supports 3 MQTT modes (internalMqttMode
, bothMqttMode
, externalMqttMode
), set mqttMode
field in edgecore.yaml to the desired mode.
- internalMqttMode: internal mqtt broker is enabled (
mqttMode
=0). - bothMqttMode: internal as well as external broker are enabled (
mqttMode
=1). - externalMqttMode: only external broker is enabled (
mqttMode
=2).
To use KubeEdge in double mqtt or external mode, you need to make sure that mosquitto or emqx edge is installed on the edge node as an MQTT Broker.
At this point we have completed all configuration changes related to edgecore.