Developers
Resource
文档评分
Findability
Accuracy
Completeness
Readability
在线提单
论坛求助

部署配置

操作系统和软件要求

软件包部署所需操作系统、软件获取方式如表1所示。

表1 操作系统和软件要求

项目

版本信息

获取方式

OS

openEuler 24.03 LTS SP3 及以上版本

获取链接

Kubernetes

1.19.9

获取链接

containerd

1.7.5

获取链接

go

1.24.0

获取链接

在满足上述操作系统和软件要求的情况下,可以通过下述步骤使用UB-Network-Device-Plugin,从而实现容器URMA网络通信。

  1. 安装依赖。
    yum install -y make gcc
    wget https://go.dev/dl/go1.24.0.linux-arm64.tar.gz --no-check-certificate
    tar zxvf go1.24.0.linux-arm64.tar.gz -C /usr/local
    export PATH=/usr/local/go/bin:$PATH
    go version
  2. 下载UB-Network-Device-Plugin源码。
    git clone -b br_noncom_container_20260228 https://gitcode.com/openFuyao/ub-network-device-plugin.git
  3. 构建UB-Network-Device-Plugin插件二进制和镜像。
    cd ub-network-device-plugin/
    make
    • make:编译构建出二进制和镜像。如需要构建镜像,需要下载安装docker,因构建脚本中使用docker build构建镜像。
    • make build:仅构建二进制。
    • make image:仅构建镜像
  4. 查看是否构建正确,即_output/image路径下是否包含编译构建结果文件ub-network-device-plugin-v1.0.1-aarch64.tar。
    [root@master ub-network-device-plugin]# ll _output/image/
    total 227660 -rw------- 1 root root 233117696 Feb  4 06:17 ub-network-device-plugin-v1.0.1-aarch64.tar
  5. 进入tar镜像所在目录,在所有节点上导入ub-network-device-plugin-*.tar镜像。
    ctr -n k8s.io i import ub-network-device-plugin-v1.0.1-aarch64.tar
  6. 在K8S的master节点上,进入ub-network-device-plugin.yaml所在目录下,执行以下命令进行安装。
    kubectl apply -f ub-network-device-plugin.yaml

    ub-network-device-plugin.yaml文件内容如下供参考。

    apiVersion: v1
    kind: Namespace
    metadata:
      name: ub-network-system
    ---
    apiVersion: apps/v1
    kind: DaemonSet
    metadata:
      name: ub-network-device-plugin
      namespace: ub-network-system
    spec:
      selector:
        matchLabels:
          name: ub-network-device-plugin
      updateStrategy:
        rollingUpdate:
          maxUnavailable: 100%
        type: RollingUpdate
      template:
        metadata:
          labels:
            name: ub-network-device-plugin
        spec:
          hostNetwork: true
          securityContext:
            seccompProfile:
              type: RuntimeDefault
          priorityClassName: "system-node-critical"
          containers:
            - image: docker.io/library/ub-network-device-plugin-aarch64:v1.0.1    # 替换镜像仓地址和版本为实际值
              imagePullPolicy: IfNotPresent
              name: ub-network-device-plugin
              env:
                - name: LD_LIBRARY_PATH
                  value: "/lib:/lib64:/usr/lib64"
              command:
                - ub-network-device-plugin
              args:
                - --sync-interval=30s
                - --health-port=8088                             # 可选配置,默认8088;可根据实际环境端口规划替换,并同步替换探针配置中的 port 值
              securityContext:
                privileged: true
              volumeMounts:
                - name: kubelet-device-plugins-dir
                  mountPath: /var/lib/kubelet/device-plugins
                - name: runtime-sock                             # 以 containerd 为例,需根据实际情况替换为对应 CRI 地址;访问 CRI 获取 Sandbox 状态信息,组成网络命名空间,在设置网络命名空间时需要
                  mountPath: /run/containerd/containerd.sock
                - name: so                                       # 访问 UBS Engine 所需要的 lib 库路径
                  mountPath: /usr/lib64
                - name: ubse-sock-dir                            # UBS Engine 的 sock 文件所在目录
                  mountPath: /run/ubse
                - name: urma-admin                               # 设置网络命名空间的二进制命令
                  mountPath: /usr/bin/urma_admin
                - name: proc                                     # urma_admin 设置网络命名空间时需要访问此目录
                  mountPath: /proc
              livenessProbe:
                httpGet:
                  path: /healthz
                  port: 8088                                  # 与启动参数中的 --health-port 值一致
                initialDelaySeconds: 5
                periodSeconds: 10
                failureThreshold: 3
              readinessProbe:
                httpGet:
                  path: /healthz
                  port: 8088                                  # 与启动参数中的 --health-port 值一致
                initialDelaySeconds: 5
                periodSeconds: 10
                failureThreshold: 3
              resources:
                limits:
                  cpu: 500m
                  memory: 500Mi
                requests:
                  cpu: 50m
                  memory: 50Mi
          volumes:
            - name: kubelet-device-plugins-dir
              hostPath:
                path: /var/lib/kubelet/device-plugins
                type: Directory
            - name: so
              hostPath:
                path: /usr/lib64
                type: Directory
            - name: proc
              hostPath:
                path: /proc
                type: Directory
            - name: runtime-sock
              hostPath:
                path: /run/containerd/containerd.sock
                type: Socket
            - name: ubse-sock-dir
              hostPath:
                path: /run/ubse
                type: Directory
            - name: urma-admin
              hostPath:
                path: /usr/bin/urma_admin
                type: File
    

    文件应用成功后,回显如下所示。

    namespace/ub-network-system created
    daemonset.apps/ub-network-device-plugin created

    默认在所有节点启动UB-Network-Device-Plugin,如果实际集群存在UB和非UB节点场景,需要通过配置节点亲和性配置,控制UB-Network-Device-Plugin实例只部署在UB节点。

  7. 安装完成后查看Pod状态,UB-Network-Device-Plugin以DaemonSet形式部署,Pod数目应该和节点数目一致。
    kubectl get pod -n ub-network-system

    回显如下:

    NAMESPACE           NAME                                       READY   STATUS    RESTARTS       AGE   IP               NODE      NOMINATED NODE   READINESS GATES
    ub-network-system   ub-network-device-plugin-8fksp             1/1     Running   0              25s   141.61.85.166    master    <none>           <none>
    ub-network-system   ub-network-device-plugin-ltpqh             1/1     Running   0              25s   141.61.85.168    worker1   <none>           <none>

