KubeEdge v1.17.0發佈!數據處理能力與易用性全面提升

本文分享自華爲雲社區《KubeEdge v1.17.0發佈!數據處理能力與易用性全面提升》 ,作者: 雲容器大未來。

KubeEdge社區v1.17.0 版本正式發佈。新版本爲邊緣節點和設備帶來了更多的新能力,同時持續在易用性上做了提升。

kubeedge.png

KubeEdge v1.17.0 新增特性:

  • 支持邊緣 Pods 使用 InClusterConfig 訪問 Kube-APIServer

  • Mapper 支持流數據上報

  • 支持邊緣子模塊自啓動

  • 引入 keadm ctl 命令,支持在邊緣查詢和重啓 pod

  • 易用性提升:基於 Keadm 的部署能力增強

  • Mapper 框架添加 MySQL 數據庫

  • 升級 K8s 依賴到 v1.28

新特性概覽

支持邊緣 Pods 使用 InClusterConfig 訪問 Kube-APIServer

Kubernetes 支持 Pods 使用 InClusterConfig 機制直接訪問 Kube-APIServer,然而在邊緣場景,邊緣 Pods 和 Kube-APIServer 通常不在一個網絡環境下,無法直接訪問。在1.17.0 新版本中,通過開啓 MetaServer 和 DynamicController 模塊,邊緣 Pods 同樣可以使用 InClusterConfig 機制直接訪問 Kube-APIServer。

該特性在本版本中作爲 Alpha 特性發布,如果你需要使用,您需要開啓邊緣 List-Watch 開關並配置 requireAuthorization的featureGates。

  • 在使 keadm init 啓動 CloudCore 時,指定 cloudCore.featureGates.requireAuthorization=true 以及 cloudCore.modules.dynamicController.enable=true。
  • 啓動 EdgeCore 後,按如下修改 edgecore.yaml 後重啓 EdgeCore。
apiVersion: edgecore.config.kubeedge.io/v1alpha2
kind: EdgeCore
featureGates:
  requireAuthorization: true
modules:
  ...
  metaManager:
    metaServer:
      enable: true
更多信息可參考:

https://github.com/kubeedge/kubeedge/pull/5524

https://github.com/kubeedge/kubeedge/pull/5541

Mapper 支持流數據上報

1.17 版本中,針對當前 Mapper 只能處理離散型的設備數據,無法處理流數據的問題,爲 Mapper-Framework 提供視頻流數據處理的能力。在新版本中,能夠支持 KubeEdge 管理邊緣攝像頭設備,獲取攝像頭採集的視頻流,並將視頻流保存爲幀文件或者視頻文件,增強 KubeEdge 邊緣設備管理能力。

邊緣攝像頭設備管理

1.17 版本提供基於 Onvif 協議的內置 Mapper,實現 Onvif 設備驅動功能,能夠根據用戶配置文件中的定義連接攝像頭設備,獲取設備的鑑權文件與 RTSP 視頻流,將 Onvif 攝像頭設備納管進 KubeEdge 集羣。Onvif 設備的一個示例 device-instance 配置文件如下:

apiVersion: devices.kubeedge.io/v1beta1
kind: Device
metadata:
  name: onvif-device-01
  namespace: default
spec:
  deviceModelRef:
    name: onvif-model   # need to be the same as the model name defined in onvif-model.yaml
  protocol:
    protocolName: onvif
    configData:
      url: 192.168.168.64:80   # Replace it with the address of your own onvif camera
      userName: admin          # Replace it with the username of your own onvif camera
      password: /etc/secret/password   # Fill in the fields according to your secret.yaml
  nodeName: edge-node          # Replace it with your edge node name
  properties:
    - name: getURI
      visitors:
        protocolName: onvif
        configData:
          url: 192.168.168.64:80
          userName: admin
          password: /etc/secret/password
          dataType: string

視頻流數據處理

新版本增強 Mapper-Framework 數據面能力,內置流數據處理功能。用戶能夠在 device-instance 文件中進行配置,將邊緣攝像頭設備上報的視頻流截取保存爲視頻片段文件以及視頻幀文件,流數據處理的 device-instance 文件示例如下:

apiVersion: devices.kubeedge.io/v1beta1
kind: Device
metadata:
  name: onvif-device-01
