|Index|SUSE Telco Cloud ドキュメント|Telco機能の設定|SR-IOV
適用項目 SUSE Telco Cloud 3.6

39 SR-IOV

SR-IOV(Single Root I/O Virtualization)を使用すると、ネットワークアダプターなどの単一の物理デバイスが、そのリソースを複数の`PCIe`ハードウェア関数に分離できます。これにより、さまざまなアプリケーションがリソースに直接アクセスできるようになります。

クラスターに`SR-IOV`をデプロイするために、2つの異なる方法を提供しています。

ネットワークデバイスにNetwork Operatorを使用し、vRANアクセラレータにDevice Pluginを使用するというように、両方のソリューションが必要な稀なケースでは、それらを別々のKubernetesネームスペースにデプロイする必要があります。この分離は、2つのデプロイメント間の競合を防ぐために不可欠です。

39.1 オプション1:SR-IOV Network Device Plugin DaemonsetおよびconfigMap

SR-IOV Network Device Pluginは、PCI物理機能(PF)やその仮想機能(VF)などのネットワークリソースをKubernetesホスト上で検出し、アドバタイズします。

  • デバイスプラグイン用のconfig mapを準備します

SR-IOVリソースプールを定義するconfig mapを作成する必要があります。`lspci`コマンドを実行して情報を取得します。

$ lspci | grep -i acc
07:00.0 Processing accelerators: Intel Corporation Device 57c2
07:00.1 Processing accelerators: Intel Corporation Device 57c3
07:00.2 Processing accelerators: Intel Corporation Device 57c3
07:00.3 Processing accelerators: Intel Corporation Device 57c3
07:00.4 Processing accelerators: Intel Corporation Device 57c3
07:00.5 Processing accelerators: Intel Corporation Device 57c3
07:00.6 Processing accelerators: Intel Corporation Device 57c3
07:00.7 Processing accelerators: Intel Corporation Device 57c3
07:01.0 Processing accelerators: Intel Corporation Device 57c3
07:01.1 Processing accelerators: Intel Corporation Device 57c3
07:01.2 Processing accelerators: Intel Corporation Device 57c3
07:01.3 Processing accelerators: Intel Corporation Device 57c3
07:01.4 Processing accelerators: Intel Corporation Device 57c3
07:01.5 Processing accelerators: Intel Corporation Device 57c3
07:01.6 Processing accelerators: Intel Corporation Device 57c3
07:01.7 Processing accelerators: Intel Corporation Device 57c3
07:02.0 Processing accelerators: Intel Corporation Device 57c3
0a:00.0 Processing accelerators: Intel Corporation Device 57c2

$ lspci | grep -i net
19:00.0 Ethernet controller: Broadcom Inc. and subsidiaries BCM57504 NetXtreme-E 10Gb/25Gb/40Gb/50Gb/100Gb/200Gb Ethernet (rev 11)
19:00.1 Ethernet controller: Broadcom Inc. and subsidiaries BCM57504 NetXtreme-E 10Gb/25Gb/40Gb/50Gb/100Gb/200Gb Ethernet (rev 11)
19:00.2 Ethernet controller: Broadcom Inc. and subsidiaries BCM57504 NetXtreme-E 10Gb/25Gb/40Gb/50Gb/100Gb/200Gb Ethernet (rev 11)
19:00.3 Ethernet controller: Broadcom Inc. and subsidiaries BCM57504 NetXtreme-E 10Gb/25Gb/40Gb/50Gb/100Gb/200Gb Ethernet (rev 11)
51:00.0 Ethernet controller: Intel Corporation Ethernet Controller E810-C for QSFP (rev 02)
51:00.1 Ethernet controller: Intel Corporation Ethernet Controller E810-C for QSFP (rev 02)
51:01.0 Ethernet controller: Intel Corporation Ethernet Adaptive Virtual Function (rev 02)
51:01.1 Ethernet controller: Intel Corporation Ethernet Adaptive Virtual Function (rev 02)
51:01.2 Ethernet controller: Intel Corporation Ethernet Adaptive Virtual Function (rev 02)
51:01.3 Ethernet controller: Intel Corporation Ethernet Adaptive Virtual Function (rev 02)
51:11.0 Ethernet controller: Intel Corporation Ethernet Adaptive Virtual Function (rev 02)
51:11.1 Ethernet controller: Intel Corporation Ethernet Adaptive Virtual Function (rev 02)
51:11.2 Ethernet controller: Intel Corporation Ethernet Adaptive Virtual Function (rev 02)
51:11.3 Ethernet controller: Intel Corporation Ethernet Adaptive Virtual Function (rev 02)

