Setup using Release package

Prerequisites

  • Install docker

  • Install kubeadm/kubectl

  • Creating cluster with kubeadm

  • KubeEdge supports https connection to Kubernetes apiserver.

    Enter the path to kubeconfig file in controller.yaml

    1. controller:
    2. kube:
    3. ...
    4. kubeconfig: "path_to_kubeconfig_file" #Enter path to kubeconfig file to enable https connection to k8s apiserver
  • (Optional) KubeEdge also supports insecure http connection to Kubernetes apiserver for testing, debugging cases. Please follow below steps to enable http port in Kubernetes apiserver.

    1. vi /etc/kubernetes/manifests/kube-apiserver.yaml
    2. # Add the following flags in spec: containers: -command section
    3. - --insecure-port=8080
    4. - --insecure-bind-address=0.0.0.0

    Enter the master address in controller.yaml

    1. controller:
    2. kube:
    3. ...
    4. master: "http://127.0.0.1:8080" #Note if master and kubeconfig are both set, master will override any value in kubeconfig.

Cloud Vm

Note:execute the below commands as root user

  1. VERSION="v0.3.0"
  2. OS="linux"
  3. ARCH="amd64"
  4. 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

Generate Certificates

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.

  1. wget -L https://raw.githubusercontent.com/kubeedge/kubeedge/master/build/tools/certgen.sh
  2. # make script executable
  3. chmod +x certgen.sh
  4. bash -x ./certgen.sh genCertAndKey edge

NOTE: The cert/key will be generated in the /etc/kubeedge/ca and /etc/kubeedge/certs respectively.

  • 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 DeviceModel and Device CRDs.
  1. wget -L https://raw.githubusercontent.com/kubeedge/kubeedge/master/build/crds/devices/devices_v1alpha1_devicemodel.yaml
  2. kubectl create -f devices_v1alpha1_devicemodel.yaml
  3. wget -L https://raw.githubusercontent.com/kubeedge/kubeedge/master/build/crds/devices/devices_v1alpha1_device.yaml
  4. kubectl create -f devices_v1alpha1_device.yaml
  • Create ClusterObjectSync and ObjectSync CRDs which used in reliable message delivery.
  1. wget -L https://raw.githubusercontent.com/kubeedge/kubeedge/master/build/crds/reliablesyncs/cluster_objectsync_v1alpha1.yaml
  2. kubectl create -f cluster_objectsync_v1alpha1.yaml
  3. wget -L https://raw.githubusercontent.com/kubeedge/kubeedge/master/build/crds/reliablesyncs/objectsync_v1alpha1.yaml
  4. kubectl create -f objectsync_v1alpha1.yaml
  • Run cloud
  1. cd /etc/kubeedge/cloud
  2. # run cloudcore
  3. # `conf/` should be in the same directory where cloudcore resides
  4. # verify the configurations before running cloud(cloudcore)
  5. ./cloudcore

Edge Vm

Prerequisites

Configuring MQTT mode

The Edge part of KubeEdge uses MQTT for communication between deviceTwin and devices. KubeEdge supports 3 MQTT modes:

  1. internalMqttMode: internal mqtt broker is enabled.
  2. bothMqttMode: internal as well as external broker are enabled.
  3. 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.yaml configuration file
    • Replace edgehub.websocket.certfile and edgehub.websocket.keyfile with your own certificate path
    • Update the IP address of the master in the websocket.url field.
    • replace edge-node with edge node name in edge.yaml for the below fields :
      • websocket:URL
      • controller:node-id
      • edged: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:docker or runtime-type:remote
    • Additionally specify the following parameters for remote/CRI based runtimes
      • remote-runtime-endpoint:/var/run/containerd/containerd.sock
      • remote-image-endpoint:/var/run/containerd/containerd.sock
      • runtime-request-timeout: 2
      • podsandbox-image: k8s.gcr.io/pause
      • kubelet-root-dir: /var/run/kubelet/
  • Run edge
  1. # run edgecore
  2. # `conf/` should be in the same directory as the cloned KubeEdge repository
  3. cd /etc/kubeedge/edge
  4. # verify the configurations before running edge(edgecore)
  5. ./edgecore
  6. # or
  7. nohup ./edgecore > edgecore.log 2>&1 &
  1. **Note**: Running edgecore on ARM based processors,follow the above steps as mentioned for Edge Vm
  1. VERSION="v0.3.0"
  2. OS="linux"
  3. ARCH="arm"
  4. 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

NOTE: scp kubeedge folder from cloud vm to edge vm

  1. In cloud
  2. scp -r /etc/kubeedge root@edgeip:/etc