6.5. SR-IOV の設定
OpenShift Container Platform には、OpenShift Container Platform ノードで SR-IOV ハードウェアを使用する機能が含まれます。これにより、他のネットワークインターフェースに加えて SR-IOV Virtual Function (VF) インターフェースを Pod に割り当てることができます。
この機能を有効にするには、SR-IOV ネットワークデバイスプラグインおよび SR-IOV CNI プラグインという 2 つのコンポーネントが必要になります。
- SR-IOV ネットワークプラグインは、SR-IOV ネットワークの Virtual Function (VF) リソースを検出し、公開し、割り当てるための Kubernetes デバイスプラグインです。デバイスプラグインは、とりわけ物理デバイスでの制限されたリソースの使用を有効にするために Kubernetes で使用されます。デバイスプラグインは、Kubernetes スケジューラーに使い切られたリソースについて認識させ、Pod が利用可能なリソースが十分にあるワーカーノードにスケジュールされるようにします。
- SR-IOV CNI プラグインは、SR-IOV デバイスプラグインから割り当てられる VF インターフェースを Pod につなぎます。
6.5.1. サポートされるデバイス
以下のネットワークインターフェースカード (NIC) モデルは OpenShift Container Platform でサポートされています。
- Intel XXV710-DA2 25G カード (ベンダー ID 0x8086 およびデバイス ID 0x158b)
- Mellanox MT27710 Family [ConnectX-4 Lx] 25G カード (ベンダー ID 0x15b3 およびデバイス ID 0x1015)
- Mellanox MT27800 Family [ConnectX-5] 100G カード (ベンダー ID 0x15b3 およびデバイス ID 0x1017)
Mellanox カードの場合、VF をホストにプロビジョニングする前に SR-IOV がファームウェアで有効にされていることを確認します。
6.5.2. SR-IOV プラグインおよび daemonset の作成
SR-IOV VF の作成は、SR-IOV デバイスプラグインおよび SR-IOV CNI では処理されません。SR-IOV VF をホストにプロビジョニングするには、これを手動で設定する必要があります。
SR-IOV ネットワークプラグインおよび SR-IOV CNI プラグインを使用するには、クラスター内の各ノード上で、両方のプラグインをデーモンモードで実行します。
以下の内容を含む
openshift-sriov
namespace の YAML ファイルを作成します。apiVersion: v1 kind: Namespace metadata: name: openshift-sriov labels: name: openshift-sriov openshift.io/run-level: "0" annotations: openshift.io/node-selector: "" openshift.io/description: "Openshift SR-IOV network components"
以下のコマンドを実行して、
openshift-sriov
namespace を作成します。$ oc create -f openshift-sriov.yaml
以下の内容を含む
sriov-device-plugin
サービスアカウントの YAML ファイルを作成します。apiVersion: v1 kind: ServiceAccount metadata: name: sriov-device-plugin namespace: openshift-sriov
以下のコマンドを実行し、
sriov-device-plugin
サービスアカウントを作成します。$ oc create -f sriov-device-plugin.yaml
以下の内容を含む
sriov-cni
サービスアカウントの YAML ファイルを作成します。apiVersion: v1 kind: ServiceAccount metadata: name: sriov-cni namespace: openshift-sriov
以下のコマンドを実行し、
sriov-cni
サービスアカウントを作成します。$ oc create -f sriov-cni.yaml
以下の内容を含む
sriov-device-plugin
DaemonSet の YAML ファイルを作成します。注記SR-IOV ネットワークデバイスプラグインデーモンは、起動時に各ホストで設定されたすべての (サポートされている NIC モデルの) SR-IOV VF を検出し、検出されたリソースを公開します。割り当てることのできる利用可能な SR-IOV VF リソースの数は、
oc describe node <node-name>
コマンドでノードを記述して確認できます。SR-IOV VF リソースのリソース名はopenshift.io/sriov
です。ノードで利用可能な SR-IOV VF がない場合、ゼロ (0) の値が表示されます。kind: DaemonSet apiVersion: apps/v1 metadata: name: sriov-device-plugin namespace: openshift-sriov annotations: kubernetes.io/description: | This daemon set launches the SR-IOV network device plugin on each node. spec: selector: matchLabels: app: sriov-device-plugin updateStrategy: type: RollingUpdate template: metadata: labels: app: sriov-device-plugin component: network type: infra openshift.io/component: network spec: hostNetwork: true nodeSelector: beta.kubernetes.io/os: linux tolerations: - operator: Exists serviceAccountName: sriov-device-plugin containers: - name: sriov-device-plugin image: quay.io/openshift/ose-sriov-network-device-plugin:v4.0.0 args: - --log-level=10 securityContext: privileged: true volumeMounts: - name: devicesock mountPath: /var/lib/kubelet/ readOnly: false - name: net mountPath: /sys/class/net readOnly: true volumes: - name: devicesock hostPath: path: /var/lib/kubelet/ - name: net hostPath: path: /sys/class/net
以下のコマンドを実行し、
sriov-device-plugin
DaemonSet を作成します。oc create -f sriov-device-plugin.yaml
以下の内容を含む
sriov-cni
DaemonSet の YAML ファイルを作成します。kind: DaemonSet apiVersion: apps/v1 metadata: name: sriov-cni namespace: openshift-sriov annotations: kubernetes.io/description: | This daemon set launches the SR-IOV CNI plugin on SR-IOV capable worker nodes. spec: selector: matchLabels: app: sriov-cni updateStrategy: type: RollingUpdate template: metadata: labels: app: sriov-cni component: network type: infra openshift.io/component: network spec: nodeSelector: beta.kubernetes.io/os: linux tolerations: - operator: Exists serviceAccountName: sriov-cni containers: - name: sriov-cni image: quay.io/openshift/ose-sriov-cni:v4.0.0 securityContext: privileged: true volumeMounts: - name: cnibin mountPath: /host/opt/cni/bin volumes: - name: cnibin hostPath: path: /var/lib/cni/bin
以下のコマンドを実行し、
sriov-cni
DaemonSet を作成します。$ oc create -f sriov-cni.yaml
6.5.3. SR-IOV を使用した追加インターフェースの設定
SR-IOV 設定を使用してカスタムリソース (CR) の YAML ファイルを作成します。以下の CR の
name
フィールドには、値sriov-conf
が含まれます。apiVersion: "k8s.cni.cncf.io/v1" kind: NetworkAttachmentDefinition metadata: name: sriov-conf annotations: k8s.v1.cni.cncf.io/resourceName: openshift.io/sriov 1 spec: config: '{ "type": "sriov", 2 "name": "sriov-conf", "ipam": { "type": "host-local", "subnet": "10.56.217.0/24", "routes": [{ "dst": "0.0.0.0/0" }], "gateway": "10.56.217.1" } }'
以下のコマンドを実行して、
sriov-conf
CR を作成します。$ oc create -f sriov-conf.yaml
NetworkAttachmentDefinition
の名前を参照し、1 つのopenshift.io/sriov
リソースを参照する Pod の YAML ファイルを作成します。apiVersion: v1 kind: Pod metadata: name: sriovsamplepod annotations: k8s.v1.cni.cncf.io/networks: sriov-conf spec: containers: - name: sriovsamplepod command: ["/bin/bash", "-c", "sleep 2000000000000"] image: centos/tools resources: requests: openshift.io/sriov: '1' limits: openshift.io/sriov: '1'
以下のコマンドを実行して
sriovsamplepod
Pod を作成します。$ oc create -f sriovsamplepod.yaml
ip
コマンドを実行して、追加のインターフェースを表示します。$ oc exec sriovsamplepod -- ip a