1.7. 创建用于 MicroShift 的 ServingRuntime CR
根据已安装的清单和发行信息创建 ServingRuntime 自定义资源(CR)。包括的步骤是重新使用包括的 microshift-ai-model-serving 清单文件的示例,以便在工作负载命名空间中重新创建 OpenVINO Model Server (OVMS)模型运行时。
注意
此方法不需要实时集群,因此它可能是 CI/CD 自动化的一部分。
先决条件
-
microshift-ai-model-serving和microshift-ai-model-serving-release-infoRPM 都已安装。 - 有对机器的 root 用户访问权限。
-
已安装 OpenShift CLI (
oc)。
流程
运行以下命令,从 MicroShift 发行版本信息文件中提取要使用的
ServingRuntimeCR 的镜像引用:OVMS_IMAGE="$(jq -r '.images | with_entries(select(.key == "ovms-image")) | .[]' /usr/share/microshift/release/release-ai-model-serving-"$(uname -i)".json)"
$ OVMS_IMAGE="$(jq -r '.images | with_entries(select(.key == "ovms-image")) | .[]' /usr/share/microshift/release/release-ai-model-serving-"$(uname -i)".json)"1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- 在本例中,提取 OVMS 模型运行时的镜像引用。
运行以下命令复制原始
ServingRuntimeYAML 文件:cp /usr/lib/microshift/manifests.d/050-microshift-ai-model-serving-runtimes/ovms-kserve.yaml ./ovms-kserve.yaml
$ cp /usr/lib/microshift/manifests.d/050-microshift-ai-model-serving-runtimes/ovms-kserve.yaml ./ovms-kserve.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow 运行以下命令,将实际镜像引用添加到
ServingRuntimeYAML 的image:parameter 字段值:sed -i "s,image: ovms-image,image: ${OVMS_IMAGE}," ./ovms-kserve.yaml$ sed -i "s,image: ovms-image,image: ${OVMS_IMAGE}," ./ovms-kserve.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow 运行以下命令,使用 YAML 文件在自定义命名空间中创建
ServingRuntime对象:oc create -n <ai_demo> -f ./ovms-kserve.yaml
$ oc create -n <ai_demo> -f ./ovms-kserve.yaml1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- 将
<ai_demo> 替换为您的命名空间的名称。
重要
如果 ServingRuntime CR 是新清单的一部分,请在 kustomization.yaml 文件中设置命名空间,例如:
Kustomize 清单命名空间值示例
后续步骤
-
创建
InferenceService对象。 - 验证您的模型是否已准备好推断。
- 查询模型。
- 可选:检查模型指标。