在UB-Network-Device-Plugin容器部署成功后,还需要在业务容器中对URMA设备进行配置,步骤如下:

  1. 将业务容器镜像上传到需要pod运行的节点工作目录,如~/workspace。
    ctr -n k8s.io image import <image-path> # image-path 即上一步制作的镜像存放的路径
    unpacking <image:label> (sha256:xxxxx)...done # unpacking后的字段为操作系统返回的镜像的名字和label,启动pod时要用
  2. 将URMA通信设备的配置追加到业务容器yaml中,示例如下,重点注意加粗的配置项来使能UB容器通信。
    apiVersion: v1
    kind: Pod
    metadata:
      name: urma-test
    spec:
      nodeName: master
      hostNetwork: false
      containers:
      - name: urma-test
        image: service-test:v1.0.1 # 该字段为上传镜像时获取到的,根据实际填写
        imagePullPolicy: IfNotPresent
        command: ["/bin/sh", "-c", "while true; do sleep 1000; done"]
        resources:
          requests:
            cpu: "1"
            memory: "1Gi"
            unifiedbus.com/ub_net_device: 1 # 标准配置:需共享单个设备,无需额外调整
          limits:
            cpu: "1"
            memory: "1Gi"
            unifiedbus.com/ub_net_device: 1 # 标准配置:需共享单个设备,无需额外调整
        securityContext:
          privileged: false # root用户非特权
          capabilities:
            add: ["SYS_ADMIN"]
  3. 拉起业务容器。
    kubectl apply -f <yaml-name> # yaml-name为上面写入yaml模板的文件名