3.5. NodeFeatureRule カスタムリソースの使用
一連のルールが条件に一致する場合にノードにラベルを付ける NodeFeatureRule
オブジェクトを作成します。
手順
次のテキストを含むカスタムリソースを、
nodefeaturerule.yaml
という名前で作成します。Copy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: nfd.openshift.io/v1 kind: NodeFeatureRule metadata: name: example-rule spec: rules: - name: "example rule" labels: "example-custom-feature": "true" # Label is created if all of the rules below match matchFeatures: # Match if "veth" kernel module is loaded - feature: kernel.loadedmodule matchExpressions: veth: {op: Exists} # Match if any PCI device with vendor 8086 exists in the system - feature: pci.device matchExpressions: vendor: {op: In, value: ["8086"]}
apiVersion: nfd.openshift.io/v1 kind: NodeFeatureRule metadata: name: example-rule spec: rules: - name: "example rule" labels: "example-custom-feature": "true" # Label is created if all of the rules below match matchFeatures: # Match if "veth" kernel module is loaded - feature: kernel.loadedmodule matchExpressions: veth: {op: Exists} # Match if any PCI device with vendor 8086 exists in the system - feature: pci.device matchExpressions: vendor: {op: In, value: ["8086"]}
このカスタムリソースは、
veth
モジュールがロードされ、ベンダーコードが8086
の PCI デバイスがクラスター内に存在する場合にラベル付けするように指定します。次のコマンドを実行して、
nodefeaturerule.yaml
ファイルをクラスターに適用します。Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f https://raw.githubusercontent.com/kubernetes-sigs/node-feature-discovery/v0.13.6/examples/nodefeaturerule.yaml
$ oc apply -f https://raw.githubusercontent.com/kubernetes-sigs/node-feature-discovery/v0.13.6/examples/nodefeaturerule.yaml
この例では、
veth
モジュールがロードされており、ベンダーコードが8086
の PCI デバイスが存在するノードに機能ラベルを適用します。注記ラベルの再設定では、最大 1 分の遅延が発生する可能性があります。