5.7.2. 在 Operator Lifecycle Manager 中测试 Operator 升级
您可以使用 Operator Lifecycle Manager(OLM)集成 Operator SDK 来快速测试 Operator 升级,而无需手动管理索引镜像和目录源。
run bundle-upgrade
子命令通过为以后的版本指定捆绑包镜像来自动触发已安装的 Operator 以升级到更新的版本。
先决条件
-
使用
run bundle
子命令安装 OLM 的 operator - 代表已安装 Operator 的更新版本的捆绑包镜像
流程
如果使用
run bundle
子命令的 OLM 尚未安装 Operator,请通过指定捆绑包镜像来安装 Operator 的早期版本。例如,对于 Memcached Operator:$ operator-sdk run bundle <registry>/<user>/memcached-operator:v0.0.1
输出示例
INFO[0009] Successfully created registry pod: quay-io-demo-memcached-operator-v0-0-1 INFO[0009] Created CatalogSource: memcached-operator-catalog INFO[0010] OperatorGroup "operator-sdk-og" created INFO[0010] Created Subscription: memcached-operator-v0-0-1-sub INFO[0013] Approved InstallPlan install-bqggr for the Subscription: memcached-operator-v0-0-1-sub INFO[0013] Waiting for ClusterServiceVersion "my-project/memcached-operator.v0.0.1" to reach 'Succeeded' phase INFO[0013] Waiting for ClusterServiceVersion "my-project/memcached-operator.v0.0.1" to appear INFO[0019] Found ClusterServiceVersion "my-project/memcached-operator.v0.0.1" phase: Succeeded
通过为后续的 Operator 版本指定捆绑包镜像来升级已安装的 Operator:
$ operator-sdk run bundle-upgrade <registry>/<user>/memcached-operator:v0.0.2
输出示例
INFO[0002] Found existing subscription with name memcached-operator-v0-0-1-sub and namespace my-project INFO[0002] Found existing catalog source with name memcached-operator-catalog and namespace my-project INFO[0009] Successfully created registry pod: quay-io-demo-memcached-operator-v0-0-2 INFO[0009] Updated catalog source memcached-operator-catalog with address and annotations INFO[0010] Deleted previous registry pod with name "quay-io-demo-memcached-operator-v0-0-1" INFO[0041] Approved InstallPlan install-gvcjh for the Subscription: memcached-operator-v0-0-1-sub INFO[0042] Waiting for ClusterServiceVersion "my-project/memcached-operator.v0.0.2" to reach 'Succeeded' phase INFO[0042] Found ClusterServiceVersion "my-project/memcached-operator.v0.0.2" phase: InstallReady INFO[0043] Found ClusterServiceVersion "my-project/memcached-operator.v0.0.2" phase: Installing INFO[0044] Found ClusterServiceVersion "my-project/memcached-operator.v0.0.2" phase: Succeeded INFO[0044] Successfully upgraded to "memcached-operator.v0.0.2"
清理已安装的 Operator:
$ operator-sdk cleanup memcached-operator