...
properties:
  - name: saveFrame                  # Convert video stream into frame
    visitors:
      protocolName: onvif
      configData:
        format: jpg                  # Frame file format
        outputDir: /tmp/case/        # Directory for output frame files
        frameCount: 30               # Number of output frames
        frameInterval: 1000000       # Time interval between frames (The unit is nanoseconds)
        dataType: stream
  - name: saveVideo                  # Convert video streams into video clips
    visitors:
      protocolName: onvif
      configData:
        frameCount: 1000             # The number of frames the video clip contains
        format: mp4                  # Video clip format
        outputDir: /tmp/case/        # Directory for output video clip
        videoNum: 2                  # Number of video clips
        dataType: stream

更多信息可參考:

https://github.com/kubeedge/kubeedge/pull/5448

https://github.com/kubeedge/kubeedge/pull/5514

https://github.com/kubeedge/mappers-go/pull/127

支持邊緣子模塊自啓動

由於配置或者可恢復的環境問題,例如進程啓動順序等,導致 EdgeCore 啓動失敗。例如,當 containerd.socket 沒有就緒時,Edged 啓動 Kubelet 失敗會導致 EdgeCore 直接退出。

在新版本中,我們改進了 Beehive 框架,支持邊緣子模塊重啓。用戶可以通過啓動 moduleRestart featureGates,將 EdgeCore 的子模塊設置爲自動重啓,而不是整個 EdgeCore 退出。

該特性在本版本中作爲 Alpha 特性發布,如果你需要使用,您需要配置 moduleRestart 的 featureGates。

apiVersion: edgecore.config.kubeedge.io/v1alpha2
kind: EdgeCore
featureGates:
  moduleRestart: true

更多信息可參考:

https://github.com/kubeedge/kubeedge/pull/5513

https://github.com/kubeedge/kubeedge/pull/5514

引入 keadm ctl 命令,支持在邊緣查詢和重啓 pod

當邊緣節點離線時,我們無法通過 kubectl 查看邊緣節點上的 pod,在 1.17 中可以在邊緣節點上通過 keadm ctl get/restart pod [flag] 對 pod 進行查詢或重啓。

如果需要使用該特性,您需要開啓 metaserver 開關。

  • keadm ctl get pod 的可選參數如下:
[root@centos-2 bin]# keadm ctl get pod -h
Get pods in edge node

Usage:
  keadm ctl get pod [flags]

Flags:
  -A, --all-namespaces     If present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace
  -h, --help               help for pod
  -n, --namespace string   Specify a namespace (default "default")
  -o, --output string      Output format. One of: (json, yaml, name, go-template, go-template-file, template, templatefile, jsonpath, jsonpath-as-json, jsonpath-file, custom-columns, custom-columns-file, wide)
  -l, --selector string    Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)
  • keadm ctl restart pod 的可選參數如下:
[root@centos-2 bin]# keadm ctl restart pod -h
Restart pods in edge node

Usage:
  keadm ctl restart pod [flags]

Flags:
  -h, --help               help for pod
  -n, --namespace string   Specify a namespace (default "default")
Demo 演示:
[root@centos-2 bin]# alias kectl='keadm ctl'
[root@centos-2 bin]# kectl get pod -owide -A
NAMESPACE   NAME                                READY   STATUS    RESTARTS      AGE   IP               NODE       NOMINATED NODE   READINESS GATES
default     nginx-deployment-58b54fbd94-f5q7p   1/1     Running   1 (20m ago)   22m   10.88.0.2        centos-2   <none>           <none>
kubeedge    edge-eclipse-mosquitto-scvrk        1/1     Running   1 (16m ago)   28m   192.168.94.106   centos-2   <none>           <none>

[root@centos-2 bin]# kectl restart pod -n kubeedge    edge-eclipse-mosquitto-scvrk
393cbcac4b484a4a28eee7dd2d63b33137a10a84d5f6eed6402b9a23efc6aef0
af4059137ced56b365da7e1c43d3ea218e3090ab7644a105651ca4661ddf26f0

[root@centos-2 bin]# kectl get pod -owide -A
NAMESPACE   NAME                                READY   STATUS    RESTARTS      AGE   IP               NODE       NOMINATED NODE   READINESS GATES
default     nginx-deployment-58b54fbd94-f5q7p   1/1     Running   1 (21m ago)   23m   10.88.0.2        centos-2   <none>           <none>
kubeedge    edge-eclipse-mosquitto-scvrk        1/1     Running   2 (10s ago)   29m   192.168.94.106   centos-2   <none>           <none>

