Porting edgecore of kubeedge to armhf

1. Cross compile the edgecore

About this topic, Please refer to this :https://blog.csdn.net/changqing1990/article/details/99633983

2. Install docker

If you use ubuntu/debain/Pi, you can use the get_docker.sh provided by docker government. this scripts can detect you CPU arch and download the right install package.

$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sh get-docker.sh

If you non-debian system, such as yocto , you can access the https://download.docker.com/linux/static/stable/armhf/ to get the newest version static binary for docker-ce. Although you can use yocoto bb to build, but it’s a waste time 's way.

3. Create edge node

kube-proxy as a api-server’s proxy in every node, and it deployed by daemonset, that is once a k8s node is created, the kube-proxy will deployed to the node automaticlly.

But in kubeedge scene, kube-proxy in edge node is not needed. Because kube-proxy need to comunicate with api-server frequently,and not consider the case the network is lost at some times.
But edgenode is always in this state, and edgecore is designed for tolerating with this off line case.

To avoid the kube-proxy is deployed to the edgenode, you need taint the node, then other normal deployment will can’t deploy kube-proxy to this edgenode. If you want to deploy a app to edge node, you need to tolerate the taint node.

** Create the node**
node.json:

{
  "kind": "Node",
  "apiVersion": "v1",
  "metadata": {
    "name": "edgenode2",
    "labels": {
      "name": "edge-node",
      "node-role.kubernetes.io/edge": ""
    }
  }
}

kubectl apply -f node.json
## taint the node
kubectl taint node edgenode2 \ node.kubernetes.io/kubeedge=:NoExecute

To tolerate the taint node, you need to add toleration in your deployment yaml, such as:

.........
    spec:
      ........
      tolerations:
      - key: "node.kubernetes.io/kubeedge"
        operator: "Exists"
        effect: "NoExecute"
      nodeSelector:
        name:  "edge-node"
        .......

4. Run edgecore

4.1 Setting the config file

Set the edge.yaml as below:

mqtt:
    server: tcp://127.0.0.1:1883 # external mqtt broker url.
    internal-server: tcp://0.0.0.0:1884 # internal mqtt broker url.
    mode: 0 # 0: internal mqtt broker enable only. 1: internal and external mqtt broker enable. 2: external mqtt broker enable only.
    qos: 0 # 0: QOSAtMostOnce, 1: QOSAtLeastOnce, 2: QOSExactlyOnce.
    retain: false # if the flag set true, server will store the message and can be delivered to future subscribers.
    session-queue-size: 100 # A size of how many sessions will be handled. default to 100.

edgehub:
    websocket:
        url: wss://172.21.73.79:32143/e632aba927ea4ac2b575ec1603d56f10/edgenode2/events
        certfile: /etc/kubeedge/certs/edge.crt
        keyfile: /etc/kubeedge/certs/edge.key
        handshake-timeout: 30 #second
        write-deadline: 15 # second
        read-deadline: 15 # second
    quic:
        url: 127.0.0.1:10001
        cafile: /etc/kubeedge/ca/rootCA.crt
        certfile: /etc/kubeedge/certs/edge.crt
        keyfile: /etc/kubeedge/certs/edge.key
        handshake-timeout: 30 #second
        write-deadline: 15 # second
        read-deadline: 15 # second
    controller:
        protocol: websocket # websocket, quic
        heartbeat: 15  # second
        project-id: e632aba927ea4ac2b575ec1603d56f10
        node-id: edgenode2

edged:
    register-node-namespace: default
    hostname-override: edgenode2
    interface-name: eth0
    edged-memory-capacity-bytes: 1073741824
    node-status-update-frequency: 10 # second
    device-plugin-enabled: false
    gpu-plugin-enabled: false
    image-gc-high-threshold: 80 # percent
    image-gc-low-threshold: 40 # percent
    maximum-dead-containers-per-container: 1
    docker-address: unix:///var/run/docker.sock
    version: v1.15.0-kubeedge-v1.0.0
    runtime-type: docker
    remote-runtime-endpoint: unix:///var/run/dockershim.sock
    remote-image-endpoint: unix:///var/run/dockershim.sock
    runtime-request-timeout: 2
    podsandbox-image: kubeedge/pause-arm:3.1
    image-pull-progress-deadline: 600 # second
    cgroup-driver: cgroupfs
    node-ip: ""
    cluster-dns: ""
    cluster-domain: ""

mesh:
    loadbalance:
        strategy-name: RoundRobin

About mqtt part, you must set the mode for internal or outsides mqtt broker you use, and set the right mqtt broker url.

You should set edgehub. websocket.url as right IP address and edgenode name.

edged. hostname-override should be set as your edgenode name.
And edged.interface-name should be same as you ethernet inteface name.
In arm sides, docker pull image maybe watste some time, we set the ** image-pull-progress-deadline** as 600s.

4.2 Start edgecore service

We show a systemd service file as below:

## File: edgecore.service

[Unit]
Description=edgecore startup service
After=network.target docker.service

[Service]
Environment="GOARCHAIUS_CONFIG_PATH=/etc/kubeedge/edge"
Environment="database.source=/var/lib/edged/edge.db"
ExecStart=/usr/bin/edgecore > /var/log/edgecore.log 
Restart=on-failure

[Install]
WantedBy=multi-user.target

systemctl enable edgecore.service
systemctl start edgecore

5. Deploy a demo app to edgenode

### deployment-armv7.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      hostNetwork: true
      tolerations:
      - key: "node.kubernetes.io/kubeedge"
        operator: "Exists"
        effect: "NoExecute"
      nodeSelector:
        name:  "edge-node"
      restartPolicy: Always
      containers:
      - name: nginx
        image: arm32v7/nginx
        ports:
        - containerPort: 80
          hostPort: 80
        imagePullPolicy: IfNotPresent

kubectl apply -f deployment-armv7.yaml

Then check pod status by kubectl until pod state is running.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值