Skip to the content.

KubeEdge Overview

Summary

KubeEdge is an open-source platform that extends native containerized application orchestration capabilities to hosts at the edge. Built on top of Kubernetes, KubeEdge provides infrastructure support for network, application deployment, and metadata synchronization between cloud and edge. It enables the management of edge nodes as if they were part of a single, unified Kubernetes cluster, allowing for consistent and scalable application deployment across edge and cloud environments.

Problems Addressed

KubeEdge helps users address several key challenges in edge computing environments:

  1. Unified Management: Allows for centralized management of edge and cloud resources using Kubernetes, reducing operational complexity.
  2. Reduced Latency: By deploying applications closer to end-users or data sources, KubeEdge minimizes latency and improves performance.
  3. Offline Operation: Enables edge nodes to operate autonomously even when disconnected from the cloud, ensuring high availability and reliability.
  4. Resource Efficiency: Optimizes the use of edge resources by managing workloads efficiently and enabling better utilization of computational power at the edge.

Getting Started with KubeEdge

Here’s a brief demo on how to get started with KubeEdge and use it in a scenario:

Step 1: Prerequisites

Ensure you have the following prerequisites:

Step 2: Install KubeEdge

  1. Cloud Side Installation:
    • Download and install KubeEdge on the cloud side:

      wget https://github.com/kubeedge/kubeedge/releases/download/v1.10.0/keadm-v1.10.0-linux-amd64.tar.gz
      tar -xvzf keadm-v1.10.0-linux-amd64.tar.gz
      cd keadm-v1.10.0-linux-amd64/keadm
      sudo ./keadm init --kube-config=<path-to-your-kubeconfig>
      
    • This will initialize the KubeEdge cloud components and configure the Kubernetes API server.

  2. Edge Side Installation:
    • Download and install KubeEdge on the edge node:

      wget https://github.com/kubeedge/kubeedge/releases/download/v1.10.0/keadm-v1.10.0-linux-amd64.tar.gz
      tar -xvzf keadm-v1.10.0-linux-amd64.tar.gz
      cd keadm-v1.10.0-linux-amd64/keadm
      sudo ./keadm join --cloudcore-ipport=<cloud-ip:port> --token=<token-generated-from-cloud-side>
      
    • This will set up the KubeEdge edge components and connect the edge node to the cloud.

Step 3: Deploy an Application

Deploy a sample NGINX application on the edge node:

  1. Create a Deployment YAML file named nginx-deployment.yaml:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: nginx-deployment
      namespace: default
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: nginx
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
          - name: nginx
            image: nginx:1.14.2
            ports:
            - containerPort: 80
    
  2. Apply the Deployment:

kubectl apply -f nginx-deployment.yaml
  1. Create a NodeSelector YAML file named node-selector.yaml to schedule the deployment to the edge node:
apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  containers:
  - name: nginx
    image: nginx
  nodeSelector:
    node-role.kubernetes.io/edge: ""
  1. Apply the NodeSelector:
kubectl apply -f node-selector.yaml

Step 4: Verify the Deployment

  1. Check the status of the deployment:
kubectl get pods -o wide
  1. Ensure the pod is running on the edge node.

Scenario: Edge Device Management

KubeEdge allows you to manage IoT devices connected to edge nodes seamlessly. Here’s a simple scenario to demonstrate this capability.

  1. Create a DeviceModel YAML file named device-model.yaml:
apiVersion: devices.kubeedge.io/v1alpha2
kind: DeviceModel
metadata:
  name: sensor-model
spec:
  properties:
  - name: temperature
    description: "Temperature sensor"
    type:
      int:
        accessMode: ReadWrite
        unit: "degree celsius"
  1. Apply the DeviceModel:
kubectl apply -f device-model.yaml
  1. Create a DeviceInstance YAML file named device-instance.yaml:
apiVersion: devices.kubeedge.io/v1alpha2
kind: Device
metadata:
  name: temperature-sensor
spec:
  deviceModelRef:
    name: sensor-model
  nodeSelector:
    nodeSelectorTerms:
    - matchExpressions:
      - key: "node-role.kubernetes.io/edge"
        operator: In
        values:
        - ""
  protocol:
    protocolName: modbus
    protocolConfig:
      address: 192.168.1.100
  1. Apply the DeviceInstance:
kubectl apply -f device-instance.yaml
  1. Verify the DeviceInstance:
kubectl get devices

This setup demonstrates how KubeEdge can be used to manage IoT devices at the edge, ensuring efficient and reliable operations.