Setup from KubeEdge Installer

Keadm is used to install the cloud and edge components of kubeedge. It is not responsible for installing K8s and runtime, so users must install a k8s master on cloud and runtime on edge first. Or use an existing cluster.

Please refer kubernetes-compatibility to get Kubernetes compatibility and determine what version of Kubernetes would be installed.

Kubeedge interacts with the standard K8s API, so the K8s cluster can be installed with any tools, such as:

Limitation

  • Currently support of keadm is available for Ubuntu and CentOS OS. RaspberryPi supports is in-progress.

Getting KubeEdge Installer

There are currently two ways to get keadm

  • Download from KubeEdge Release

    1. Go to KubeEdge Release page and download keadm-$VERSION-$OS-$ARCH.tar.gz..
    2. Untar it at desired location, by executing tar -xvzf keadm-$VERSION-$OS-$ARCH.tar.gz.
    3. kubeedge folder is created after execution the command.
  • Building from source

    1. Download the source code.

      1. git clone https://github.com/kubeedge/kubeedge.git $GOPATH/src/github.com/kubeedge/kubeedge
      2. cd $GOPATH/src/github.com/kubeedge/kubeedge
      3. make all WHAT=keadm

      or

      1. go get github.com/kubeedge/kubeedge/keadm/cmd/keadm
    2. If you used go get, the keadm binary is available in $GOPATH/bin/

      If you compiled from source, the keadm binary is in $GOPATH/src/github.com/kubeedge/kubeedge/_output/local/bin/

Setup Cloud Side (KubeEdge Master Node)

By default port ‘10000’ in your cloudcore needs to be accessible for your edge nodes.

keadm init will install cloudcore, generate the certs and install the CRDs. It also provide flag by which specific versions can be set.

  1. Execute keadm init : keadm needs super user rights (or root rights) to run successfully.

    Command flags The optional flags with this command are mentioned below

    ``` “keadm init” command install KubeEdge’s master node (on the cloud) component. It checks if the Kubernetes Master are installed already, If not installed, please install the Kubernetes first.

    Usage: keadm init [flags]

    Examples:

    keadm init

    • This command will download and install the default version of KubeEdge cloud component

    keadm init —kubeedge-version=1.2.0 —kube-config=/root/.kube/config

    • kube-config is the absolute path of kubeconfig which used to secure connectivity between cloudcore and kube-apiserver
  1. Flags:
  2. -h, --help help for init
  3. --kube-config string Use this key to set kube-config path, eg: $HOME/.kube/config (default "/root/.kube/config")
  4. --kubeedge-version string[="1.2.0"] Use this key to download and use the required KubeEdge version (default "1.2.0")
  5. --master string Use this key to set K8s master address, eg: http://127.0.0.1:8080
  6. ```

IMPORTANT NOTE: At least one of kubeconfig or master must be configured correctly, so that it can be used to verify the version and other info of the k8s cluster.

Examples:

  1. keadm init

Sample execution output:

  1. Kubernetes version verification passed, KubeEdge installation will start...
  2. ...
  3. KubeEdge cloudcore is running, For logs visit: /var/log/kubeedge/cloudcore.log

Manually copy certs.tgz from cloud host to edge host(s)

Now users still need to copy the certs to the edge nodes. In the future, it will support the use of tokens for authentication.

On edge host

  1. mkdir -p /etc/kubeedge

On cloud host

  1. cd /etc/kubeedge/
  2. scp -r certs.tgz username@ipEdgevm:/etc/kubeedge

On edge host untar the certs.tgz file

  1. cd /etc/kubeedge
  2. tar -xvzf certs.tgz

Setup Edge Side (KubeEdge Worker Node)

keadm join will install edgecore and mqtt. It also provide flag by which specific versions can be set.

Execute keadm join <flags>

Command flags

The optional flags with this command are shown in below shell

  1. "keadm join" command bootstraps KubeEdge's worker node (at the edge) component.
  2. It will also connect with cloud component to receive
  3. further instructions and forward telemetry data from
  4. devices to cloud
  5. Usage:
  6. keadm join [flags]
  7. Examples:
  8. keadm join --cloudcore-ipport=<ip:port address> --edgenode-name=<unique string as edge identifier>
  9. - For this command --cloudcore-ipport flag is a required option
  10. - This command will download and install the default version of pre-requisites and KubeEdge
  11. keadm join --cloudcore-ipport=10.20.30.40:10000 --edgenode-name=testing123 --kubeedge-version=1.2.0
  12. Flags:
  13. --certPath string The certPath used by edgecore, the default value is /etc/kubeedge/certs (default "/etc/kubeedge/certs")
  14. -e, --cloudcore-ipport string IP:Port address of KubeEdge CloudCore
  15. -i, --edgenode-name string KubeEdge Node unique identification string, If flag not used then the command will generate a unique id on its own
  16. -h, --help help for join
  17. --interfacename string KubeEdge Node interface name string, the default value is eth0
  18. --kubeedge-version string[="1.2.0"] Use this key to download and use the required KubeEdge version (default "1.2.0")
  19. -r, --runtimetype string Container runtime type

IMPORTANT NOTE:

  1. For this command –cloudcore-ipport flag is a Mandatory flag
  2. The KubeEdge version used in cloud and edge side should be same.

Examples:

  1. keadm join --cloudcore-ipport=192.168.20.50:10000

