第 5 章 集群扩展
5.1. 管理集群扩展 复制链接链接已复制到粘贴板!
将一个目录被添加到集群后,您可以访问发布到目录的扩展和 Operator 版本、补丁和无线更新。
您可以使用自定义资源(CR)从 CLI 声明性管理扩展。
对于 OpenShift Container Platform 4.20,适用于 OLM v1 的流程都是基于 CLI 的。另外,管理员也可以使用普通方法(如 Import YAML 和 Search 页面)在 web 控制台中创建和查看相关对象。但是,现有的 Software Catalog 和 Installed Operators 页还不会显示 OLM v1 组件。
5.1.1. 支持的扩展 复制链接链接已复制到粘贴板!
目前,Operator Lifecycle Manager (OLM) v1 支持安装满足以下所有条件的集群扩展:
-
扩展必须使用 OLM (Classic) 中引入的
registry+v1捆绑包格式。 扩展必须通过
AllNamespaces安装模式支持安装。-
您可以使用
SingleNamespace和OwnNamespace安装模式作为 OpenShift Container Platform 4.20 中的技术预览功能。
-
您可以使用
扩展不能使用 Webhook。
- 您可以在 OpenShift Container Platform 4.20 中安装使用 webhook 作为技术预览功能的扩展。
扩展不能使用以下基于文件的目录属性声明依赖项:
-
olm.gvk.required -
olm.package.required -
olm.constraint
-
OLM v1 检查您要安装的扩展是否满足这些限制。如果要安装的扩展不符合这些限制,会在集群扩展条件中输出错误消息。
在特定命名空间中部署扩展,并使用 Webhook 安装扩展只是一个技术预览功能。技术预览功能不受红帽产品服务等级协议(SLA)支持,且功能可能并不完整。红帽不推荐在生产环境中使用它们。这些技术预览功能可以使用户提早试用新的功能,并有机会在开发阶段提供反馈意见。
有关红帽技术预览功能支持范围的更多信息,请参阅以下链接:
Operator Lifecycle Manager (OLM) v1 不支持 OLM 中引入的 OperatorConditions API (Classic)。
如果扩展依赖于 OperatorConditions API 管理更新,扩展可能无法正确安装。大多数依赖此 API 的扩展都会在启动时失败,但在协调过程中可能会失败。
作为临时解决方案,您可以将扩展固定到特定的版本。当您想更新扩展时,请查阅扩展文档来查找何时安全将扩展固定到新版本。
5.1.2. 从目录查找 Operator 复制链接链接已复制到粘贴板!
在集群中添加目录后,您可以查询目录以查找要安装的 Operator 和扩展。
目前,在 Operator Lifecycle Manager (OLM) v1 中,您无法查询由 catalogd 管理的集群目录。在 OLM v1 中,您必须使用 opm 和 jq CLI 工具查询目录 registry。
先决条件
- 您已在集群中添加目录。
-
已安装
jqCLI 工具。 -
已安装
opmCLI 工具。
流程
要返回支持
AllNamespaces安装模式的扩展列表,且不使用 Webhook,请输入以下命令:$ opm render <catalog_registry_url>:<tag> \ | jq -cs '[.[] | select(.schema == "olm.bundle" \ and (.properties[] | select(.type == "olm.csv.metadata").value.installModes[] \ | select(.type == "AllNamespaces" and .supported == true)) \ and .spec.webhookdefinitions == null) | .package] | unique[]'其中:
catalog_registry_url-
指定目录 registry 的 URL,如
registry.redhat.io/redhat/redhat-operator-index。 tag指定目录的标签或版本,如
v4.20或latest。例 5.1. 示例命令
$ opm render \ registry.redhat.io/redhat/redhat-operator-index:v4.20 \ | jq -cs '[.[] | select(.schema == "olm.bundle" \ and (.properties[] | select(.type == "olm.csv.metadata").value.installModes[] \ | select(.type == "AllNamespaces" and .supported == true)) \ and .spec.webhookdefinitions == null) | .package] | unique[]'例 5.2. 输出示例
"3scale-operator" "amq-broker-rhel8" "amq-online" "amq-streams" "amq-streams-console" "ansible-automation-platform-operator" "ansible-cloud-addons-operator" "apicast-operator" "authorino-operator" "aws-load-balancer-operator" "bamoe-kogito-operator" "cephcsi-operator" "cincinnati-operator" "cluster-logging" "cluster-observability-operator" "compliance-operator" "container-security-operator" "cryostat-operator" "datagrid" "devspaces" ...
运行以下命令,检查扩展的元数据内容:
$ opm render <catalog_registry_url>:<tag> \ | jq -s '.[] | select( .schema == "olm.package") \ | select( .name == "<package_name>")'例 5.3. 示例命令
$ opm render \ registry.redhat.io/redhat/redhat-operator-index:v4.20 \ | jq -s '.[] | select( .schema == "olm.package") \ | select( .name == "openshift-pipelines-operator-rh")'例 5.4. 输出示例
{ "schema": "olm.package", "name": "openshift-pipelines-operator-rh", "defaultChannel": "latest", "icon": { "base64data": "iVBORw0KGgoAAAANSUhE...", "mediatype": "image/png" } }
5.1.2.1. 常见目录查询 复制链接链接已复制到粘贴板!
您可以使用 opm 和 jq CLI 工具查询目录。下表显示了您可以在安装、更新和管理扩展生命周期时使用的通用目录查询。
命令语法
$ opm render <catalog_registry_url>:<tag> | <jq_request>
其中:
catalog_registry_url-
指定目录 registry 的 URL,如
registry.redhat.io/redhat/redhat-operator-index。 tag-
指定目录的标签或版本,如
v4.20或latest。 jq_request- 指定您要在目录上运行的查询。
例 5.5. 示例命令
$ opm render \
registry.redhat.io/redhat/redhat-operator-index:v4.20 \
| jq -cs '[.[] | select(.schema == "olm.bundle" and (.properties[] \
| select(.type == "olm.csv.metadata").value.installModes[] \
| select(.type == "AllNamespaces" and .supported == true)) \
and .spec.webhookdefinitions == null) \
| .package] | unique[]'
| 查询 | Request(请求) |
|---|---|
| 目录中的可用软件包 |
|
|
支持 |
|
| 软件包元数据 |
|
| 软件包中的目录 Blob |
|
| 查询 | Request(请求) |
|---|---|
| 软件包中的频道 |
|
| 频道中的版本 |
|
|
|
| 查询 | Request(请求) |
|---|---|
| 软件包中的捆绑包 |
|
|
|
5.1.3. 集群扩展权限 复制链接链接已复制到粘贴板!
在 Operator Lifecycle Manager (OLM) Classic 中,具有集群管理员特权的单一服务帐户管理所有集群扩展。
OLM v1 被设计为默认比 OLM (Classic) 更安全。OLM v1 使用在扩展的自定义资源(CR)中指定的服务帐户管理集群扩展。集群管理员可以为每个集群扩展创建一个服务帐户。因此,管理员可以遵循最小特权的原则,只分配基于角色的访问控制(RBAC)来安装和管理该扩展。
您必须向集群角色或角色添加每个权限。然后,您必须使用集群角色绑定或角色绑定将集群角色或角色绑定到服务帐户。
您可以将 RBAC 限定为集群或命名空间。使用集群角色和集群角色绑定将权限范围到集群。使用角色和角色绑定将权限范围到命名空间。无论您将权限范围到集群还是命名空间取决于您要安装和管理的扩展设计。
为简化以下步骤并改进可读性,以下示例清单使用范围到集群的权限。您可以进一步限制某些权限,方法是将它们限定到扩展名的命名空间,而不是集群。
如果已安装的扩展的新版本需要额外的权限,OLM v1 会停止更新过程,直到集群管理员授予这些权限。
5.1.3.1. 创建命名空间 复制链接链接已复制到粘贴板!
在创建用于安装和管理集群扩展的服务帐户前,您必须创建一个命名空间。
先决条件
-
使用具有
cluster-admin权限的账户访问 OpenShift Container Platform 集群。
流程
运行以下命令,为您要安装的扩展的服务帐户创建新命名空间:
$ oc adm new-project <new_namespace>
5.1.3.2. 为扩展创建服务帐户 复制链接链接已复制到粘贴板!
您必须创建一个服务帐户来安装、管理和更新集群扩展。
先决条件
-
使用具有
cluster-admin权限的账户访问 OpenShift Container Platform 集群。
流程
创建服务帐户,类似以下示例:
apiVersion: v1 kind: ServiceAccount metadata: name: <extension>-installer namespace: <namespace>例 5.6.
extension-service-account.yaml文件示例apiVersion: v1 kind: ServiceAccount metadata: name: pipelines-installer namespace: pipelines运行以下命令来应用服务帐户:
$ oc apply -f extension-service-account.yaml
5.1.3.3. 下载扩展的捆绑包清单 复制链接链接已复制到粘贴板!
使用 opm CLI 工具下载您要安装的扩展的捆绑包清单。使用您选择的 CLI 工具或文本编辑器查看清单,并找到安装和管理扩展所需的权限。
先决条件
-
可以使用具有
cluster-admin权限的账户访问 OpenShift Container Platform 集群。 - 您已决定要安装的扩展。
-
已安装
opmCLI 工具。
流程
运行以下命令,检查您要安装的扩展的可用版本和镜像:
$ opm render <registry_url>:<tag_or_version> | \ jq -cs '.[] | select( .schema == "olm.bundle" ) | \ select( .package == "<extension_name>") | \ {"name":.name, "image":.image}'例 5.7. 示例命令
$ opm render registry.redhat.io/redhat/redhat-operator-index:v4.20 | \ jq -cs '.[] | select( .schema == "olm.bundle" ) | \ select( .package == "openshift-pipelines-operator-rh") | \ {"name":.name, "image":.image}'例 5.8. 输出示例
{"name":"openshift-pipelines-operator-rh.v1.14.3","image":"registry.redhat.io/openshift-pipelines/pipelines-operator-bundle@sha256:3f64b29f6903981470d0917b2557f49d84067bccdba0544bfe874ec4412f45b0"} {"name":"openshift-pipelines-operator-rh.v1.14.4","image":"registry.redhat.io/openshift-pipelines/pipelines-operator-bundle@sha256:dd3d18367da2be42539e5dde8e484dac3df33ba3ce1d5bcf896838954f3864ec"} {"name":"openshift-pipelines-operator-rh.v1.14.5","image":"registry.redhat.io/openshift-pipelines/pipelines-operator-bundle@sha256:f7b19ce26be742c4aaa458d37bc5ad373b5b29b20aaa7d308349687d3cbd8838"} {"name":"openshift-pipelines-operator-rh.v1.15.0","image":"registry.redhat.io/openshift-pipelines/pipelines-operator-bundle@sha256:22be152950501a933fe6e1df0e663c8056ca910a89dab3ea801c3bb2dc2bf1e6"} {"name":"openshift-pipelines-operator-rh.v1.15.1","image":"registry.redhat.io/openshift-pipelines/pipelines-operator-bundle@sha256:64afb32e3640bb5968904b3d1a317e9dfb307970f6fda0243e2018417207fd75"} {"name":"openshift-pipelines-operator-rh.v1.15.2","image":"registry.redhat.io/openshift-pipelines/pipelines-operator-bundle@sha256:8a593c1144709c9aeffbeb68d0b4b08368f528e7bb6f595884b2474bcfbcafcd"} {"name":"openshift-pipelines-operator-rh.v1.16.0","image":"registry.redhat.io/openshift-pipelines/pipelines-operator-bundle@sha256:a46b7990c0ad07dae78f43334c9bd5e6cba7b50ca60d3f880099b71e77bed214"} {"name":"openshift-pipelines-operator-rh.v1.16.1","image":"registry.redhat.io/openshift-pipelines/pipelines-operator-bundle@sha256:29f27245e93b3f605647993884751c490c4a44070d3857a878d2aee87d43f85b"} {"name":"openshift-pipelines-operator-rh.v1.16.2","image":"registry.redhat.io/openshift-pipelines/pipelines-operator-bundle@sha256:2037004666526c90329f4791f14cb6cc06e8775cb84ba107a24cc4c2cf944649"} {"name":"openshift-pipelines-operator-rh.v1.17.0","image":"registry.redhat.io/openshift-pipelines/pipelines-operator-bundle@sha256:d75065e999826d38408049aa1fde674cd1e45e384bfdc96523f6bad58a0e0dbc"}运行以下命令,创建一个目录来提取您要安装的捆绑包镜像:
$ mkdir <new_dir>运行以下命令来更改目录:
$ cd <new_dir>查找您要安装并运行以下命令的镜像引用:
$ oc image extract <full_path_to_registry_image>@sha256:<sha>示例命令
$ oc image extract registry.redhat.io/openshift-pipelines/pipelines-operator-bundle@sha256:f7b19ce26be742c4aaa458d37bc5ad373b5b29b20aaa7d308349687d3cbd8838运行以下命令来更改
manifests目录:$ cd manifests输入以下命令来查看 manifests 目录的内容。输出中列出了安装、管理和操作扩展所需的资源清单。
$ tree例 5.9. 输出示例
. ├── manifests │ ├── config-logging_v1_configmap.yaml │ ├── openshift-pipelines-operator-monitor_monitoring.coreos.com_v1_servicemonitor.yaml │ ├── openshift-pipelines-operator-prometheus-k8s-read-binding_rbac.authorization.k8s.io_v1_rolebinding.yaml │ ├── openshift-pipelines-operator-read_rbac.authorization.k8s.io_v1_role.yaml │ ├── openshift-pipelines-operator-rh.clusterserviceversion.yaml │ ├── operator.tekton.dev_manualapprovalgates.yaml │ ├── operator.tekton.dev_openshiftpipelinesascodes.yaml │ ├── operator.tekton.dev_tektonaddons.yaml │ ├── operator.tekton.dev_tektonchains.yaml │ ├── operator.tekton.dev_tektonconfigs.yaml │ ├── operator.tekton.dev_tektonhubs.yaml │ ├── operator.tekton.dev_tektoninstallersets.yaml │ ├── operator.tekton.dev_tektonpipelines.yaml │ ├── operator.tekton.dev_tektonresults.yaml │ ├── operator.tekton.dev_tektontriggers.yaml │ ├── tekton-config-defaults_v1_configmap.yaml │ ├── tekton-config-observability_v1_configmap.yaml │ ├── tekton-config-read-rolebinding_rbac.authorization.k8s.io_v1_clusterrolebinding.yaml │ ├── tekton-config-read-role_rbac.authorization.k8s.io_v1_clusterrole.yaml │ ├── tekton-operator-controller-config-leader-election_v1_configmap.yaml │ ├── tekton-operator-info_rbac.authorization.k8s.io_v1_rolebinding.yaml │ ├── tekton-operator-info_rbac.authorization.k8s.io_v1_role.yaml │ ├── tekton-operator-info_v1_configmap.yaml │ ├── tekton-operator_v1_service.yaml │ ├── tekton-operator-webhook-certs_v1_secret.yaml │ ├── tekton-operator-webhook-config-leader-election_v1_configmap.yaml │ ├── tekton-operator-webhook_v1_service.yaml │ ├── tekton-result-read-rolebinding_rbac.authorization.k8s.io_v1_clusterrolebinding.yaml │ └── tekton-result-read-role_rbac.authorization.k8s.io_v1_clusterrole.yaml ├── metadata │ ├── annotations.yaml │ └── properties.yaml └── root └── buildinfo ├── content_manifests │ └── openshift-pipelines-operator-bundle-container-v1.16.2-3.json └── Dockerfile-openshift-pipelines-pipelines-operator-bundle-container-v1.16.2-3
后续步骤
-
使用您首选的 CLI 工具或文本编辑器,查看
manifests目录中集群服务版本(CSV)文件的install.spec.clusterpermissions小节的内容。以下示例引用了 Red Hat OpenShift Pipelines Operator 的openshift-pipelines-operator-rh.clusterserviceversion.yaml文件。 - 在以下流程中,保留此文件作为参考,同时为集群角色文件分配权限。
5.1.3.4. 安装和管理集群扩展所需的权限 复制链接链接已复制到粘贴板!
您必须检查集群扩展的捆绑包镜像中包含的清单,以分配所需的权限。服务帐户需要足够的基于角色的访问控制(RBAC)来创建和管理以下资源。
遵循最小特权和范围权限到特定资源名称的原则,且具有运行所需的最小 RBAC。
- 准入插件
-
因为 OpenShift Container Platform 集群使用
OwnerReferencesPermissionEnforcement准入插件,集群扩展必须具有更新blockOwnerDeletion和ownerReferencesfinalizers 的权限。 - 扩展的控制器的集群角色和集群角色绑定
- 您必须定义 RBAC,以便安装服务帐户可以为扩展控制器创建和管理集群角色和集群角色绑定。
- 集群服务版本(CSV)
- 您必须为集群扩展的 CSV 中定义的资源定义 RBAC。
- 集群范围的捆绑包资源
-
您必须定义 RBAC,以创建和管理捆绑包中包含的任何集群范围的资源。如果集群范围的资源与另一个资源类型匹配,如
ClusterRole,您可以在resources或resourceNames字段中将资源添加到预先存在的规则中。 - 自定义资源定义(CRD)
- 您必须定义 RBAC,以便安装服务帐户可以为扩展创建和管理 CRD。另外,您必须为 RBAC 的控制器授予服务帐户来管理其 CRD。
- 部署
- 您必须为安装服务帐户定义 RBAC,以创建和管理扩展控制器所需的部署,如服务和配置映射。
- 扩展权限
- 您必须包含 CSV 中定义的权限和集群权限的 RBAC。安装服务帐户需要能够向扩展控制器授予这些权限,因为扩展控制器需要这些权限才能正常运行。
- 命名空间范围的捆绑包资源
- 您必须为任何命名空间范围的捆绑包资源定义 RBAC。安装服务帐户需要相应的权限来创建和管理资源,如配置映射或服务。
- 角色和角色绑定
- 您必须为 CSV 中定义的任何角色或角色绑定定义 RBAC。安装服务帐户需要相应的权限来创建和管理这些角色和角色绑定。
- 服务帐户
- 您必须定义 RBAC,以便安装服务帐户可以为扩展控制器创建和管理服务帐户。
5.1.3.5. 为扩展创建集群角色 复制链接链接已复制到粘贴板!
您必须查看集群服务版本(CSV)的 install.spec.clusterpermissions 小节,并仔细查看扩展的清单,以定义您要安装的扩展所需的基于角色的访问控制(RBAC)。您必须通过将所需的 RBAC 从 CSV 复制到新清单来创建集群角色。
如果要测试在 OLM v1 中安装和更新扩展的过程,您可以使用以下集群角色授予集群管理员权限。此清单仅用于测试目的。它不应该在生产环境中使用。
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: <extension>-installer-clusterrole
rules:
- apiGroups: ["*"]
resources: ["*"]
verbs: ["*"]
以下流程使用 Red Hat OpenShift Pipelines Operator 的 openshift-pipelines-operator-rh.clusterserviceversion.yaml 文件作为示例。示例包括安装和管理 OpenShift Pipelines Operator 所需的 RBAC 摘录。有关完整的清单,请参阅"Red Hat OpenShift Pipelines Operator 的集群角色示例"。
为简化以下步骤并改进可读性,以下示例清单使用范围到集群的权限。您可以进一步限制某些权限,方法是将它们限定到扩展名的命名空间,而不是集群。
先决条件
-
使用具有
cluster-admin权限的账户访问 OpenShift Container Platform 集群。 - 您已在要安装的扩展的镜像引用中下载了清单。
流程
创建新集群角色清单,如下例所示:
示例
<extension>-cluster-role.yaml文件apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: <extension>-installer-clusterrole编辑集群角色清单使其包含在扩展上更新终结器的权限,如下例所示:
示例 <extension>-cluster-role.yaml
apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: pipelines-installer-clusterrole rules: - apiGroups: - olm.operatorframework.io resources: - clusterextensions/finalizers verbs: - update # Scoped to the name of the ClusterExtension resourceNames: - <metadata_name>1 - 1
- 指定来自扩展的自定义资源(CR)的
metadata.name字段的值。
在扩展的 CSV 文件中的
rules.resources字段中搜索clusterrole和clusterrolebindings值。将 API 组、资源、操作动词和资源名称复制到您的清单中,如下例所示:
集群角色清单示例
apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: pipelines-installer-clusterrole rules: # ... # ClusterRoles and ClusterRoleBindings for the controllers of the extension - apiGroups: - rbac.authorization.k8s.io resources: - clusterroles verbs: - create1 - list - watch - apiGroups: - rbac.authorization.k8s.io resources: - clusterroles verbs: - get - update - patch - delete resourceNames:2 - "*" - apiGroups: - rbac.authorization.k8s.io resources: - clusterrolebindings verbs: - create - list - watch - apiGroups: - rbac.authorization.k8s.io resources: - clusterrolebindings verbs: - get - update - patch - delete resourceNames: - "*" # ...
在扩展的 CSV 文件中的
rules.resources字段中搜索customresourcedefinitions值。将 API 组、资源、操作动词和资源名称复制到您的清单中,如下例所示:
apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: pipelines-installer-clusterrole rules: # ... # Custom resource definitions of the extension - apiGroups: - apiextensions.k8s.io resources: - customresourcedefinitions verbs: - create - list - watch - apiGroups: - apiextensions.k8s.io resources: - customresourcedefinitions verbs: - get - update - patch - delete resourceNames: - manualapprovalgates.operator.tekton.dev - openshiftpipelinesascodes.operator.tekton.dev - tektonaddons.operator.tekton.dev - tektonchains.operator.tekton.dev - tektonconfigs.operator.tekton.dev - tektonhubs.operator.tekton.dev - tektoninstallersets.operator.tekton.dev - tektonpipelines.operator.tekton.dev - tektonresults.operator.tekton.dev - tektontriggers.operator.tekton.dev # ...
在
rules.resourcesspec 中搜索带有permissions和clusterPermissions值的小节。将 API 组、资源、操作动词和资源名称复制到您的清单中,如下例所示:
apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: pipelines-installer-clusterrole rules: # ... # Excerpt from install.spec.clusterPermissions - apiGroups: - '' resources: - nodes - pods - services - endpoints - persistentvolumeclaims - events - configmaps - secrets - pods/log - limitranges verbs: - create - list - watch - delete - deletecollection - patch - get - update - apiGroups: - extensions - apps resources: - ingresses - ingresses/status verbs: - create - list - watch - delete - patch - get - update # ...
在
install.spec.deployments小节中搜索资源的 CSV 文件。将 API 组、资源、操作动词和资源名称复制到您的清单中,如下例所示:
apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: pipelines-installer-clusterrole rules: # ... # Excerpt from install.spec.deployments - apiGroups: - apps resources: - deployments verbs: - create - list - watch - apiGroups: - apps resources: - deployments verbs: - get - update - patch - delete # scoped to the extension controller deployment name resourceNames: - openshift-pipelines-operator - tekton-operator-webhook # ...
在扩展的 CSV 文件中的
rules.resources字段中搜索services和configmaps值。将 API 组、资源、操作动词和资源名称复制到您的清单中,如下例所示:
apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: pipelines-installer-clusterrole rules: # ... # Services - apiGroups: - "" resources: - services verbs: - create - apiGroups: - "" resources: - services verbs: - get - list - watch - update - patch - delete # scoped to the service name resourceNames: - openshift-pipelines-operator-monitor - tekton-operator - tekton-operator-webhook # configmaps - apiGroups: - "" resources: - configmaps verbs: - create - apiGroups: - "" resources: - configmaps verbs: - get - list - watch - update - patch - delete # scoped to the configmap name resourceNames: - config-logging - tekton-config-defaults - tekton-config-observability - tekton-operator-controller-config-leader-election - tekton-operator-info - tekton-operator-webhook-config-leader-election - apiGroups: - operator.tekton.dev resources: - tekton-config-read-role - tekton-result-read-role verbs: - get - watch - list
运行以下命令,将集群角色清单添加到集群中:
$ oc apply -f <extension>-installer-clusterrole.yaml示例命令
$ oc apply -f pipelines-installer-clusterrole.yaml
5.1.3.6. Red Hat OpenShift Pipelines Operator 的集群角色示例 复制链接链接已复制到粘贴板!
如需 OpenShift Pipelines Operator 的完整集群角色清单,请参阅以下示例。
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: pipelines-installer-clusterrole
rules:
- apiGroups:
- olm.operatorframework.io
resources:
- clusterextensions/finalizers
verbs:
- update
# Scoped to the name of the ClusterExtension
resourceNames:
- pipes # the value from <metadata.name> from the extension's custom resource (CR)
# ClusterRoles and ClusterRoleBindings for the controllers of the extension
- apiGroups:
- rbac.authorization.k8s.io
resources:
- clusterroles
verbs:
- create
- list
- watch
- apiGroups:
- rbac.authorization.k8s.io
resources:
- clusterroles
verbs:
- get
- update
- patch
- delete
resourceNames:
- "*"
- apiGroups:
- rbac.authorization.k8s.io
resources:
- clusterrolebindings
verbs:
- create
- list
- watch
- apiGroups:
- rbac.authorization.k8s.io
resources:
- clusterrolebindings
verbs:
- get
- update
- patch
- delete
resourceNames:
- "*"
# Extension's custom resource definitions
- apiGroups:
- apiextensions.k8s.io
resources:
- customresourcedefinitions
verbs:
- create
- list
- watch
- apiGroups:
- apiextensions.k8s.io
resources:
- customresourcedefinitions
verbs:
- get
- update
- patch
- delete
resourceNames:
- manualapprovalgates.operator.tekton.dev
- openshiftpipelinesascodes.operator.tekton.dev
- tektonaddons.operator.tekton.dev
- tektonchains.operator.tekton.dev
- tektonconfigs.operator.tekton.dev
- tektonhubs.operator.tekton.dev
- tektoninstallersets.operator.tekton.dev
- tektonpipelines.operator.tekton.dev
- tektonresults.operator.tekton.dev
- tektontriggers.operator.tekton.dev
- apiGroups:
- ''
resources:
- nodes
- pods
- services
- endpoints
- persistentvolumeclaims
- events
- configmaps
- secrets
- pods/log
- limitranges
verbs:
- create
- list
- watch
- delete
- deletecollection
- patch
- get
- update
- apiGroups:
- extensions
- apps
resources:
- ingresses
- ingresses/status
verbs:
- create
- list
- watch
- delete
- patch
- get
- update
- apiGroups:
- ''
resources:
- namespaces
verbs:
- get
- list
- create
- update
- delete
- patch
- watch
- apiGroups:
- apps
resources:
- deployments
- daemonsets
- replicasets
- statefulsets
- deployments/finalizers
verbs:
- delete
- deletecollection
- create
- patch
- get
- list
- update
- watch
- apiGroups:
- monitoring.coreos.com
resources:
- servicemonitors
verbs:
- get
- create
- delete
- apiGroups:
- rbac.authorization.k8s.io
resources:
- clusterroles
- roles
verbs:
- delete
- deletecollection
- create
- patch
- get
- list
- update
- watch
- bind
- escalate
- apiGroups:
- ''
resources:
- serviceaccounts
verbs:
- get
- list
- create
- update
- delete
- patch
- watch
- impersonate
- apiGroups:
- rbac.authorization.k8s.io
resources:
- clusterrolebindings
- rolebindings
verbs:
- get
- update
- delete
- patch
- create
- list
- watch
- apiGroups:
- apiextensions.k8s.io
resources:
- customresourcedefinitions
- customresourcedefinitions/status
verbs:
- get
- create
- update
- delete
- list
- patch
- watch
- apiGroups:
- admissionregistration.k8s.io
resources:
- mutatingwebhookconfigurations
- validatingwebhookconfigurations
verbs:
- get
- list
- create
- update
- delete
- patch
- watch
- apiGroups:
- build.knative.dev
resources:
- builds
- buildtemplates
- clusterbuildtemplates
verbs:
- get
- list
- create
- update
- delete
- patch
- watch
- apiGroups:
- extensions
resources:
- deployments
verbs:
- get
- list
- create
- update
- delete
- patch
- watch
- apiGroups:
- extensions
resources:
- deployments/finalizers
verbs:
- get
- list
- create
- update
- delete
- patch
- watch
- apiGroups:
- operator.tekton.dev
resources:
- '*'
- tektonaddons
verbs:
- delete
- deletecollection
- create
- patch
- get
- list
- update
- watch
- apiGroups:
- tekton.dev
- triggers.tekton.dev
- operator.tekton.dev
- pipelinesascode.tekton.dev
resources:
- '*'
verbs:
- add
- delete
- deletecollection
- create
- patch
- get
- list
- update
- watch
- apiGroups:
- dashboard.tekton.dev
resources:
- '*'
- tektonaddons
verbs:
- delete
- deletecollection
- create
- patch
- get
- list
- update
- watch
- apiGroups:
- security.openshift.io
resources:
- securitycontextconstraints
verbs:
- use
- get
- list
- create
- update
- delete
- apiGroups:
- events.k8s.io
resources:
- events
verbs:
- create
- apiGroups:
- route.openshift.io
resources:
- routes
verbs:
- delete
- deletecollection
- create
- patch
- get
- list
- update
- watch
- apiGroups:
- coordination.k8s.io
resources:
- leases
verbs:
- get
- list
- create
- update
- delete
- patch
- watch
- apiGroups:
- console.openshift.io
resources:
- consoleyamlsamples
- consoleclidownloads
- consolequickstarts
- consolelinks
verbs:
- delete
- deletecollection
- create
- patch
- get
- list
- update
- watch
- apiGroups:
- autoscaling
resources:
- horizontalpodautoscalers
verbs:
- delete
- create
- patch
- get
- list
- update
- watch
- apiGroups:
- policy
resources:
- poddisruptionbudgets
verbs:
- delete
- deletecollection
- create
- patch
- get
- list
- update
- watch
- apiGroups:
- monitoring.coreos.com
resources:
- servicemonitors
verbs:
- delete
- deletecollection
- create
- patch
- get
- list
- update
- watch
- apiGroups:
- batch
resources:
- jobs
- cronjobs
verbs:
- delete
- deletecollection
- create
- patch
- get
- list
- update
- watch
- apiGroups:
- ''
resources:
- namespaces/finalizers
verbs:
- update
- apiGroups:
- resolution.tekton.dev
resources:
- resolutionrequests
- resolutionrequests/status
verbs:
- get
- list
- watch
- create
- delete
- update
- patch
- apiGroups:
- console.openshift.io
resources:
- consoleplugins
verbs:
- get
- list
- watch
- create
- delete
- update
- patch
# Deployments specified in install.spec.deployments
- apiGroups:
- apps
resources:
- deployments
verbs:
- create
- list
- watch
- apiGroups:
- apps
resources:
- deployments
verbs:
- get
- update
- patch
- delete
# scoped to the extension controller deployment name
resourceNames:
- openshift-pipelines-operator
- tekton-operator-webhook
# Service accounts in the CSV
- apiGroups:
- ""
resources:
- serviceaccounts
verbs:
- create
- list
- watch
- apiGroups:
- ""
resources:
- serviceaccounts
verbs:
- get
- update
- patch
- delete
# scoped to the extension controller's deployment service account
resourceNames:
- openshift-pipelines-operator
# Services
- apiGroups:
- ""
resources:
- services
verbs:
- create
- apiGroups:
- ""
resources:
- services
verbs:
- get
- list
- watch
- update
- patch
- delete
# scoped to the service name
resourceNames:
- openshift-pipelines-operator-monitor
- tekton-operator
- tekton-operator-webhook
# configmaps
- apiGroups:
- ""
resources:
- configmaps
verbs:
- create
- apiGroups:
- ""
resources:
- configmaps
verbs:
- get
- list
- watch
- update
- patch
- delete
# scoped to the configmap name
resourceNames:
- config-logging
- tekton-config-defaults
- tekton-config-observability
- tekton-operator-controller-config-leader-election
- tekton-operator-info
- tekton-operator-webhook-config-leader-election
- apiGroups:
- operator.tekton.dev
resources:
- tekton-config-read-role
- tekton-result-read-role
verbs:
- get
- watch
- list
---
5.1.3.7. 为扩展创建集群角色绑定 复制链接链接已复制到粘贴板!
创建服务帐户和集群角色后,您必须将集群角色绑定到带有集群角色绑定清单的服务帐户。
先决条件
-
使用具有
cluster-admin权限的账户访问 OpenShift Container Platform 集群。 您已为要安装的扩展创建并应用以下资源:
- Namespace
- 服务帐户
- 集群角色
流程
创建集群角色绑定将集群角色绑定绑定到服务帐户,如下例所示:
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.10.
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 (Classic) Operator,它们仅限于集群。如需更多信息,请参阅支持的扩展。
对于 OpenShift Container Platform 4.20,适用于 OLM v1 的流程都是基于 CLI 的。另外,管理员也可以使用普通方法(如 Import YAML 和 Search 页面)在 web 控制台中创建和查看相关对象。但是,现有的 Software Catalog 和 Installed Operators 页还不会显示 OLM v1 组件。
先决条件
- 您已创建了服务帐户,并分配了足够的基于角色的访问控制 (RBAC) 来安装、更新和管理您要安装的扩展。如需更多信息,请参阅"集群扩展权限"。
流程
创建一个类似以下示例的 CR:
apiVersion: olm.operatorframework.io/v1 kind: ClusterExtension metadata: name: <clusterextension_name> spec: namespace: <installed_namespace>1 serviceAccount: name: <service_account_installer_name>2 source: sourceType: Catalog catalog: packageName: <package_name> channels: - <channel_name>3 version: <version_or_version_range>4 upgradeConstraintPolicy: CatalogProvided5 - 1
- 指定您要安装捆绑包的命名空间,如
pipelines或my-extension。扩展仍然是集群范围的,可能包含在不同命名空间中安装的资源。 - 2
- 指定您为安装、更新和管理扩展创建的服务帐户的名称。
- 3
- 可选:将频道名称指定为数组,如
pipelines-1.14或latest。 - 4
- 可选:指定您要安装的软件包的版本或版本范围,如
1.14.0、1.14.x或>=1.16。如需更多信息,请参阅"示例自定义资源(CR)指定目标版本"和"支持版本范围"。 - 5
- 可选:指定升级约束策略。如果未指定,则默认设置为
CatalogProvided。只有在新版本满足软件包作者设置的升级限制时,CatalogProvided设置才会更新。要强制更新或回滚,请将字段设置为SelfCertified。如需更多信息,请参阅"设置更新或回滚"。
pipelines-operator.yaml CR 示例
apiVersion: olm.operatorframework.io/v1
kind: ClusterExtension
metadata:
name: pipelines-operator
spec:
namespace: pipelines
serviceAccount:
name: pipelines-installer
source:
sourceType: Catalog
catalog:
packageName: openshift-pipelines-operator-rh
version: "1.14.x"
运行以下命令,将 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.11. 输出示例
apiVersion: v1 items: - apiVersion: olm.operatorframework.io/v1 kind: ClusterExtension metadata: annotations: kubectl.kubernetes.io/last-applied-configuration: | {"apiVersion":"olm.operatorframework.io/v1","kind":"ClusterExtension","metadata":{"annotations":{},"name":"pipes"},"spec":{"namespace":"pipelines","serviceAccount":{"name":"pipelines-installer"},"source":{"catalog":{"packageName":"openshift-pipelines-operator-rh","version":"1.14.x"},"sourceType":"Catalog"}}} creationTimestamp: "2025-02-18T21:48:13Z" finalizers: - olm.operatorframework.io/cleanup-unpack-cache - olm.operatorframework.io/cleanup-contentmanager-cache generation: 1 name: pipelines-operator resourceVersion: "72725" uid: e18b13fb-a96d-436f-be75-a9a0f2b07993 spec: namespace: pipelines serviceAccount: name: pipelines-installer source: catalog: packageName: openshift-pipelines-operator-rh upgradeConstraintPolicy: CatalogProvided version: 1.14.x sourceType: Catalog status: conditions: - lastTransitionTime: "2025-02-18T21:48:13Z" message: "" observedGeneration: 1 reason: Deprecated status: "False" type: Deprecated - lastTransitionTime: "2025-02-18T21:48:13Z" message: "" observedGeneration: 1 reason: Deprecated status: "False" type: PackageDeprecated - lastTransitionTime: "2025-02-18T21:48:13Z" message: "" observedGeneration: 1 reason: Deprecated status: "False" type: ChannelDeprecated - lastTransitionTime: "2025-02-18T21:48:13Z" message: "" observedGeneration: 1 reason: Deprecated status: "False" type: BundleDeprecated - lastTransitionTime: "2025-02-18T21:48:16Z" message: Installed bundle registry.redhat.io/openshift-pipelines/pipelines-operator-bundle@sha256:f7b19ce26be742c4aaa458d37bc5ad373b5b29b20aaa7d308349687d3cbd8838 successfully observedGeneration: 1 reason: Succeeded status: "True" type: Installed - lastTransitionTime: "2025-02-18T21:48:16Z" message: desired state reached observedGeneration: 1 reason: Succeeded status: "True" type: Progressing install: bundle: name: openshift-pipelines-operator-rh.v1.14.5 version: 1.14.5 kind: List metadata: resourceVersion: ""其中:
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- 显示安装的捆绑包的版本。
5.1.5. 在特定命名空间中部署集群扩展(技术预览) 复制链接链接已复制到粘贴板!
安装模式是 Operator Lifecycle Manager (OLM) Classic 的多租户功能。OLM v1 不支持多租户,并使用 AllNamespaces 安装模式将集群扩展部署到集群。
但是,一些现有集群扩展不支持 AllNamespaces 安装模式。您可以使用 OwnNamespace 或 SingleNamespace 安装模式作为 registry+v1 Operator 捆绑包的技术预览功能在特定命名空间中部署扩展。
不支持 MultiNamespace 安装模式。因此,您无法在集群中多次安装同一 Operator。
在特定命名空间中部署集群扩展只是一个技术预览功能。技术预览功能不受红帽产品服务等级协议(SLA)支持,且功能可能并不完整。红帽不推荐在生产环境中使用它们。这些技术预览功能可以使用户提早试用新的功能,并有机会在开发阶段提供反馈意见。
有关红帽技术预览功能支持范围的更多信息,请参阅以下链接:
如需更多信息,请参阅"支持扩展"。
先决条件
-
使用具有
cluster-admin权限的账户访问 OpenShift Container Platform 集群 -
在集群中启用
TechPreviewNoUpgrade功能集 -
支持
OwnNamespace或SingleNamespace安装模式的 Operator
流程
创建自定义资源(CR),类似以下示例:
示例
<cluster-extension-cr>.yaml文件apiVersion: olm.operatorframework.io/v1 kind: ClusterExtension metadata: name: <clusterextension_name> annotations: olm.operatorframework.io/watch-namespace: <namespace> spec: namespace: <installed_namespace> serviceAccount: name: <service_account_installer_name> source: sourceType: Catalog catalog: packageName: <package_name> channels: - <channel_name> version: <version_or_version_range> upgradeConstraintPolicy: CatalogProvided其中:
namespace指定您要部署集群扩展的命名空间。
-
如果
namespace参数为空,或者注解不存在,则使用AllNamespaces安装模式部署扩展。 -
如果
namespace参数的值与spec.namespace字段中的installed_namespace参数相同,则使用OwnNamespace安装模式部署扩展。 -
如果
namespace参数指定与installed_namespace参数不同的命名空间,则使用SingleNamespace安装模式部署扩展。
-
如果
运行以下命令,将 CR 应用到集群:
$ oc apply -f <cluster_extension_cr>.yaml
5.1.6. 集群扩展的 preflight 权限检查(技术预览) 复制链接链接已复制到粘贴板!
当您尝试安装扩展时,Operator Controller 会执行安装过程的空运行。此空运行验证指定的服务帐户是否可以执行安装扩展所需的所有操作。这包括在捆绑包中创建所有 Kubernetes 对象,以及捆绑包定义的角色和绑定的基于角色的访问控制(RBAC)规则。
对集群扩展的 preflight 权限检查只是一个技术预览功能。技术预览功能不受红帽产品服务等级协议(SLA)支持,且功能可能并不完整。红帽不推荐在生产环境中使用它们。这些技术预览功能可以使用户提早试用新的功能,并有机会在开发阶段提供反馈意见。
有关红帽技术预览功能支持范围的更多信息,请参阅以下链接:
如果服务帐户缺少任何所需的 RBAC 规则,preflight 检查会在实际安装进行前失败。如果 preflight 检查失败,Operator Controller 会在扩展的状态条件和 Operator Controller 日志中报告错误。
要继续安装,请更新角色和绑定,为服务帐户授予缺少的权限并应用更改。如果没有错误,Operator Controller 会协调更新的权限并完成安装。
5.1.6.1. preflight 权限检查的报告示例 复制链接链接已复制到粘贴板!
以下报告表示服务帐户需要以下缺少的权限:
-
用于对整个集群核心 API 组中的
services资源执行list和watch操作的 RBAC 规则 -
用于对
pipelines命名空间的appsAPI 组中的deployments资源执行create操作的 RBAC 规则。
您可以在集群扩展的状态条件中,从 preflight 权限检查报告。oc describe clusterextension 命令打印有关集群扩展的信息,包括状态条件。
示例命令
$ oc describe clusterextension <extension_name>
报告示例
apiVersion: v1
items:
- apiVersion: olm.operatorframework.io/v1
kind: ClusterExtension
...
Conditions:
Type: Progressing
Status: False
Reason: Retrying
Message: pre-authorization failed: service account requires the following permissions to manage cluster extension:
Namespace:"" APIGroups:[] Resources:[services] Verbs:[list,watch]
Namespace:"pipelines" APIGroups:["apps"] Resources:[deployments] Verbs:[create]
Namespace-
在命名空间级别指定所需的 RBAC 规则范围,如
pipelines命名空间。空命名空间值""表示您必须将权限范围到集群。 APIGroups指定所需权限应用到的 API 组的名称。API 组中的空值(
[])表示权限应用到核心 API 组。例如,服务、secret 和配置映射都是核心资源。如果资源属于命名 API 组,报告列出了方括号之间的名称。例如,
APIGroups:[apps]值表示扩展需要 RBAC 规则对appsAPI 组中的资源执行操作。Resources- 指定需要权限的资源类型。例如,服务、secret 和自定义资源定义是常见的资源类型。
Verbs- 指定服务帐户执行操作(或 verbs)所需的权限。如果报告列出了几个操作动词,则所有列出的操作动词都需要 RBAC 规则。
5.1.6.2. 常见权限错误 复制链接链接已复制到粘贴板!
- 缺少操作动词
- 服务帐户没有执行所需操作的权限。要解决这个问题,请更新或创建角色和绑定来授予所需的权限。角色和角色绑定定义命名空间的资源权限。集群角色和集群角色绑定定义集群的资源权限。
- 权限升级
- 服务帐户没有足够的权限来创建扩展所需的角色或集群角色。当发生这种情况时,preflight 检查会报告缺少动词,以防止特权升级。要解决这个问题,请为服务帐户授予足够的权限,使其可以创建角色。
- 缺少角色引用
-
扩展引用 Operator Controller 无法找到的角色或集群角色。当发生这种情况时,preflight 检查会列出缺少的角色,并报告
授权评估错误。要解决这个问题,请创建或更新角色和集群角色,以确保所有角色引用都存在。
5.1.7. 更新集群扩展 复制链接链接已复制到粘贴板!
您可以通过手动编辑自定义资源 (CR) 并应用更改来更新集群扩展或 Operator。
先决条件
- 已安装 Operator 或扩展。
-
已安装
jqCLI 工具。 -
已安装
opmCLI 工具。
流程
通过完成以下步骤,检查目录文件本地副本中的频道和版本信息:
运行以下命令,从所选软件包中获取频道列表:
$ opm render <catalog_registry_url>:<tag> \ | jq -s '.[] | select( .schema == "olm.channel" ) \ | select( .package == "openshift-pipelines-operator-rh") | .name'例 5.12. 示例命令
$ opm render registry.redhat.io/redhat/redhat-operator-index:v4.20 \ | jq -s '.[] | select( .schema == "olm.channel" ) \ | select( .package == "openshift-pipelines-operator-rh") | .name'例 5.13. 输出示例
"latest" "pipelines-1.14" "pipelines-1.15" "pipelines-1.16" "pipelines-1.17"运行以下命令,获取频道中发布的版本列表:
$ opm render <catalog_registry_url>:<tag> \ | jq -s '.[] | select( .package == "<package_name>" ) \ | select( .schema == "olm.channel" ) \ | select( .name == "<channel_name>" ) | .entries \ | .[] | .name'例 5.14. 示例命令
$ opm render registry.redhat.io/redhat/redhat-operator-index:v4.20 \ | jq -s '.[] | select( .package == "openshift-pipelines-operator-rh" ) \ | select( .schema == "olm.channel" ) | select( .name == "latest" ) \ | .entries | .[] | .name'例 5.15. 输出示例
"openshift-pipelines-operator-rh.v1.15.0" "openshift-pipelines-operator-rh.v1.16.0" "openshift-pipelines-operator-rh.v1.17.0" "openshift-pipelines-operator-rh.v1.17.1"
运行以下命令,查找在 Operator 或扩展 CR 中指定哪个版本或频道:
$ oc get clusterextension <operator_name> -o yaml示例命令
$ oc get clusterextension pipelines-operator -o yaml例 5.16. 输出示例
apiVersion: v1 items: - apiVersion: olm.operatorframework.io/v1 kind: ClusterExtension metadata: annotations: kubectl.kubernetes.io/last-applied-configuration: | {"apiVersion":"olm.operatorframework.io/v1","kind":"ClusterExtension","metadata":{"annotations":{},"name":"pipes"},"spec":{"namespace":"pipelines","serviceAccount":{"name":"pipelines-installer"},"source":{"catalog":{"packageName":"openshift-pipelines-operator-rh","version":"1.14.x"},"sourceType":"Catalog"}}} creationTimestamp: "2025-02-18T21:48:13Z" finalizers: - olm.operatorframework.io/cleanup-unpack-cache - olm.operatorframework.io/cleanup-contentmanager-cache generation: 1 name: pipelines-operator resourceVersion: "72725" uid: e18b13fb-a96d-436f-be75-a9a0f2b07993 spec: namespace: pipelines serviceAccount: name: pipelines-installer source: catalog: packageName: openshift-pipelines-operator-rh upgradeConstraintPolicy: CatalogProvided version: 1.14.x sourceType: Catalog status: conditions: - lastTransitionTime: "2025-02-18T21:48:13Z" message: "" observedGeneration: 1 reason: Deprecated status: "False" type: Deprecated - lastTransitionTime: "2025-02-18T21:48:13Z" message: "" observedGeneration: 1 reason: Deprecated status: "False" type: PackageDeprecated - lastTransitionTime: "2025-02-18T21:48:13Z" message: "" observedGeneration: 1 reason: Deprecated status: "False" type: ChannelDeprecated - lastTransitionTime: "2025-02-18T21:48:13Z" message: "" observedGeneration: 1 reason: Deprecated status: "False" type: BundleDeprecated - lastTransitionTime: "2025-02-18T21:48:16Z" message: Installed bundle registry.redhat.io/openshift-pipelines/pipelines-operator-bundle@sha256:f7b19ce26be742c4aaa458d37bc5ad373b5b29b20aaa7d308349687d3cbd8838 successfully observedGeneration: 1 reason: Succeeded status: "True" type: Installed - lastTransitionTime: "2025-02-18T21:48:16Z" message: desired state reached observedGeneration: 1 reason: Succeeded status: "True" type: Progressing install: bundle: name: openshift-pipelines-operator-rh.v1.14.5 version: 1.14.5 kind: List metadata: resourceVersion: ""使用以下方法之一编辑 CR:
如果要将 Operator 或扩展固定到特定版本,如
1.15.0,请编辑类似以下示例的 CR:pipelines-operator.yamlCR 示例apiVersion: olm.operatorframework.io/v1 kind: ClusterExtension metadata: name: pipelines-operator spec: namespace: pipelines serviceAccount: name: pipelines-installer source: sourceType: Catalog catalog: packageName: openshift-pipelines-operator-rh version: "1.15.0"1 - 1
- 将版本从
1.14.x更新至1.15.0
如果要定义可接受的更新版本范围,请编辑类似以下示例的 CR:
指定了版本范围的 CR 示例
apiVersion: olm.operatorframework.io/v1 kind: ClusterExtension metadata: name: pipelines-operator spec: namespace: pipelines serviceAccount: name: pipelines-installer source: sourceType: Catalog catalog: packageName: openshift-pipelines-operator-rh version: ">1.15, <1.17"1 - 1
- 指定所需的版本范围,大于
1.15版本,但小于1.17。如需更多信息,请参阅"支持版本范围"和"Version 比较字符串"。
如果要更新到可以从频道解析的最新版本,请编辑类似以下示例的 CR:
带有指定频道的 CR 示例
apiVersion: olm.operatorframework.io/v1 kind: ClusterExtension metadata: name: pipelines-operator spec: namespace: pipelines serviceAccount: name: pipelines-installer source: sourceType: Catalog catalog: packageName: openshift-pipelines-operator-rh channels: - latest1 - 1
- 安装可从指定频道解析的最新版本。对频道的更新会自动安装。输入值作为数组。
如果要指定频道和版本范围,请编辑类似以下示例的 CR:
带有指定频道和版本范围的 CR 示例
apiVersion: olm.operatorframework.io/v1 kind: ClusterExtension metadata: name: pipelines-operator spec: namespace: pipelines serviceAccount: name: pipelines-installer source: sourceType: Catalog catalog: packageName: openshift-pipelines-operator-rh channels: - latest version: "<1.16"如需更多信息,请参阅"指定目标版本的示例自定义资源(CR) "。
运行以下命令,将更新应用到集群:
$ oc apply -f pipelines-operator.yaml输出示例
clusterextension.olm.operatorframework.io/pipelines-operator configured
验证
运行以下命令验证频道和版本更新是否已应用:
$ oc get clusterextension pipelines-operator -o yaml例 5.17. 输出示例
apiVersion: olm.operatorframework.io/v1 kind: ClusterExtension metadata: annotations: kubectl.kubernetes.io/last-applied-configuration: | {"apiVersion":"olm.operatorframework.io/v1","kind":"ClusterExtension","metadata":{"annotations":{},"name":"pipes"},"spec":{"namespace":"pipelines","serviceAccount":{"name":"pipelines-installer"},"source":{"catalog":{"packageName":"openshift-pipelines-operator-rh","version":"\u003c1.16"},"sourceType":"Catalog"}}} creationTimestamp: "2025-02-18T21:48:13Z" finalizers: - olm.operatorframework.io/cleanup-unpack-cache - olm.operatorframework.io/cleanup-contentmanager-cache generation: 2 name: pipes resourceVersion: "90693" uid: e18b13fb-a96d-436f-be75-a9a0f2b07993 spec: namespace: pipelines serviceAccount: name: pipelines-installer source: catalog: packageName: openshift-pipelines-operator-rh upgradeConstraintPolicy: CatalogProvided version: <1.16 sourceType: Catalog status: conditions: - lastTransitionTime: "2025-02-18T21:48:13Z" message: "" observedGeneration: 2 reason: Deprecated status: "False" type: Deprecated - lastTransitionTime: "2025-02-18T21:48:13Z" message: "" observedGeneration: 2 reason: Deprecated status: "False" type: PackageDeprecated - lastTransitionTime: "2025-02-18T21:48:13Z" message: "" observedGeneration: 2 reason: Deprecated status: "False" type: ChannelDeprecated - lastTransitionTime: "2025-02-18T21:48:13Z" message: "" observedGeneration: 2 reason: Deprecated status: "False" type: BundleDeprecated - lastTransitionTime: "2025-02-18T21:48:16Z" message: Installed bundle registry.redhat.io/openshift-pipelines/pipelines-operator-bundle@sha256:8a593c1144709c9aeffbeb68d0b4b08368f528e7bb6f595884b2474bcfbcafcd successfully observedGeneration: 2 reason: Succeeded status: "True" type: Installed - lastTransitionTime: "2025-02-18T21:48:16Z" message: desired state reached observedGeneration: 2 reason: Succeeded status: "True" type: Progressing install: bundle: name: openshift-pipelines-operator-rh.v1.15.2 version: 1.15.2
故障排除
如果您指定已弃用或不存在的目标版本或频道,您可以运行以下命令来检查扩展的状态:
$ oc get clusterextension <operator_name> -o yaml例 5.18. 不存在版本的输出示例
apiVersion: olm.operatorframework.io/v1 kind: ClusterExtension metadata: annotations: kubectl.kubernetes.io/last-applied-configuration: | {"apiVersion":"olm.operatorframework.io/v1","kind":"ClusterExtension","metadata":{"annotations":{},"name":"pipes"},"spec":{"namespace":"pipelines","serviceAccount":{"name":"pipelines-installer"},"source":{"catalog":{"packageName":"openshift-pipelines-operator-rh","version":"9.x"},"sourceType":"Catalog"}}} creationTimestamp: "2025-02-18T21:48:13Z" finalizers: - olm.operatorframework.io/cleanup-unpack-cache - olm.operatorframework.io/cleanup-contentmanager-cache generation: 3 name: pipes resourceVersion: "93334" uid: e18b13fb-a96d-436f-be75-a9a0f2b07993 spec: namespace: pipelines serviceAccount: name: pipelines-installer source: catalog: packageName: openshift-pipelines-operator-rh upgradeConstraintPolicy: CatalogProvided version: 9.x sourceType: Catalog status: conditions: - lastTransitionTime: "2025-02-18T21:48:13Z" message: "" observedGeneration: 2 reason: Deprecated status: "False" type: Deprecated - lastTransitionTime: "2025-02-18T21:48:13Z" message: "" observedGeneration: 2 reason: Deprecated status: "False" type: PackageDeprecated - lastTransitionTime: "2025-02-18T21:48:13Z" message: "" observedGeneration: 2 reason: Deprecated status: "False" type: ChannelDeprecated - lastTransitionTime: "2025-02-18T21:48:13Z" message: "" observedGeneration: 2 reason: Deprecated status: "False" type: BundleDeprecated - lastTransitionTime: "2025-02-18T21:48:16Z" message: Installed bundle registry.redhat.io/openshift-pipelines/pipelines-operator-bundle@sha256:8a593c1144709c9aeffbeb68d0b4b08368f528e7bb6f595884b2474bcfbcafcd successfully observedGeneration: 3 reason: Succeeded status: "True" type: Installed - lastTransitionTime: "2025-02-18T21:48:16Z" message: 'error upgrading from currently installed version "1.15.2": no bundles found for package "openshift-pipelines-operator-rh" matching version "9.x"' observedGeneration: 3 reason: Retrying status: "True" type: Progressing install: bundle: name: openshift-pipelines-operator-rh.v1.15.2 version: 1.15.2
5.1.8. 删除 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