-
After initializing Kubernetes master, we need to expose insecure port 8080 for cloudcore/kubectl to work with http connection to Kubernetes apiserver. Please follow below steps to enable http port in Kubernetes apiserver.
vi /etc/kubernetes/manifests/kube-apiserver.yaml # Add the following flags in spec: containers: -command section - --insecure-port=8080 - --insecure-bind-address=0.0.0.0 -
(Optional)KubeEdge also supports https connection to Kubernetes apiserver. Follow the steps in Kubernetes Documentation to create the kubeconfig file.
Enter the path to kubeconfig file in controller.yaml
controller: kube: ... kubeconfig: "path_to_kubeconfig_file" #Enter path to kubeconfig file to enable https connection to k8s apiserver
Note:execute the below commands as root user
VERSION="v0.3.0" OS="linux" ARCH="amd64" curl -L "https://github.com/kubeedge/kubeedge/releases/download/${VERSION}/kubeedge-${VERSION}-${OS}-${ARCH}.tar.gz" --output kubeedge-${VERSION}-${OS}-${ARCH}.tar.gz && tar -xf kubeedge-${VERSION}-${OS}-${ARCH}.tar.gz -C /etc
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.
wget -L https://raw.githubusercontent.com/kubeedge/kubeedge/master/build/tools/certgen.sh # make script executable chmod +x certgen.sh bash -x ./certgen.sh genCertAndKey edgeNOTE: The cert/key will be generated in the
/etc/kubeedge/caand/etc/kubeedge/certsrespectively.-
The path to the generated certificates should be updated in
etc/kubeedge/cloud/conf/controller.yaml. Please update the correct paths for the following :- cloudhub.ca
- cloudhub.cert
- cloudhub.key
-
Create device model and device CRDs.
wget -L https://raw.githubusercontent.com/kubeedge/kubeedge/master/build/crds/devices/devices_v1alpha1_devicemodel.yaml # make script executable chmod +x devices_v1alpha1_devicemodel.yaml kubectl create -f devices_v1alpha1_devicemodel.yaml wget -L https://raw.githubusercontent.com/kubeedge/kubeedge/master/build/crds/devices/devices_v1alpha1_device.yaml # make script executable chmod +x devices_v1alpha1_device.yaml kubectl create -f devices_v1alpha1_device.yaml- Run cloud
cd /etc/kubeedge/cloud # run edge controller # `conf/` should be in the same directory where cloudcore resides # verify the configurations before running cloud(cloudcore) ./cloudcore
- Install Docker and/or Containerd based on the runtime to be used at edge
-
NOTE: scp kubeedge folder from cloud vm to edge vm
In cloud
scp -r /etc/kubeedge root@edgeip:/etcThe Edge part of KubeEdge uses MQTT for communication between deviceTwin and devices. KubeEdge supports 3 MQTT modes:
- internalMqttMode: internal mqtt broker is enabled.
- bothMqttMode: internal as well as external broker are enabled.
- externalMqttMode: only external broker is enabled.
Use mode field in edge.yaml to select the desired mode.
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.
-
We have provided a sample node.json to add a node in kubernetes. Please make sure edge-node is added in kubernetes. Run below steps to add edge-node.
-
Deploy node
shell wget -L https://raw.githubusercontent.com/kubeedge/kubeedge/master/build/node.json #Modify the node.json` file and change `metadata.name` to the name of the edge node kubectl apply -f node.json -
Modify the
/etc/kubeedge/edge/conf/edge.yamlconfiguration file- Replace
edgehub.websocket.certfileandedgehub.websocket.keyfilewith your own certificate path - Update the IP address of the master in the
websocket.urlfield. - replace
edge-nodewith edge node name in edge.yaml for the below fields :websocket:URLcontroller:node-idedged:hostname-override
- Configure the desired container runtime in /etc/kubeedge/edge/conf/edge.yaml configuration file
- Specify the runtime type 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
runtime-type:dockerorruntime-type:remote
- Additionally specify the following parameters for remote/CRI based runtimes
remote-runtime-endpoint:/var/run/containerd/containerd.sockremote-image-endpoint:/var/run/containerd/containerd.sockruntime-request-timeout: 2podsandbox-image: k8s.gcr.io/pausekubelet-root-dir: /var/run/kubelet/
- Replace
-
Run edge
# run edgecore
# `conf/` should be in the same directory as the cloned KubeEdge repository
cd /etc/kubeedge/edge
# verify the configurations before running edge(edgecore)
./edgecore
# or
nohup ./edgecore > edgecore.log 2>&1 &
**Note**: Running edgecore on ARM based processors,follow the above steps as mentioned for Edge Vm
VERSION="v0.3.0"
OS="linux"
ARCH="arm"
curl -L "https://github.com/kubeedge/kubeedge/releases/download/${VERSION}/kubeedge-${VERSION}-${OS}-${ARCH}.tar.gz" --output kubeedge-${VERSION}-${OS}-${ARCH}.tar.gz && tar -xf kubeedge-${VERSION}-${OS}-${ARCH}.tar.gz -C /etc- Monitoring containers status
- If the container runtime configured to manage containers is containerd , then the following commands can be used to inspect container status and list images.
- sudo ctr --namespace k8s.io containers ls
- sudo ctr --namespace k8s.io images ls
- sudo crictl exec -ti /bin/bash
- If the container runtime configured to manage containers is containerd , then the following commands can be used to inspect container status and list images.