第 5 章 集群扩展
5.1. 管理集群扩展
Operator Lifecycle Manager (OLM) v1 只是一个技术预览功能。技术预览功能不受红帽产品服务等级协议(SLA)支持,且功能可能并不完整。红帽不推荐在生产环境中使用它们。这些技术预览功能可以使用户提早试用新的功能,并有机会在开发阶段提供反馈意见。
有关红帽技术预览功能支持范围的更多信息,请参阅技术预览功能支持范围。
将一个目录被添加到集群后,您可以访问发布到目录的扩展和 Operator 版本、补丁和无线更新。
您可以使用自定义资源 (CR) 从 CLI 中声明性管理扩展。
目前,Operator Lifecycle Manager (OLM) v1 无法验证私有 registry,如红帽提供的 Operator 目录。这是个已知问题。因此,依赖 Red Hat Operator 目录的 OLM v1 流程无法正常工作。(OCPBUGS-36364)
5.1.1. 支持的扩展
目前,Operator Lifecycle Manager (OLM) v1 支持安装满足以下所有条件的集群扩展:
-
扩展必须使用现有 OLM 中引入的
registry+v1
捆绑包格式。 -
扩展必须通过
AllNamespaces
安装模式支持安装。 - 扩展不能使用 Webhook。
扩展不能使用以下基于文件的目录属性声明依赖项:
-
olm.gvk.required
-
olm.package.required
-
olm.constraint
-
OLM v1 检查您要安装的扩展是否满足这些限制。如果要安装的扩展不符合这些限制,会在集群扩展条件中输出错误消息。
Operator Lifecycle Manager (OLM) v1 不支持现有 OLM 中引入的 OperatorConditions
API。
如果扩展依赖于 OperatorConditions
API 管理更新,扩展可能无法正确安装。大多数依赖此 API 的扩展都会在启动时失败,但在协调过程中可能会失败。
作为临时解决方案,您可以将扩展固定到特定的版本。当您想更新扩展时,请查阅扩展文档来查找何时安全将扩展固定到新版本。
其他资源
5.1.2. 从目录查找 Operator
在集群中添加目录后,您可以查询目录以查找要安装的 Operator 和扩展。在查询目录前,您必须端口转发目录服务器服务。
先决条件
- 您已在集群中添加目录。
-
已安装
jq
CLI 工具。
流程
运行以下命令,在
openshift-catalogd
命名空间中转发目录服务器服务:$ oc -n openshift-catalogd port-forward svc/catalogd-catalogserver 8080:443
在新的终端窗口中或标签页中,运行以下命令来在本地下载目录的 JSON 文件:
$ curl -L -k https://localhost:8080/catalogs/<catalog_name>/all.json \ -C - -o /<path>/<catalog_name>.json
例 5.1. 示例命令
$ curl -L -k https://localhost:8080/catalogs/redhat-operators/all.json \ -C - -o /home/username/catalogs/rhoc.json
运行以下命令之一返回目录中的 Operator 和扩展列表。
重要目前,Operator Lifecycle Manager (OLM) v1 支持安装满足以下所有条件的集群扩展:
-
扩展必须使用现有 OLM 中引入的
registry+v1
捆绑包格式。 -
扩展必须通过
AllNamespaces
安装模式支持安装。 - 扩展不能使用 Webhook。
扩展不能使用以下基于文件的目录属性声明依赖项:
-
olm.gvk.required
-
olm.package.required
-
olm.constraint
-
OLM v1 检查您要安装的扩展是否满足这些限制。如果要安装的扩展不符合这些限制,会在集群扩展条件中输出错误消息。
运行以下命令,从本地目录文件获取 Operator 和扩展列表:
$ jq -s '.[] | select(.schema == "olm.package") | .name' \ /<path>/<filename>.json
例 5.2. 示例命令
$ jq -s '.[] | select(.schema == "olm.package") | .name' \ /home/username/catalogs/rhoc.json
例 5.3. 输出示例
NAME AGE "3scale-operator" "advanced-cluster-management" "amq-broker-rhel8" "amq-online" "amq-streams" "amq7-interconnect-operator" "ansible-automation-platform-operator" "ansible-cloud-addons-operator" "apicast-operator" "aws-efs-csi-driver-operator" "aws-load-balancer-operator" "bamoe-businessautomation-operator" "bamoe-kogito-operator" "bare-metal-event-relay" "businessautomation-operator" ...
运行以下命令,获取支持
AllNamespaces
安装模式的软件包列表,且不从本地目录文件中使用 webhook:$ jq -c 'select(.schema == "olm.bundle") | \ {"package":.package, "version":.properties[] | \ select(.type == "olm.bundle.object").value.data | @base64d | fromjson | \ select(.kind == "ClusterServiceVersion" and (.spec.installModes[] | \ select(.type == "AllNamespaces" and .supported == true) != null) \ and .spec.webhookdefinitions == null).spec.version}' \ /<path>/<catalog_name>.json
例 5.4. 输出示例
{"package":"3scale-operator","version":"0.10.0-mas"} {"package":"3scale-operator","version":"0.10.5"} {"package":"3scale-operator","version":"0.11.0-mas"} {"package":"3scale-operator","version":"0.11.1-mas"} {"package":"3scale-operator","version":"0.11.2-mas"} {"package":"3scale-operator","version":"0.11.3-mas"} {"package":"3scale-operator","version":"0.11.5-mas"} {"package":"3scale-operator","version":"0.11.6-mas"} {"package":"3scale-operator","version":"0.11.7-mas"} {"package":"3scale-operator","version":"0.11.8-mas"} {"package":"amq-broker-rhel8","version":"7.10.0-opr-1"} {"package":"amq-broker-rhel8","version":"7.10.0-opr-2"} {"package":"amq-broker-rhel8","version":"7.10.0-opr-3"} {"package":"amq-broker-rhel8","version":"7.10.0-opr-4"} {"package":"amq-broker-rhel8","version":"7.10.1-opr-1"} {"package":"amq-broker-rhel8","version":"7.10.1-opr-2"} {"package":"amq-broker-rhel8","version":"7.10.2-opr-1"} {"package":"amq-broker-rhel8","version":"7.10.2-opr-2"} ...
-
扩展必须使用现有 OLM 中引入的
运行以下命令,检查 Operator 或扩展的元数据的内容:
$ jq -s '.[] | select( .schema == "olm.package") | \ select( .name == "<package_name>")' /<path>/<catalog_name>.json
例 5.5. 示例命令
$ jq -s '.[] | select( .schema == "olm.package") | \ select( .name == "openshift-pipelines-operator-rh")' \ /home/username/rhoc.json
例 5.6. 输出示例
{ "defaultChannel": "stable", "icon": { "base64data": "PHN2ZyB4bWxu..." "mediatype": "image/png" }, "name": "openshift-pipelines-operator-rh", "schema": "olm.package" }
5.1.2.1. 常见目录查询
您可以使用 jq
CLI 工具查询目录。
查询 | Request(请求) |
---|---|
目录中的可用软件包 |
$ jq -s '.[] | select( .schema == "olm.package") | \ .name' <catalog_name>.json |
支持 |
$ jq -c 'select(.schema == "olm.bundle") | \ {"package":.package, "version":.properties[] | \ select(.type == "olm.bundle.object").value.data | \ @base64d | fromjson | \ select(.kind == "ClusterServiceVersion" and (.spec.installModes[] | \ select(.type == "AllNamespaces" and .supported == true) != null) \ and .spec.webhookdefinitions == null).spec.version}' \ <catalog_name>.json |
软件包元数据 |
$ jq -s '.[] | select( .schema == "olm.package") | \ select( .name == "<package_name>")' <catalog_name>.json |
软件包中的目录 Blob |
$ jq -s '.[] | select( .package == "<package_name>")' \ <catalog_name>.json |
查询 | Request(请求) |
---|---|
软件包中的频道 |
$ jq -s '.[] | select( .schema == "olm.channel" ) | \ select( .package == "<package_name>") | .name' \ <catalog_name>.json |
频道中的版本 |
$ jq -s '.[] | select( .package == "<package_name>" ) | \ select( .schema == "olm.channel" ) | \ select( .name == "<channel_name>" ) | \ .entries | .[] | .name' <catalog_name>.json |
|
$ jq -s '.[] | select( .schema == "olm.channel" ) | \ select ( .name == "<channel>") | \ select( .package == "<package_name>")' \ <catalog_name>.json |
查询 | Request(请求) |
---|---|
软件包中的捆绑包 |
$ jq -s '.[] | select( .schema == "olm.bundle" ) | \ select( .package == "<package_name>") | .name' \ <catalog_name>.json |
|
$ jq -s '.[] | select( .schema == "olm.bundle" ) | \ select ( .name == "<bundle_name>") | \ select( .package == "<package_name>")' \ <catalog_name>.json |
5.1.3. 创建服务帐户以管理集群扩展
与现有的 Operator Lifecycle Manager (OLM) 不同,OLM v1 没有安装、更新和管理集群扩展的权限。集群管理员必须创建服务帐户,并分配安装、更新和管理集群扩展所需的基于角色的访问控制 (RBAC)。
OLM v1 中存在一个已知问题。如果您没有为扩展的服务帐户分配正确的基于角色的访问控制 (RBAC),OLM v1 会卡住,协调会停止。
目前,OLM v1 没有帮助扩展管理员为服务帐户找到正确的 RBAC 的工具。
因为 OLM v1 是一个技术预览功能,且不应在生产环境中使用,您可以使用文档中的更宽松的 RBAC 来避免此问题。
此 RBAC 仅用于测试目的。不要在生产环境集群中使用它。
先决条件
-
使用具有
cluster-admin
权限的账户访问 OpenShift Container Platform 集群。
流程
创建服务帐户,类似以下示例:
apiVersion: v1 kind: ServiceAccount metadata: name: <extension>-installer namespace: <namespace>
例 5.7.
extension-service-account.yaml
文件示例apiVersion: v1 kind: ServiceAccount metadata: name: pipelines-installer namespace: pipelines
运行以下命令来应用服务帐户:
$ oc apply -f extension-service-account.yaml
创建集群角色并分配 RBAC,如下例所示:
警告以下集群角色没有遵循最小特权的原则。此集群角色仅用于测试目的。不要在生产环境集群中使用它。
apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: <extension>-installer-clusterrole rules: - apiGroups: ["*"] resources: ["*"] verbs: ["*"]
例 5.8.
pipelines-cluster-role.yaml
文件示例apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: pipelines-installer-clusterrole rules: - apiGroups: ["*"] resources: ["*"] verbs: ["*"]
运行以下命令在集群中添加集群角色:
$ oc apply -f pipelines-role.yaml
通过创建集群角色绑定将集群角色授予的权限绑定到服务帐户,如下例所示:
apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: <extension>-installer-binding roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: <extension>-installer-clusterrole subjects: - kind: ServiceAccount name: <extension>-installer namespace: <namespace>
例 5.9.
pipelines-cluster-role-binding.yaml
文件示例apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: pipelines-installer-binding roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: pipelines-installer-clusterrole subjects: - kind: ServiceAccount name: pipelines-installer namespace: pipelines
运行以下命令来应用集群角色绑定:
$ oc apply -f pipelines-cluster-role-binding.yaml
5.1.4. 从目录安装集群扩展
您可以通过创建自定义资源 (CR) 并将其应用到集群来从目录安装扩展。Operator Lifecycle Manager (OLM) v1 支持安装集群扩展,包括通过 registry+v1
捆绑包格式(用于集群的现有 OLM Operator)。如需更多信息,请参阅支持的扩展。
目前,Operator Lifecycle Manager (OLM) v1 无法验证私有 registry,如红帽提供的 Operator 目录。这是个已知问题。因此,依赖 Red Hat Operator 目录的 OLM v1 流程无法正常工作。(OCPBUGS-36364)
先决条件
- 您已在集群中添加目录。
- 您已下载了目录文件的本地副本。
-
已安装
jq
CLI 工具。 - 您已创建了服务帐户,并分配了足够的基于角色的访问控制 (RBAC) 来安装、更新和管理您要安装的扩展。如需更多信息,请参阅创建服务帐户。
流程
通过完成以下步骤,检查目录文件本地副本中的频道和版本信息:
运行以下命令,从所选软件包中获取频道列表:
$ jq -s '.[] | select( .schema == "olm.channel" ) | \ select( .package == "<package_name>") | \ .name' /<path>/<catalog_name>.json
例 5.10. 示例命令
$ jq -s '.[] | select( .schema == "olm.channel" ) | \ select( .package == "openshift-pipelines-operator-rh") | \ .name' /home/username/rhoc.json
例 5.11. 输出示例
"latest" "pipelines-1.11" "pipelines-1.12" "pipelines-1.13" "pipelines-1.14"
运行以下命令,获取频道中发布的版本列表:
$ jq -s '.[] | select( .package == "<package_name>" ) | \ select( .schema == "olm.channel" ) | \ select( .name == "<channel_name>" ) | .entries | \ .[] | .name' /<path>/<catalog_name>.json
例 5.12. 示例命令
$ jq -s '.[] | select( .package == "openshift-pipelines-operator-rh" ) | \ select( .schema == "olm.channel" ) | select( .name == "latest" ) | \ .entries | .[] | .name' /home/username/rhoc.json
例 5.13. 输出示例
"openshift-pipelines-operator-rh.v1.12.0" "openshift-pipelines-operator-rh.v1.12.1" "openshift-pipelines-operator-rh.v1.12.2" "openshift-pipelines-operator-rh.v1.13.0" "openshift-pipelines-operator-rh.v1.13.1" "openshift-pipelines-operator-rh.v1.11.1" "openshift-pipelines-operator-rh.v1.12.0" "openshift-pipelines-operator-rh.v1.12.1" "openshift-pipelines-operator-rh.v1.12.2" "openshift-pipelines-operator-rh.v1.13.0" "openshift-pipelines-operator-rh.v1.14.1" "openshift-pipelines-operator-rh.v1.14.2" "openshift-pipelines-operator-rh.v1.14.3" "openshift-pipelines-operator-rh.v1.14.4"
如果要将扩展安装到新命名空间中,请运行以下命令:
$ oc adm new-project <new_namespace>
创建一个类似以下示例的 CR:
pipelines-operator.yaml
CR 示例apiVersion: olm.operatorframework.io/v1alpha1 kind: ClusterExtension metadata: name: pipelines-operator spec: packageName: openshift-pipelines-operator-rh installNamespace: <namespace> serviceAccount: name: <service_account> channel: <channel> version: "<version>"
其中:
<namespace>
-
指定您要安装捆绑包的命名空间,如
pipelines
或my-extension
。扩展仍然是集群范围的,可能包含在不同命名空间中安装的资源。 <service_account>
- 指定您为安装、更新和管理扩展创建的服务帐户的名称。
<channel>
-
可选:为您要安装或更新的软件包指定频道,如
pipelines-1.11
或latest
。 <version>
可选:指定您要安装或更新的软件包的版本或版本范围,如
1.11.1
、1.12.x
或>=1.12.1
。如需更多信息,请参阅"示例自定义资源(CR)指定目标版本"和"支持版本范围"。重要如果您尝试安装没有唯一名称的 Operator 或扩展,则安装可能会失败,或者导致无法预计的结果。这是因为以下原因:
- 如果在集群中安装 mulitple 目录,Operator Lifecycle Manager (OLM) v1 不包含在安装 Operator 或扩展时指定目录的机制。
- OLM v1 要求在集群中安装的所有 Operator 和扩展都使用其捆绑包和软件包的唯一名称。
运行以下命令,将 CR 应用到集群:
$ oc apply -f pipeline-operator.yaml
输出示例
clusterextension.olm.operatorframework.io/pipelines-operator created
验证
运行以下命令,以 YAML 格式查看 Operator 或扩展 CR:
$ oc get clusterextension pipelines-operator -o yaml
例 5.14. 输出示例
apiVersion: v1 items: - apiVersion: olm.operatorframework.io/v1alpha1 kind: ClusterExtension metadata: annotations: kubectl.kubernetes.io/last-applied-configuration: | {"apiVersion":"olm.operatorframework.io/v1alpha1","kind":"ClusterExtension","metadata":{"annotations":{},"name":"pipelines-operator"},"spec":{"channel":"latest","installNamespace":"pipelines","packageName":"openshift-pipelines-operator-rh","serviceAccount":{"name":"pipelines-installer"},"pollInterval":"30m"}} creationTimestamp: "2024-06-10T17:50:51Z" finalizers: - olm.operatorframework.io/cleanup-unpack-cache generation: 1 name: pipelines-operator resourceVersion: "53324" uid: c54237be-cde4-46d4-9b31-d0ec6acc19bf spec: channel: latest installNamespace: pipelines packageName: openshift-pipelines-operator-rh serviceAccount: name: pipelines-installer upgradeConstraintPolicy: Enforce status: conditions: - lastTransitionTime: "2024-06-10T17:50:58Z" message: resolved to "registry.redhat.io/openshift-pipelines/pipelines-operator-bundle@sha256:dd3d18367da2be42539e5dde8e484dac3df33ba3ce1d5bcf896838954f3864ec" observedGeneration: 1 reason: Success status: "True" type: Resolved - lastTransitionTime: "2024-06-10T17:51:11Z" message: installed from "registry.redhat.io/openshift-pipelines/pipelines-operator-bundle@sha256:dd3d18367da2be42539e5dde8e484dac3df33ba3ce1d5bcf896838954f3864ec" observedGeneration: 1 reason: Success status: "True" type: Installed - lastTransitionTime: "2024-06-10T17:50:58Z" message: "" observedGeneration: 1 reason: Deprecated status: "False" type: Deprecated - lastTransitionTime: "2024-06-10T17:50:58Z" message: "" observedGeneration: 1 reason: Deprecated status: "False" type: PackageDeprecated - lastTransitionTime: "2024-06-10T17:50:58Z" message: "" observedGeneration: 1 reason: Deprecated status: "False" type: ChannelDeprecated - lastTransitionTime: "2024-06-10T17:50:58Z" message: "" observedGeneration: 1 reason: Deprecated status: "False" type: BundleDeprecated - lastTransitionTime: "2024-06-10T17:50:58Z" message: 'unpack successful: observedGeneration: 1 reason: UnpackSuccess status: "True" type: Unpacked installedBundle: name: openshift-pipelines-operator-rh.v1.14.4 version: 1.14.4 resolvedBundle: name: openshift-pipelines-operator-rh.v1.14.4 version: 1.14.4
其中:
spec.channel
- 显示扩展 CR 中定义的频道。
spec.version
- 显示扩展 CR 中定义的版本或版本范围。
status.conditions
- 显示扩展状态和健康的信息。
type: Deprecated
显示以下一个或多个是否已弃用:
type: PackageDeprecated
- 显示解析的软件包是否已弃用。
type: ChannelDeprecated
- 显示解析的频道是否已弃用。
type: BundleDeprecated
- 显示解析捆绑包是否已弃用。
status
字段中的False
值表示reason: Deprecated
条件已弃用。status
字段中的True
值表示reason: Deprecated
条件已被弃用。installedBundle.name
- 显示安装的捆绑包的名称。
installedBundle.version
- 显示安装的捆绑包的版本。
resolvedBundle.name
- 显示解析捆绑包的名称。
resolvedBundle.version
- 显示解析捆绑包的版本。
5.1.5. 更新集群扩展
您可以通过手动编辑自定义资源 (CR) 并应用更改来更新集群扩展或 Operator。
先决条件
- 已安装目录。
- 您已下载了目录文件的本地副本。
- 已安装 Operator 或扩展。
-
已安装
jq
CLI 工具。
流程
通过完成以下步骤,检查目录文件本地副本中的频道和版本信息:
运行以下命令,从所选软件包中获取频道列表:
$ jq -s '.[] | select( .schema == "olm.channel" ) | \ select( .package == "<package_name>") | \ .name' /<path>/<catalog_name>.json
例 5.15. 示例命令
$ jq -s '.[] | select( .schema == "olm.channel" ) | \ select( .package == "openshift-pipelines-operator-rh") | \ .name' /home/username/rhoc.json
例 5.16. 输出示例
"latest" "pipelines-1.11" "pipelines-1.12" "pipelines-1.13" "pipelines-1.14"
运行以下命令,获取频道中发布的版本列表:
$ jq -s '.[] | select( .package == "<package_name>" ) | \ select( .schema == "olm.channel" ) | \ select( .name == "<channel_name>" ) | .entries | \ .[] | .name' /<path>/<catalog_name>.json
例 5.17. 示例命令
$ jq -s '.[] | select( .package == "openshift-pipelines-operator-rh" ) | \ select( .schema == "olm.channel" ) | select( .name == "latest" ) | \ .entries | .[] | .name' /home/username/rhoc.json
例 5.18. 输出示例
"openshift-pipelines-operator-rh.v1.11.1" "openshift-pipelines-operator-rh.v1.12.0" "openshift-pipelines-operator-rh.v1.12.1" "openshift-pipelines-operator-rh.v1.12.2" "openshift-pipelines-operator-rh.v1.13.0" "openshift-pipelines-operator-rh.v1.14.1" "openshift-pipelines-operator-rh.v1.14.2" "openshift-pipelines-operator-rh.v1.14.3" "openshift-pipelines-operator-rh.v1.14.4"
运行以下命令,查找在 Operator 或扩展 CR 中指定哪个版本或频道:
$ oc get clusterextension <operator_name> -o yaml
示例命令
$ oc get clusterextension pipelines-operator -o yaml
例 5.19. 输出示例
apiVersion: olm.operatorframework.io/v1alpha1 kind: ClusterExtension metadata: annotations: kubectl.kubernetes.io/last-applied-configuration: | {"apiVersion":"olm.operatorframework.io/v1alpha1","kind":"ClusterExtension","metadata":{"annotations":{},"name":"pipelines-operator"},"spec":{"channel":"latest","installNamespace":"openshift-operators","packageName":"openshift-pipelines-operator-rh","pollInterval":"30m","version":"\u003c1.12"}} creationTimestamp: "2024-06-11T15:55:37Z" generation: 1 name: pipelines-operator resourceVersion: "69776" uid: 6a11dff3-bfa3-42b8-9e5f-d8babbd6486f spec: channel: latest installNamespace: openshift-operators packageName: openshift-pipelines-operator-rh upgradeConstraintPolicy: Enforce version: <1.12 status: conditions: - lastTransitionTime: "2024-06-11T15:56:09Z" message: installed from "registry.redhat.io/openshift-pipelines/pipelines-operator-bundle@sha256:e09d37bb1e754db42324fd18c1cb3e7ce77e7b7fcbf4932d0535391579938280" observedGeneration: 1 reason: Success status: "True" type: Installed - lastTransitionTime: "2024-06-11T15:55:50Z" message: resolved to "registry.redhat.io/openshift-pipelines/pipelines-operator-bundle@sha256:e09d37bb1e754db42324fd18c1cb3e7ce77e7b7fcbf4932d0535391579938280" observedGeneration: 1 reason: Success status: "True" type: Resolved - lastTransitionTime: "2024-06-11T15:55:50Z" message: "" observedGeneration: 1 reason: Deprecated status: "False" type: Deprecated - lastTransitionTime: "2024-06-11T15:55:50Z" message: "" observedGeneration: 1 reason: Deprecated status: "False" type: PackageDeprecated - lastTransitionTime: "2024-06-11T15:55:50Z" message: "" observedGeneration: 1 reason: Deprecated status: "False" type: ChannelDeprecated - lastTransitionTime: "2024-06-11T15:55:50Z" message: "" observedGeneration: 1 reason: Deprecated status: "False" type: BundleDeprecated installedBundle: name: openshift-pipelines-operator-rh.v1.11.1 version: 1.11.1 resolvedBundle: name: openshift-pipelines-operator-rh.v1.11.1 version: 1.11.1
使用以下方法之一编辑 CR:
如果要将 Operator 或扩展固定到特定版本,如
1.12.1
,请编辑类似以下示例的 CR:pipelines-operator.yaml
CR 示例apiVersion: olm.operatorframework.io/v1alpha1 kind: ClusterExtension metadata: name: pipelines-operator spec: packageName: openshift-pipelines-operator-rh installNamespace: <namespace> version: "1.12.1" 1
- 1
- 将版本从
1.11.1
更新至1.12.1
如果要定义可接受的更新版本范围,请编辑类似以下示例的 CR:
指定了版本范围的 CR 示例
apiVersion: olm.operatorframework.io/v1alpha1 kind: ClusterExtension metadata: name: pipelines-operator spec: packageName: openshift-pipelines-operator-rh installNamespace: <namespace> version: ">1.11.1, <1.13" 1
- 1
- 指定所需的版本范围大于
1.11.1
版本,且小于1.13
。如需更多信息,请参阅"支持版本范围"和"Version 比较字符串"。
如果要更新到可以从频道解析的最新版本,请编辑类似以下示例的 CR:
带有指定频道的 CR 示例
apiVersion: olm.operatorframework.io/v1alpha1 kind: ClusterExtension metadata: name: pipelines-operator spec: packageName: openshift-pipelines-operator-rh installNamespace: <namespace> channel: pipelines-1.13 1
- 1
- 安装可从指定频道解析的最新版本。对频道的更新会自动安装。
如果要指定频道和版本范围,请编辑类似以下示例的 CR:
带有指定频道和版本范围的 CR 示例
apiVersion: olm.operatorframework.io/v1alpha1 kind: ClusterExtension metadata: name: pipelines-operator spec: packageName: openshift-pipelines-operator-rh installNamespace: <namespace> channel: latest version: "<1.13"
如需更多信息,请参阅"指定目标版本的示例自定义资源(CR) "。
运行以下命令,将更新应用到集群:
$ oc apply -f pipelines-operator.yaml
输出示例
clusterextension.olm.operatorframework.io/pipelines-operator configured
提示您可以运行以下命令来通过 CLI 对 CR 进行补丁并应用更改:
$ oc patch clusterextension/pipelines-operator -p \ '{"spec":{"version":"<1.13"}}' \ --type=merge
输出示例
clusterextension.olm.operatorframework.io/pipelines-operator patched
验证
运行以下命令验证频道和版本更新是否已应用:
$ oc get clusterextension pipelines-operator -o yaml
例 5.20. 输出示例
apiVersion: olm.operatorframework.io/v1alpha1 kind: ClusterExtension metadata: annotations: kubectl.kubernetes.io/last-applied-configuration: | {"apiVersion":"olm.operatorframework.io/v1alpha1","kind":"ClusterExtension","metadata":{"annotations":{},"name":"pipelines-operator"},"spec":{"channel":"latest","installNamespace":"openshift-operators","packageName":"openshift-pipelines-operator-rh","pollInterval":"30m","version":"\u003c1.13"}} creationTimestamp: "2024-06-11T18:23:26Z" generation: 2 name: pipelines-operator resourceVersion: "66310" uid: ce0416ba-13ea-4069-a6c8-e5efcbc47537 spec: channel: latest installNamespace: openshift-operators packageName: openshift-pipelines-operator-rh upgradeConstraintPolicy: Enforce version: <1.13 status: conditions: - lastTransitionTime: "2024-06-11T18:23:33Z" message: resolved to "registry.redhat.io/openshift-pipelines/pipelines-operator-bundle@sha256:814742c8a7cc7e2662598e114c35c13993a7b423cfe92548124e43ea5d469f82" observedGeneration: 2 reason: Success status: "True" type: Resolved - lastTransitionTime: "2024-06-11T18:23:52Z" message: installed from "registry.redhat.io/openshift-pipelines/pipelines-operator-bundle@sha256:814742c8a7cc7e2662598e114c35c13993a7b423cfe92548124e43ea5d469f82" observedGeneration: 2 reason: Success status: "True" type: Installed - lastTransitionTime: "2024-06-11T18:23:33Z" message: "" observedGeneration: 2 reason: Deprecated status: "False" type: Deprecated - lastTransitionTime: "2024-06-11T18:23:33Z" message: "" observedGeneration: 2 reason: Deprecated status: "False" type: PackageDeprecated - lastTransitionTime: "2024-06-11T18:23:33Z" message: "" observedGeneration: 2 reason: Deprecated status: "False" type: ChannelDeprecated - lastTransitionTime: "2024-06-11T18:23:33Z" message: "" observedGeneration: 2 reason: Deprecated status: "False" type: BundleDeprecated installedBundle: name: openshift-pipelines-operator-rh.v1.12.2 version: 1.12.2 resolvedBundle: name: openshift-pipelines-operator-rh.v1.12.2 version: 1.12.2
故障排除
如果您指定已弃用或不存在的目标版本或频道,您可以运行以下命令来检查扩展的状态:
$ oc get clusterextension <operator_name> -o yaml
例 5.21. 不存在版本的输出示例
apiVersion: olm.operatorframework.io/v1alpha1 kind: ClusterExtension metadata: annotations: kubectl.kubernetes.io/last-applied-configuration: | {"apiVersion":"olm.operatorframework.io/v1alpha1","kind":"ClusterExtension","metadata":{"annotations":{},"name":"pipelines-operator"},"spec":{"channel":"latest","installNamespace":"openshift-operators","packageName":"openshift-pipelines-operator-rh","pollInterval":"30m","version":"3.0"}} creationTimestamp: "2024-06-11T18:23:26Z" generation: 3 name: pipelines-operator resourceVersion: "71852" uid: ce0416ba-13ea-4069-a6c8-e5efcbc47537 spec: channel: latest installNamespace: openshift-operators packageName: openshift-pipelines-operator-rh upgradeConstraintPolicy: Enforce version: "3.0" status: conditions: - lastTransitionTime: "2024-06-11T18:29:02Z" message: 'error upgrading from currently installed version "1.12.2": no package "openshift-pipelines-operator-rh" matching version "3.0" found in channel "latest"' observedGeneration: 3 reason: ResolutionFailed status: "False" type: Resolved - lastTransitionTime: "2024-06-11T18:29:02Z" message: installation has not been attempted as resolution failed observedGeneration: 3 reason: InstallationStatusUnknown status: Unknown type: Installed - lastTransitionTime: "2024-06-11T18:29:02Z" message: deprecation checks have not been attempted as resolution failed observedGeneration: 3 reason: Deprecated status: Unknown type: Deprecated - lastTransitionTime: "2024-06-11T18:29:02Z" message: deprecation checks have not been attempted as resolution failed observedGeneration: 3 reason: Deprecated status: Unknown type: PackageDeprecated - lastTransitionTime: "2024-06-11T18:29:02Z" message: deprecation checks have not been attempted as resolution failed observedGeneration: 3 reason: Deprecated status: Unknown type: ChannelDeprecated - lastTransitionTime: "2024-06-11T18:29:02Z" message: deprecation checks have not been attempted as resolution failed observedGeneration: 3 reason: Deprecated status: Unknown type: BundleDeprecated
其他资源
5.1.6. 删除 Operator
您可以通过删除 ClusterExtension
自定义资源 (CR) 来删除 Operator 及其自定义资源定义 (CRD)。
先决条件
- 已安装目录。
- 已安装 Operator。
流程
运行以下命令来删除 Operator 及其 CRD:
$ oc delete clusterextension <operator_name>
输出示例
clusterextension.olm.operatorframework.io "<operator_name>" deleted
验证
运行以下命令验证您的 Operator 及其资源已被删除:
运行以下命令验证 Operator 已被删除:
$ oc get clusterextensions
输出示例
No resources found
运行以下命令验证 Operator 的系统命名空间是否已删除:
$ oc get ns <operator_name>-system
输出示例
Error from server (NotFound): namespaces "<operator_name>-system" not found