Sample execution output:

  1. Host has mosquit+ already installed and running. Hence skipping the installation steps !!!
  2. ...
  3. KubeEdge edgecore is running, For logs visit: /var/log/kubeedge/edgecore.log

Setup Edge Side with VM provisioning (KubeEdge Worker Node)

Requirement, restrictions

  1. Current phase supports only one runtime, either container or VM runtime in one cluster.
  2. Make sure no libvirt is running on the worker nodes.

Steps

  1. Install CNI plugin:

    • Download CNI plugin release and extract it:
    1. $ wget https://github.com/containernetworking/plugins/releases/download/v0.8.2/cni-plugins-linux-amd64-v0.8.2.tgz
    2. # Extract the tarball
    3. $ mkdir cni
    4. $ tar -zxvf v0.2.0.tar.gz -C cni
    5. $ mkdir -p /opt/cni/bin
    6. $ cp ./cni/* /opt/cni/bin/
    • Configure cni plugin
    1. $ mkdir -p /etc/cni/net.d/
    2. $ cat >/etc/cni/net.d/bridge.conf <<EOF
    3. {
    4. "cniVersion": "0.3.1",
    5. "name": "containerd-net",
    6. "type": "bridge",
    7. "bridge": "cni0",
    8. "isGateway": true,
    9. "ipMasq": true,
    10. "ipam": {
    11. "type": "host-local",
    12. "subnet": "10.88.0.0/16",
    13. "routes": [
    14. { "dst": "0.0.0.0/0" }
    15. ]
    16. }
    17. }
    18. EOF
  2. Setup VM runtime: Use script hack/setup-vmruntime.sh to set up VM runtime. It makes use of Arktos Runtime release to start three containers:

    1. vmruntime_vms
    2. vmruntime_libvirt
    3. vmruntime_virtlet
  3. Start edgecore service and join the cluster: The step is similare to provision containers with specify remote-runtime-endpoint.

Examples:

  1. keadm join --cloudcore-ipport=192.168.20.50:10000 -r remote --remote-runtime-endpoint=unix:///run/virtlet.sock
  1. Test create a VM workload: (optional) On the master node, create a sample yaml file vm.yaml as:
  1. apiVersion: v1
  2. kind: Pod
  3. metadata:
  4. name: testvm
  5. spec:
  6. containers:
  7. - name: testvm
  8. image: download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img
  9. imagePullPolicy: Always
  10. resources:
  11. limits:
  12. cpu: "3"
  13. memory: "200Mi"
  14. requests:
  15. cpu: "3"
  16. memory: "200Mi"

Then use kubectl create -f vm.yaml to create VM pod on the edge node. You should see the workload on master:

  1. On master:
  2. # kubectl get pods -o wide
  3. NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
  4. testvm 1/1 Running 0 38s 10.88.0.18 testnodevm3 <none> <none>

On the edge worker node: either ssh into the VM instance or virsh list can verify the VM is created and running:

  1. Id Name State
  2. ----------------------------------------------------
  3. 1 virtlet-10628888-2584-testvm running

Reset KubeEdge Master and Worker nodes

keadm reset will stop KubeEdge components. It doesn’t uninstall/remove any of the pre-requisites.

Execute keadm reset

Command flags

  1. keadm reset --help
  2. keadm reset command can be executed in both cloud and edge node
  3. In cloud node it shuts down the cloud processes of KubeEdge
  4. In edge node it shuts down the edge processes of KubeEdge
  5. Usage:
  6. keadm reset [flags]
  7. Examples:
  8. For cloud node:
  9. keadm reset
  10. For edge node:
  11. keadm reset
  12. Flags:
  13. -h, --help help for reset

Errata

  1. Error in CloudCore

    If you are getting the below error in Cloudcore.log

    1. E1231 04:37:27.397431 19607 reflector.go:125] github.com/kubeedge/kubeedge/cloud/pkg/devicecontroller/manager/device.go:40: Failed to list *v1alpha1.Device: the server could not find the requested resource (get devices.devices.kubeedge.io)
    2. E1231 04:37:27.398273 19607 reflector.go:125] github.com/kubeedge/kubeedge/cloud/pkg/devicecontroller/manager/devicemodel.go:40: Failed to list *v1alpha1.DeviceModel: the server could not find the requested resource (get devicemodels.devices.kubeedge.io)

    browse to the

    1. cd $GOPATH/src/github.com/kubeedge/kubeedge/build/crds/devices

    and apply the below

    1. kubectl create -f devices_v1alpha1_devicemodel.yaml
    2. kubectl create -f devices_v1alpha1_device.yaml

    or

    1. kubectl create -f https://raw.githubusercontent.com/kubeedge/kubeedge/<kubeEdge Version>/build/crds/devices/devices_v1alpha1_device.yaml
    2. kubectl create -f https://raw.githubusercontent.com/kubeedge/kubeedge/<kubeEdge Version>/build/crds/devices/devices_v1alpha1_devicemodel.yaml

    Also, create ClusterObjectSync and ObjectSync CRDs which are used in reliable message delivery.

    1. cd $GOPATH/src/github.com/kubeedge/kubeedge/build/crds/reliablesyncs
    2. kubectl create -f cluster_objectsync_v1alpha1.yaml
    3. kubectl create -f objectsync_v1alpha1.yaml