3.2. 使用 Node Feature Discovery Operator
Node Feature Discovery(NFD)Operator 通过监视 NodeFeatureDiscovery
CR 来编排运行 Node-Feature-Discovery 守护进程所需的所有资源。根据 NodeFeatureDiscovery
CR,Operator 在所选命名空间中创建操作对象(NFD) 组件。您可以将 CR 编辑为使用另一个命名空间、镜像、镜像拉取策略和 nfd-worker-conf
配置映射,以及其他选项。
作为集群管理员,您可以使用 OpenShift CLI (oc
) 或 Web 控制台创建 NodeFeatureDiscovery
CR。
3.2.1. 使用 CLI 创建 NodeFeatureDiscovery CR
作为集群管理员,您可以使用 OpenShift CLI (oc
) 创建 NodeFeatureDiscovery
CR 实例。
spec.operand.image
设置需要定义一个 -rhel9
镜像以用于 OpenShift Container Platform 版本 4.13 及更新的版本。
以下示例显示了使用 -rhel9
获取正确的镜像。
先决条件
- 您可以访问 OpenShift Container Platform 集群
-
已安装 OpenShift CLI(
oc
)。 -
以具有
cluster-admin
权限的用户身份登录。 - 已安装 NFD Operator。
流程
创建
NodeFeatureDiscovery
CR:NodeFeatureDiscovery
CR 示例apiVersion: nfd.openshift.io/v1 kind: NodeFeatureDiscovery metadata: name: nfd-instance namespace: openshift-nfd spec: instance: "" # instance is empty by default topologyupdater: false # False by default operand: image: registry.redhat.io/openshift4/ose-node-feature-discovery-rhel9:v4.15 imagePullPolicy: Always workerConfig: configData: | core: # labelWhiteList: # noPublish: false sleepInterval: 60s # sources: [all] # klog: # addDirHeader: false # alsologtostderr: false # logBacktraceAt: # logtostderr: true # skipHeaders: false # stderrthreshold: 2 # v: 0 # vmodule: ## NOTE: the following options are not dynamically run-time configurable ## and require a nfd-worker restart to take effect after being changed # logDir: # logFile: # logFileMaxSize: 1800 # skipLogHeaders: false sources: cpu: cpuid: # NOTE: whitelist has priority over blacklist attributeBlacklist: - "BMI1" - "BMI2" - "CLMUL" - "CMOV" - "CX16" - "ERMS" - "F16C" - "HTT" - "LZCNT" - "MMX" - "MMXEXT" - "NX" - "POPCNT" - "RDRAND" - "RDSEED" - "RDTSCP" - "SGX" - "SSE" - "SSE2" - "SSE3" - "SSE4.1" - "SSE4.2" - "SSSE3" attributeWhitelist: kernel: kconfigFile: "/path/to/kconfig" configOpts: - "NO_HZ" - "X86" - "DMI" pci: deviceClassWhitelist: - "0200" - "03" - "12" deviceLabelFields: - "class" customConfig: configData: | - name: "more.kernel.features" matchOn: - loadedKMod: ["example_kmod3"]
运行以下命令来创建
NodeFeatureDiscovery
CR:$ oc apply -f <filename>
验证
运行以下命令,检查
NodeFeatureDiscovery
CR 是否已创建:$ oc get pods
输出示例
NAME READY STATUS RESTARTS AGE nfd-controller-manager-7f86ccfb58-vgr4x 2/2 Running 0 11m nfd-master-hcn64 1/1 Running 0 60s nfd-master-lnnxx 1/1 Running 0 60s nfd-master-mp6hr 1/1 Running 0 60s nfd-worker-vgcz9 1/1 Running 0 60s nfd-worker-xqbws 1/1 Running 0 60s
一个成功的部署会显示
Running
状态。
3.2.2. 在断开连接的环境中使用 CLI 创建 NodeFeatureDiscovery CR
作为集群管理员,您可以使用 OpenShift CLI (oc
) 创建 NodeFeatureDiscovery
CR 实例。
先决条件
- 您可以访问 OpenShift Container Platform 集群
-
已安装 OpenShift CLI(
oc
)。 -
以具有
cluster-admin
权限的用户身份登录。 - 已安装 NFD Operator。
- 您可以使用所需镜像访问镜像 registry。
-
已安装
skopeo
CLI 工具。
流程
确定 registry 镜像摘要:
运行以下命令:
$ skopeo inspect docker://registry.redhat.io/openshift4/ose-node-feature-discovery:<openshift_version>
示例命令
$ skopeo inspect docker://registry.redhat.io/openshift4/ose-node-feature-discovery:v4.12
检查输出以识别镜像摘要:
输出示例
{ ... "Digest": "sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", ... }
运行以下命令,使用
skopeo
CLI 工具将镜像从registry.redhat.io
复制到您的镜像 registry 中:skopeo copy docker://registry.redhat.io/openshift4/ose-node-feature-discovery@<image_digest> docker://<mirror_registry>/openshift4/ose-node-feature-discovery@<image_digest>
示例命令
skopeo copy docker://registry.redhat.io/openshift4/ose-node-feature-discovery@sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef docker://<your-mirror-registry>/openshift4/ose-node-feature-discovery@sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef
创建
NodeFeatureDiscovery
CR:NodeFeatureDiscovery
CR 示例apiVersion: nfd.openshift.io/v1 kind: NodeFeatureDiscovery metadata: name: nfd-instance spec: operand: image: <mirror_registry>/openshift4/ose-node-feature-discovery@<image_digest> imagePullPolicy: Always workerConfig: configData: | core: # labelWhiteList: # noPublish: false sleepInterval: 60s # sources: [all] # klog: # addDirHeader: false # alsologtostderr: false # logBacktraceAt: # logtostderr: true # skipHeaders: false # stderrthreshold: 2 # v: 0 # vmodule: ## NOTE: the following options are not dynamically run-time configurable ## and require a nfd-worker restart to take effect after being changed # logDir: # logFile: # logFileMaxSize: 1800 # skipLogHeaders: false sources: cpu: cpuid: # NOTE: whitelist has priority over blacklist attributeBlacklist: - "BMI1" - "BMI2" - "CLMUL" - "CMOV" - "CX16" - "ERMS" - "F16C" - "HTT" - "LZCNT" - "MMX" - "MMXEXT" - "NX" - "POPCNT" - "RDRAND" - "RDSEED" - "RDTSCP" - "SGX" - "SSE" - "SSE2" - "SSE3" - "SSE4.1" - "SSE4.2" - "SSSE3" attributeWhitelist: kernel: kconfigFile: "/path/to/kconfig" configOpts: - "NO_HZ" - "X86" - "DMI" pci: deviceClassWhitelist: - "0200" - "03" - "12" deviceLabelFields: - "class" customConfig: configData: | - name: "more.kernel.features" matchOn: - loadedKMod: ["example_kmod3"]
运行以下命令来创建
NodeFeatureDiscovery
CR:$ oc apply -f <filename>
验证
运行以下命令,检查
NodeFeatureDiscovery
CR 的状态:$ oc get nodefeaturediscovery nfd-instance -o yaml
运行以下命令,检查 pod 是否在没有
ImagePullBackOff
错误的情况下运行:$ oc get pods -n <nfd_namespace>
3.2.3. 使用 Web 控制台创建 NodeFeatureDiscovery CR
作为集群管理员,您可以使用 OpenShift Container Platform Web 控制台创建 NodeFeatureDiscovery
CR。
先决条件
- 您可以访问 OpenShift Container Platform 集群
-
以具有
cluster-admin
权限的用户身份登录。 - 已安装 NFD Operator。
流程
-
导航到 Operators
Installed Operators 页面。 - 在 Node Feature Discovery 部分中,在 Provided APIs 下,点 Create instance。
-
编辑
NodeFeatureDiscovery
CR 的值。 - 点 Create。