This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.3.3.2. 使用 CLI 创建 OpenShift Update Service 应用程序
您可以使用 OpenShift CLI(oc
)来创建 OpenShift Update Service 应用。
先决条件
- 已安装 OpenShift Update Service Operator。
- OpenShift Update Service graph-data 容器镜像已创建并推送到 OpenShift Update Service 访问的存储库。
- 当前发行版本和更新目标版本已被 mirror 到本地可访问的 registry 中。
流程
配置 OpenShift Update Service 目标命名空间,如
openshift-update-service
:NAMESPACE=openshift-update-service
$ NAMESPACE=openshift-update-service
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 命名空间必须与 operator 组中的
targetNamespaces
值匹配。配置 OpenShift Update Service 应用程序的名称,如
service
:NAME=service
$ NAME=service
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 按照"镜像 OpenShift Container Platform 镜像存储库"中配置,为发行镜像配置本地 registry 和存储库,如
registry.example.com/ocp4/openshift4-release-images
:RELEASE_IMAGES=registry.example.com/ocp4/openshift4-release-images
$ RELEASE_IMAGES=registry.example.com/ocp4/openshift4-release-images
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 将 graph-data 镜像的本地 pullspec 设置为在"创建 OpenShift Update Service 图形数据容器镜像"中创建的图形数据容器镜像,如
registry.example.com/openshift/graph-data:latest
:GRAPH_DATA_IMAGE=registry.example.com/openshift/graph-data:latest
$ GRAPH_DATA_IMAGE=registry.example.com/openshift/graph-data:latest
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 创建 OpenShift Update Service 应用程序对象:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 验证 OpenShift Update Service 应用程序:
使用以下命令获取策略引擎路由:
while sleep 1; do POLICY_ENGINE_GRAPH_URI="$(oc -n "${NAMESPACE}" get -o jsonpath='{.status.policyEngineURI}/api/upgrades_info/v1/graph{"\n"}' updateservice "${NAME}")"; SCHEME="${POLICY_ENGINE_GRAPH_URI%%:*}"; if test "${SCHEME}" = http -o "${SCHEME}" = https; then break; fi; done
$ while sleep 1; do POLICY_ENGINE_GRAPH_URI="$(oc -n "${NAMESPACE}" get -o jsonpath='{.status.policyEngineURI}/api/upgrades_info/v1/graph{"\n"}' updateservice "${NAME}")"; SCHEME="${POLICY_ENGINE_GRAPH_URI%%:*}"; if test "${SCHEME}" = http -o "${SCHEME}" = https; then break; fi; done
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 您可能需要轮询,直到命令成功为止。
从策略引擎检索图形。确保为
channel
指定一个有效版本。例如,如果在 OpenShift Container Platform 4.6 中运行,请使用stable-4.6
:while sleep 10; do HTTP_CODE="$(curl --header Accept:application/json --output /dev/stderr --write-out "%{http_code}" "${POLICY_ENGINE_GRAPH_URI}?channel=stable-4.6")"; if test "${HTTP_CODE}" -eq 200; then break; fi; echo "${HTTP_CODE}"; done
$ while sleep 10; do HTTP_CODE="$(curl --header Accept:application/json --output /dev/stderr --write-out "%{http_code}" "${POLICY_ENGINE_GRAPH_URI}?channel=stable-4.6")"; if test "${HTTP_CODE}" -eq 200; then break; fi; echo "${HTTP_CODE}"; done
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 这会轮询到图形请求成功为止,但生成的图形可能为空,具体取决于您已镜像的发行镜像。
基于 RFC-1123 的策略引擎路由名称不能超过 63 个字符。如果您看到 ReconcileCompleted
状态为 false
,原因为 CreateRouteFailed
caused by host must conform to DNS 1123 naming convention and must be no more than 63 characters
,请尝试使用较短的名称创建 Update Service。