更多信息可參考:

https://github.com/kubeedge/kubeedge/pull/5535

https://github.com/kubeedge/kubeedge/pull/5504

易用性提升:基於 Keadm 的部署能力增強

  • 將命令 keadm generate 更改爲 keadm manifest;
[root@centos-2 bin]# keadm --help|grep manifest 
  manifest    Checks and generate the manifests.

example:
[root@centos-1 keepalived]# keadm manifest --advertise-address=<cloud-ip> --profile version=v1.17.0
  • 在 keadm join 添加一個鏡像倉庫參數: image-repository,以支持自定義鏡像倉庫;
[root@centos-2 bin]# keadm  join -h|grep image-repository
      --image-repository string          Use this key to decide which image repository to pull images from

example:
[root@centos-2 bin]# keadm join --cloudcore-ipport <cloud-ip>:10000 --kubeedge-version=1.17.0 --remote-runtime-endpoint=unix:///run/cri-dockerd.sock --image-repository my.harbor.cn/kubeedge --token xxxx
  • 將 keadm reset 命令進行三級拆分,拆分成 keadm reset cloud 和 keadm reset edge, keadm reset 仍然被保留,使用時 cloudcore 和 edgecore 都會被卸載,新增的三級命令 keadm reset cloud 和 keadm reset edge 分別只卸載 cloudcore 和 edgecore。

[root@centos-2 bin]# keadm  reset --help
...
Available Commands:
  cloud       Teardowns CloudCore component
  edge        Teardowns EdgeCore component
Flags:
      --force                Reset the node without prompting for confirmation
  -h, --help                 help for reset
      --kube-config string   Use this key to set kube-config path, eg: $HOME/.kube/config (default "/root/.kube/config")

[root@centos-2 bin]# keadm  reset cloud --help
...
Flags:
      --force                Reset the node without prompting for confirmation
  -h, --help                 help for cloud
      --kube-config string   Use this key to set kube-config path, eg: $HOME/.kube/config (default "/root/.kube/config")

[root@centos-2 bin]# keadm  reset edge --help
...
Flags:
      --force   Reset the node without prompting for confirmation
  -h, --help    help for edge

更多信息可參考:

https://github.com/kubeedge/kubeedge/issues/5317

https://github.com/kubeedge/kubeedge/pull/5462

https://github.com/kubeedge/kubeedge/pull/5463

https://github.com/kubeedge/kubeedge/pull/5540

Mapper 框架添加 MySQL 數據庫

在 1.17 的 Mapper-Framework 中,數據推送模塊新增了 MySQL 數據庫,如果用戶想使用 MySQL 作爲某個 property 的 PushMethod,可以在 device instance 的對應 property 下, 通過如下配置即可:
apiVersion: devices.kubeedge.io/v1beta1
kind: Device
...
spec:
  properties:
    - name: xxx
      ...
      pushMethod:
        dbMethod:
          mysql:
            mysqlClientConfig:
              addr: 127.0.0.1:3306    #the url to connect to the mysql database.
              database: kubeedge      #database name
              userName: root          #user name

更多信息可參考:https://github.com/kubeedge/kubeedge/pull/5376

升級 K8s 依賴到 v1.28

新版本將依賴的 Kubernetes 版本升級到 v1.28.6,您可以在雲和邊緣使用新版本的特性。

更多信息可參考:https://github.com/kubeedge/kubeedge/pull/5412

版本升級注意事項

自 v1.17.0 起,我們推薦在使用 keadm 安裝 KubeEdge 時使用 --kubeedge-version=<version> 來指定具體版本,--profile version=<version> 會逐漸廢棄。

致謝

感謝 KubeEdge 社區技術指導委員會 (TSC)、各 SIG 成員對 v1.17 版本開發的支持與貢獻,未來 KubeEdge 將持續在新場景探索與支持、穩定性、安全性、可擴展性等方面持續發展與演進!

相關鏈接

Release Notes:https://github.com/kubeedge/kubeedge/blob/master/CHANGELOG/CHANGELOG-1.17.md

 

點擊關注,第一時間瞭解華爲雲新鮮技術~

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章