SR-IOV Device Pluginは、Kubernetesが公開すべきハードウェアリソースを定義するJSONファイルを含むconfigMapを使用します。この構成は、2つのコアとなる概念、selectors(ハードウェア検出用)と`resources`(Kubernetes公開用)に基づいています。

resource`とは、Podが消費する名前付きエンティティです(例: `rancher.io/intel_fec_5g)。リソースは、次の2つのタイプのいずれかとして定義できます。

  • accelerator:vRANアクセラレータカード(ACC100/vRAN Boostなど)に使用されます。

  • netdevice:標準のネットワークインタフェース(NIC)に使用されます。

ノード上のハードウェアをフィルタリングするために`selectors`を使用してターゲットデバイスを定義します。

  • vendors:`8086` (Intel)

  • devices:`57c3` (FEC VF)、1889 (NIC VF)

  • drivers: vfio-pci

  • pfNames: p2p1 (物理インターフェイス名)

ネットワークカードの場合、物理機能(PF)から仮想機能(VF)のサブセットを選択することもできます。

  • pfNames: ["eth1#1,2,3,4,5,6"] または [eth1#1-6]

ポッドがデバイスを要求できるようにするには、各リソースに名前を付ける必要があります。この名前は、プレフィックスと名前で構成されます。

  • resourceName: pci_sriov_net_bh_dpdk

  • resourcePrefix: rancher.io

ポッドは、結合されたリソース名 rancher.io/pci_sriov_net_bh_dpdk を要求します。

注記
注記

このドキュメントには、すべての可能なセレクターが記載されているわけではありません。リソースの種類によって、使用するセレクターのセットが異なります。詳細については、 SR-IOV Network Device Pluginリポジトリを参照してください。

以下のConfigMapは、vRANアクセラレータカード(FEC)用に1つ、2つの異なるNICポート用に2つ、合計3つのリソースを作成する例です。

FECカードの場合は、まずデバイスIDとVFIOトークンを取得する必要があります。前提条件については、第41章 「vRANアクセラレーション(Intel ACC100/VRB1/VRB2)」の章の手順に従ってください。

apiVersion: v1
kind: ConfigMap
metadata:
  name: sriovdp-config
  namespace: kube-system
data:
  config.json: |
    {
        "resourceList": [
            {
                "resourcePrefix": "rancher.io",
                "resourceName": "intel_fec_5g",
                "deviceType": "accelerator",
                "selectors": {
                    "vendors": ["8086"],
                    "devices": ["57c3"]
                },
                "additionalInfo": {
                      "*": {
                        "VFIO_TOKEN": "00112233-4455-6677-8899-aabbccddeeff"
                      }
                  }
            },
            {
                "resourcePrefix": "rancher.io",
                "resourceName": "intel_sriov_odu",
                "deviceType": "netdevice",
                "selectors": {
                    "vendors": ["8086"],
                    "devices": ["1889"],
                    "drivers": ["vfio-pci"],
                    "pfNames": ["p2p1"]
                }
            },
            {
                "resourcePrefix": "rancher.io",
                "resourceName": "intel_sriov_oru",
                "deviceType": "netdevice",
                "selectors": {
                    "vendors": ["8086"],
                    "devices": ["1889"],
                    "drivers": ["vfio-pci"],
                    "pfNames": ["p2p2"]
                }
            }
        ]
    }
  • デバイスプラグインをデプロイするために`daemonset`ファイルを準備します。

デバイスプラグインは複数のアーキテクチャ(arm、amd、ppc64le)をサポートしているため、アーキテクチャごとに複数の`daemonset`をデプロイすることで、同じファイルを異なるアーキテクチャに使用できます。

apiVersion: v1
kind: ServiceAccount
metadata:
  name: sriov-device-plugin
  namespace: kube-system
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: kube-sriov-device-plugin-amd64
  namespace: kube-system
  labels:
    tier: node
    app: sriovdp
spec:
  selector:
    matchLabels:
      name: sriov-device-plugin
  template:
    metadata:
      labels:
        name: sriov-device-plugin
        tier: node
        app: sriovdp
    spec:
      hostNetwork: true
      nodeSelector:
        kubernetes.io/arch: amd64
      tolerations:
      - key: node-role.kubernetes.io/master
        operator: Exists
        effect: NoSchedule
      serviceAccountName: sriov-device-plugin
      containers:
      - name: kube-sriovdp
        image: registry.suse.com/rancher/hardened-sriov-network-device-plugin:v3.9.0-build20250425
        imagePullPolicy: IfNotPresent
        args:
        - --log-dir=sriovdp
        - --log-level=10
        securityContext:
          privileged: true
        resources:
          requests:
            cpu: "250m"
            memory: "40Mi"
          limits:
            cpu: 1
            memory: "200Mi"
        volumeMounts:
        - name: devicesock
          mountPath: /var/lib/kubelet/
          readOnly: false
        - name: log
          mountPath: /var/log
        - name: config-volume
          mountPath: /etc/pcidp
        - name: device-info
          mountPath: /var/run/k8s.cni.cncf.io/devinfo/dp
      volumes:
        - name: devicesock
          hostPath:
            path: /var/lib/kubelet/
        - name: log
          hostPath:
            path: /var/log
        - name: device-info
          hostPath:
            path: /var/run/k8s.cni.cncf.io/devinfo/dp
            type: DirectoryOrCreate
        - name: config-volume
          configMap:
            name: sriovdp-config
            items:
            - key: config.json
              path: config.json
  • configMapと`daemonset`を適用すると、デバイスプラグインがデプロイされ、インターフェースが検出されてポッドで使用可能になります。

    $ kubectl get pods -n kube-system | grep sriov
    kube-system  kube-sriov-device-plugin-amd64-twjfl  1/1  Running  0  2m
  • すべてのノードで、インターフェースが検出され、ポッドで使用可能になったかどうかを確認します。

    $ kubectl get nodes -o json | jq '.items[] | {name: .metadata.name, allocatable: .status.allocatable}'
    {
      "name": "node1.suse.edge.com",
      "allocatable": {
          "cpu": "64",
          "ephemeral-storage": "256196109726",
          "hugepages-1Gi": "40Gi",
          "hugepages-2Mi": "0",
          "rancher.io/intel_fec_5g": "16",
          "rancher.io/intel_sriov_odu": "4",
          "rancher.io/intel_sriov_oru": "4",
          "memory": "221396384Ki",
          "pods": "110"
      }
    }
  • `FEC`アクセラレータのresourceNameは`rancher.io/intel_fec_5g`であり、16個のVFが使用可能です。

  • NICカードのresourceNameは`rancher.io/intel_sriov_odu`および`rancher.io/intel_sriov_oru`です。各リソースは4個のVFを提供します。

重要
重要

Kubernetesノードでインターフェースが割り当て可能なリソースとして検出されない場合は、この問題を解決することが不可欠です。一般的な原因の1つはconfigMapの仕様が正しくないことであるため、configMapとそのセレクターを確認することをお勧めします。

39.2 オプション2(推奨):SR-IOV Network Operator

  • Helmが存在しない場合は取得します。

$ curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
  • `sriov-network-operator`ネームスペースにSR-IOV Network Operatorをインストールします。

helm install sriov-crd oci://registry.suse.com/edge/charts/sriov-crd -n sriov-network-operator
helm install sriov-network-operator oci://registry.suse.com/edge/charts/sriov-network-operator -n sriov-network-operator
  • デプロイされたCRDとポッドを確認します。

$ kubectl get crd
$ kubectl -n sriov-network-operator get pods
  • SR-IOVラベルがノードに適用されているかどうかを確認します。

すべてのリソースが実行されると、ラベルがノードに自動的に表示されます。

$ kubectl get nodes -oyaml | grep feature.node.kubernetes.io/network-sriov.capable

feature.node.kubernetes.io/network-sriov.capable: "true"
  • daemonset を確認して、新しい sriov-network-config-daemon と sriov-rancher-nfd-worker がアクティブで準備完了になっていることを確認します。

$ kubectl get daemonset -n sriov-network-operator
NAMESPACE             NAME                            DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR                                           AGE
sriov-network-operator   sriov-network-config-daemon     1         1         1       1            1           feature.node.kubernetes.io/network-sriov.capable=true   45m
sriov-network-operator   sriov-rancher-nfd-worker        1         1         1       1            1           <none>                                                  45m

数分でノードが検出され、SR-IOV 機能で完全に構成されます。更新には最大10分かかる場合があります。

$ kubectl get sriovnetworknodestates -A
NAMESPACE             NAME     AGE
sriov-network-operator   xr11-2   83s
  • インターフェイスが検出されたかどうかを確認します。

検出されたインターフェイスは、ネットワークデバイスのPCIアドレスである必要があります。ホストで lspci コマンドを使用して、この情報を確認します。

$ kubectl get sriovnetworknodestates -n sriov-network-operator -oyaml
apiVersion: v1
items:
- apiVersion: sriovnetwork.openshift.io/v1
  kind: SriovNetworkNodeState
  metadata:
    creationTimestamp: "2023-06-07T09:52:37Z"
    generation: 1
    name: xr11-2
    namespace: sriov-network-operator
    ownerReferences:
    - apiVersion: sriovnetwork.openshift.io/v1
      blockOwnerDeletion: true
      controller: true
      kind: SriovNetworkNodePolicy
      name: default
      uid: 80b72499-e26b-4072-a75c-f9a6218ec357
    resourceVersion: "356603"
    uid: e1f1654b-92b3-44d9-9f87-2571792cc1ad
  spec:
    dpConfigVersion: "356507"
  status:
    interfaces:
    - deviceID: "1592"
      driver: ice
      eSwitchMode: legacy
      linkType: ETH
      mac: 40:a6:b7:9b:35:f0
      mtu: 1500
      name: p2p1
      pciAddress: "0000:51:00.0"
      totalvfs: 128
      vendor: "8086"
    - deviceID: "1592"
      driver: ice
      eSwitchMode: legacy
      linkType: ETH
      mac: 40:a6:b7:9b:35:f1
      mtu: 1500
      name: p2p2
      pciAddress: "0000:51:00.1"
      totalvfs: 128
      vendor: "8086"
    syncStatus: Succeeded
kind: List
metadata:
  resourceVersion: ""
注記
注記

インターフェイスがここで検出されない場合は、次のConfigMapに存在することを確認してください。

$ kubectl get cm supported-nic-ids -oyaml -n sriov-network-operator

デバイスがリストにない場合は、ConfigMapを編集して、検出される正しい値を追加してください。次に、各ノードの sriov-network-config-daemon ポッドを再起動して、更新を有効にします。

  • SriovNetworkNodePolicy を構成するために VFs を作成します。

このポリシーは、ポッドで使用するためのリソース intelnicsDpdk を作成します。また、vfio-pci ドライバーを指定されたPCIデバイスにバインドし、MTUサイズ1500の8つのVFを作成します。

注記
注記

resourceName フィールドには特殊文字を含めることはできず、クラスター全体で一意である必要があります。 この例では、DPDKがSR-IOVと組み合わせて使用されるため、deviceType: vfio-pci を使用します。DPDKを使用しない場合は、deviceType: netdevice(デフォルト値)を設定してください。

apiVersion: sriovnetwork.openshift.io/v1
kind: SriovNetworkNodePolicy
metadata:
  name: policy-dpdk
  namespace: sriov-network-operator
spec:
  nodeSelector:
    feature.node.kubernetes.io/network-sriov.capable: "true"
  resourceName: intelnicsDpdk
  deviceType: vfio-pci
  numVfs: 8
  mtu: 1500
  nicSelector:
    deviceID: "1592"
    vendor: "8086"
    rootDevices:
    - 0000:51:00.0
  • すべてのノードで構成を検証します。

定義済みの resourcePrefix rancher.io を使用すると、8つのVFを持つリソース rancher.io/intelnicsDpdk が検出されるはずです。

$ kubectl get nodes -o jsonpath='{"items": [ { "name": @.metadata.name, "allocatable": @.status.allocatable } ]}' | jq
{
  "name": "node1.suse.edge.com",
  "allocatable": {
      "cpu": "64",
      "ephemeral-storage": "256196109726",
      "hugepages-1Gi": "60Gi",
      "hugepages-2Mi": "0",
      "rancher.io/intel_fec_5g": "16",
      "memory": "200424836Ki",
      "pods": "110",
      "rancher.io/intelnicsDpdk": "8"
  }
}
  • (オプション)sriovnetwork を作成します。

この手順はオプションであり、カスタムネットワーク定義の場合にのみ必要です。以前に作成したノードポリシーにバインドする resourceName を指定します。

networkNamespace が設定されている場合、ネットワークはそのネームスペース内のポッドに公開されます。それ以外の場合、ネットワークはNetwork Operatorのインストールネームスペースで使用可能になります。

apiVersion: sriovnetwork.openshift.io/v1
kind: SriovNetwork
metadata:
  name: network-dpdk
  namespace: sriov-network-operator        # where SRIOV Operator is installed
spec:
  ipam: |
    {
      "type": "host-local",
      "subnet": "192.168.0.0/24",
      "rangeStart": "192.168.0.20",
      "rangeEnd": "192.168.0.60",
      "routes": [{
        "dst": "0.0.0.0/0"
      }],
      "gateway": "192.168.0.1"
    }
  vlan: 500
  resourceName: intelnicsDpdk
  networkNamespace: default         # where workloads are deployed
  • 更新が成功すると、ターゲットクラスターにNetworkAttachmentDefinition(NAD)が作成されます。

$ kubectl get net-attach-def -A -oyaml

apiVersion: v1
items:
- apiVersion: k8s.cni.cncf.io/v1
  kind: NetworkAttachmentDefinition
  metadata:
    annotations:
      k8s.v1.cni.cncf.io/resourceName: rancher.io/intelnicsDpdk
    creationTimestamp: "2023-06-08T11:22:27Z"
    generation: 1
    name: network-dpdk
    namespace: default
    resourceVersion: "13124"
    uid: df7c89f5-177c-4f30-ae72-7aef3294fb15
  spec:
    config: '{ "cniVersion":"0.4.0", "name":"network-dpdk","type":"sriov","vlan":500,"vlanQoS":0,"ipam":{"type":"host-local","subnet":"192.168.0.0/24","rangeStart":"192.168.0.10","rangeEnd":"192.168.0.60","routes":[{"dst":"0.0.0.0/0"}],"gateway":"192.168.0.1"}
      }'
kind: List
metadata:
  resourceVersion: ""

ワークロードポッドは、リソース名 rancher.io/intelnicsDpdk を使用してネットワークインターフェイスのVFを利用できます。