UCS Tools 中的 UCX 支持
本文档假设两个应用程序容器(一个带有 UCX 服务器,另一个带有 UCX 客户端)已经可用。
示例 UCX 服务器微服务
以下是示例 UCX 服务器微服务的 manifest 文件的内容
type: msapplication
specVersion: 2.5.0
name: ucf.svc.server-ucx
chartName: server-ucx
description: default description
version: 0.0.1
displayName: ""
category:
functional: ""
industry: ""
tags: []
keywords: []
nSpectId: NSPECT-0000-0000
publish: false
ingress-endpoints:
- name: ucx-server
description: UCX server
scheme: ucx
data-flow: in-out # Or in or out
params:
networks: "rdma-net-ipam"
#> type: string
#> description: available networks for UCX endpoint
serviceNetwork: "rdma-net-ipam"
#> type: string
#> description: network to which UCX endpoint's service should be connected
---
spec:
- name: server-ucx-deployment
type: ucf.k8s.app.deployment
parameters:
apptype: stateless
- name: "server-ucx-container"
type: ucf.k8s.container
parameters:
image:
repository: gitlab-master.nvidia.com:5005/adv-dev-team/distributed-ai/deepstream-sdk/ucf-ms
tag: "server"
securityContext:
privileged: true
capabilities:
add:
- CAP_SYS_PTRACE
volumeMounts:
- mountPath: /dev/shm
name: dshm
- name: graph-config
subPath: parameters.yaml
mountPath: /workspace/sample_graph/server-parameters.yaml
- name: dshm
type: ucf.k8s.volume
parameters:
emptyDir:
medium: Memory
- name: graph-config
type: ucf.k8s.volume
parameters:
configMap:
name: ucx-graph-config-server
- name: ucx-graph-config-server
type: ucf.k8s.configmap
parameters:
name: ucx-graph-config-server
data:
parameters.yaml: |
---
components:
- name: nv_ds_single_src_input0
parameters:
uri: file:///opt/nvidia/deepstream/deepstream/samples/streams/sample_1080p_h265.mp4
name: NvDsSingleSrcInput
---
components:
- name: nv_ds_ucx_server_sink48
parameters:
port: 7174
addr: 0.0.0.0
name: NvDsUcxServerSink
---
components:
- name: gst_caps_filter77
parameters:
caps: video/x-raw(memory:NVMM), width=1280, height=720
name: GstCapsFilter
- name: server-ucx-service
type: ucf.k8s.service
parameters:
labels:
service.kubernetes.io/service-proxy-name: multus-proxy
annotations:
k8s.v1.cni.cncf.io/service-network: $params.serviceNetwork
ports:
- port: 7174
name: ucx-server
protocol: UDP
clusterIP: None
- name: podAnnotations
type: ucf.k8s.podAnnotations
parameters:
annotations:
k8s.v1.cni.cncf.io/networks: $params.networks
manifest 文件中需要注意的要点是
一个 scheme 为
ucx
的 Ingress 端点一个参数
networks
,用于指定 Pod 应使用的网络一个参数
serviceNetwork
,用于指定 Kubernetes 服务应使用的网络为这两个配置设置参数允许应用程序开发人员在部署时设置这些配置
一个名为
dshm
的基于 Memory 的 emptyDir 卷,必须在使用 UCX 的容器中挂载到/dev/shm
位置一个
ucf.k8s.service
组件,用于 UCX 服务器的 Kubernetes 服务抽象,具有service.kubernetes.io/service-proxy-name
标签设置为multus-proxy
k8s.v1.cni.cncf.io/service-network
注解设置为参数$params.serviceNetwork
一个名为
ucx-server
的端口,与 Ingress 端点名称匹配clusterIP
设置为None
一个
podAnnotations
组件,其注解k8s.v1.cni.cncf.io/networks
设置为参数$params.networks
示例 UCX 客户端微服务
以下是示例 UCX 客户端微服务的 manifest 文件的内容
type: msapplication
specVersion: 2.5.0
name: ucf.svc.client-ucx
chartName: client-ucx
description: default description
version: 0.0.1
displayName: ""
category:
functional: ""
industry: ""
tags: []
keywords: []
nSpectId: NSPECT-0000-0000
publish: false
egress-endpoints:
- name: ucx-client
description: Client UCX EP
protocol: UDP
scheme: ucx # Or grpc / rtsp / asyncio / none
mandatory: True # Or False
data-flow: in-out # Or in or out
params:
networks: "rdma-net-ipam"
#> type: string
#> description: available networks for UCX endpoint
---
spec:
- name: client-ucx-deployment
type: ucf.k8s.app.deployment
parameters:
apptype: job
- name: "client-ucx-container"
type: ucf.k8s.container
parameters:
ucxConfig:
name: ucx-graph-config
mountPath: /workspace/sample_graph/client-parameters.yaml
image:
repository: gitlab-master.nvidia.com:5005/adv-dev-team/distributed-ai/deepstream-sdk/ucf-ms
tag: "client"
securityContext:
privileged: true
capabilities:
add:
- CAP_SYS_PTRACE
volumeMounts:
- mountPath: /dev/shm
name: dshm
- name: dshm
type: ucf.k8s.volume
parameters:
emptyDir:
medium: Memory
- name: ucx-graph-config
type: ucf.k8s.ucx-config
parameters:
name: ucx-graph-config
data: |
---
components:
- name: nv_ds_ucx_client_src7
parameters:
addr: $egress.ucx-client.address
port: {{ index .Values.egress "ucx-client" "port" }}
name: NvDsUcxClientSrc
---
components:
- name: gst_caps_filter9
parameters:
caps: video/x-raw(memory:NVMM), format=NV12, width=1280, height=720, framerate=30/1
name: GstCapsFilter
---
components:
- name: nv_ds_video_renderer13
parameters:
video-sink: 1
name: NvDsVideoRenderer
- name: restartPolicy
type: ucf.k8s.restartPolicy
parameters:
policy: OnFailure # Always / OnFailure / Never
- name: dnsPolicy
type: ucf.k8s.dnsPolicy
parameters:
policy: ClusterFirst
- name: podAnnotations
type: ucf.k8s.podAnnotations
parameters:
annotations:
k8s.v1.cni.cncf.io/networks: $params.networks
manifest 文件中需要注意的要点是
一个 scheme 为
ucx
的 Egress 端点一个参数
networks
,用于指定 Pod 应使用的网络配置参数允许应用程序开发人员在部署时设置配置
一个名为
dshm
的基于 Memory 的 emptyDir 卷,必须在使用 UCX 的容器中挂载到/dev/shm
位置一个名为
ucx-graph-config
的ucf.k8s.ucx-config
组件,可以用作使用 UCX 的应用程序的配置文件,具有配置文件内容必须设置为组件的
data
参数上的字符串占位符
$egress.<egress-endpoint-name>.address
(例如,本例中为$egress.ucx-client.address
)必须在需要 UCX 服务的 IP 地址的任何地方使用占位符
{{ index .Values.egress "<egress-endpoint-name>" "port" }}
(例如,本例中为{{ index .Values.egress "ucx-client" "port" }}
)必须在需要 UCX 服务的端口的任何地方使用
通过设置带有
ucxConfig
参数的参数,将配置文件挂载到应用程序容器(此处为client-ucx-container
)name
设置为ucf.k8s.ucx-config
组件的名称(本例中为ucx-graph-config
)mountPath
设置为应挂载配置文件的路径
一个
podAnnotations
组件,其注解k8s.v1.cni.cncf.io/networks
设置为参数$params.networks
在 UCS 应用程序中添加和连接带有 UCX 端点的微服务
带有 UCX 端点的微服务可以像带有其他端点类型的微服务一样添加和连接。
以下是包含前面章节中描述的微服务的此类应用程序的示例
specVersion: 2.5.0
version: 0.0.1
name: ucx-app
description: Sample UCX app
dependencies:
- ucf.svc.server-ucx:0.0.1
- ucf.svc.client-ucx:0.0.1
components:
- name: server-ucx
type: ucf.svc.server-ucx
parameters:
imagePullSecrets:
- name: <image-pull-secret-name>
networks: "rdma-net-ipam"
serviceNetwork: rdma-net-ipam
resources:
limits:
rdma/rdma_shared_device_a: 1
requests:
rdma/rdma_shared_device_a: 1
- name: client-ucx
type: ucf.svc.client-ucx
parameters:
imagePullSecrets:
- name: <image-pull-secret-name>
networks: "rdma-net-ipam"
resources:
limits:
rdma/rdma_shared_device_a: 1
requests:
rdma/rdma_shared_device_a: 1
connections:
client-ucx/ucx-client: server-ucx/ucx-server
应用程序中需要注意的要点是
在两个微服务上设置的
networks
参数,指示微服务的 Pod 应使用的网络接口。(微服务必须实现一个参数,以便应用程序可以设置此参数。)在 server 微服务上设置的
serviceNetwork
参数,指示微服务的 Kubernetes Service 应使用的网络接口。(微服务必须实现一个参数,以便应用程序可以设置此参数。)必须使用资源限制和请求为微服务分配 NIC 资源(例如,本例中
rdma/rdma_shared_device_a
设置为 1)。这将取决于基础设施和网络运营商配置。
部署带有 UCX 的 UCS 应用程序
硬件要求
支持 RDMA 的硬件:Mellanox ConnectX-5 NIC 或更新版本
支持 GPUDirect 的 NVIDIA GPU 和驱动程序,例如 Quadro RTX 6000/8000 或 Tesla T4 或 Tesla V100 或 Tesla V100。(仅限 GPU-Direct)
先决条件
Network Operator
请参阅 Network Operator 文档 - https://docs.nvda.net.cn/networking/display/COKAN10/Network+Operator
安装 Network Operator
启用辅助网络配置
启用 RDMA Shared Device Plugin
启用 NVIDIA OFED Driver
部署 NetworkAttachmentDefinition CRD 以定义 RDMA 设备网络
Multus Service Controller
使用以下命令安装 Multus Service Controller
kubectl apply -f https://raw.githubusercontent.com/k8snetworkplumbingwg/multus-service/main/deploy-nft.yml
禁用 coredns 缓存
使用以下命令编辑 coredns configmap,如果指定了 ttl
,则将其更改为 0
$ kubectl edit configmap coredns -n kube-system
部署应用程序
确保 networks
和 serviceNetwork
与附加到 rdma 设备的 NetworkAttachmentDefinition
CRD 中提供的网络名称匹配。还要确保 rdma 设备资源名称(示例中为 rdma_shared_device_a
)正确。这由 rdma 共享设备插件确定。
使用以下命令安装应用程序
helm install <release-name> <application-helm-chart>