Red Hat OpenShift Container Platform (OCP) の Update には Upgrade Path が設定されており、Upgrade Path を確認した上で目的の Release (Cluster Version) に Update する必要があります。
また、Upgrade Path には Update Channel
があり、その選択次第で Upgrade Path が変わってきます。
OpenShift Upgrade Path の確認
https://qiita.com/qiita2021user/items/496a428453de62cc5242
新しい oc
コマンドでは、oc adm upgrade channel
コマンドで Update Channel の変更が可能になりました。これによって、従来の oc patch
コマンドよりも容易に変更することができます。
oc コマンド Version 4.9.31 の例
Version 4.9.31 の oc adm upgrade
には channel
サブコマンドがあります。
このサブコマンドは、以下によって追加されたようです。
pkg/cli/admin/upgrade/channel: Add 'oc adm upgrade channel ...
https://github.com/openshift/oc/pull/576
また、確認できた範囲では、以下のパッケージに実装されているようです。
- openshift-clients-4.11.0-202204020828
- openshift-clients-4.10.0-202203170916
- openshift-clients-4.9.0-202203221324
$ oc version --client
Client Version: 4.9.31
$ oc adm upgrade channel --help
Set or clear the update channel.
This command will set or clear the update channel, which impacts the list of updates recommended for the cluster.
If desired channel is empty, the command will clear the update channel. If there is a list of acceptable channels and
the current update channel is in that list, you must pass --allow-explicit-channel to allow channel clear to proceed.
If desired channel is not empty, the command will set the update channel to it. If there is a list of acceptable
channels and the desired channel is not in that list, you must pass --allow-explicit-channel to allow channel change to
proceed.
Usage:
oc adm upgrade channel CHANNEL [flags]
Options:
--allow-explicit-channel=false: Change the channel, even if there is a list of acceptable channels and the desired
channel is not in that list.
Use "oc adm options" for a list of global command-line options (applies to all commands).
現在の Update Channel と選択可能な Channel (available channels) は、oc adm upgrade
で確認することができます。
$ oc adm upgrade
Cluster version is 4.9.31
Upstream: https://api.openshift.com/api/upgrades_info/v1/graph
Channel: eus-4.10 (available channels: candidate-4.10, candidate-4.9, eus-4.10, fast-4.10, fast-4.9, stable-4.10, stable-4.9)
Updates:
VERSION IMAGE
4.9.32 quay.io/openshift-release-dev/ocp-release@sha256:ecdb6d0df547b857eaf0edb5574ddd64ca6d9aff1fa61fd1ac6fb641203bedfa
4.10.12 quay.io/openshift-release-dev/ocp-release@sha256:f77f4f75c1e1a4ddd0a0355f298a834db3473fd9ca473235013e9419d1df16db
4.10.13 quay.io/openshift-release-dev/ocp-release@sha256:4f516616baed3cf84585e753359f7ef2153ae139c2e80e0191902fbd073c4143
現在の Update Channel が eus-4.10
、選択可能な Channel が candidate-4.10, candidate-4.9, eus-4.10, fast-4.10, fast-4.9, stable-4.10, stable-4.9
であることが分かります。
Update Channel を stable-4.10
に変更してみます。
$ oc adm upgrade channel stable-4.10
$ oc adm upgrade
Cluster version is 4.9.31
Upstream: https://api.openshift.com/api/upgrades_info/v1/graph
Channel: stable-4.10 (available channels: candidate-4.10, candidate-4.9, eus-4.10, fast-4.10, fast-4.9, stable-4.10, stable-4.9)
Updates:
VERSION IMAGE
4.9.32 quay.io/openshift-release-dev/ocp-release@sha256:ecdb6d0df547b857eaf0edb5574ddd64ca6d9aff1fa61fd1ac6fb641203bedfa
4.10.12 quay.io/openshift-release-dev/ocp-release@sha256:f77f4f75c1e1a4ddd0a0355f298a834db3473fd9ca473235013e9419d1df16db
4.10.13 quay.io/openshift-release-dev/ocp-release@sha256:4f516616baed3cf84585e753359f7ef2153ae139c2e80e0191902fbd073c4143
これは、以下の oc patch
コマンドと同等の変更になります。
$ oc patch clusterversion version --type json -p '[{"op": "add", "path": "/spec/channel", "value": "stable-4.10" }]'
clusterversion.config.openshift.io/version patched
また、従来同様、以下のコマンドでも変更されたことが確認できます。
$ oc get clusterversion -o jsonpath='{.items[].spec.channel}{"\n"}'
stable-4.10
available channels にない Channel を指定する場合は --allow-explicit-channel
を使用します。
試しに、存在しない dummy-channel
を指定してみます。
$ oc adm upgrade channel --allow-explicit-channel dummy-channel
warning: The requested channel "dummy-channel" is not one of the available channels (candidate-4.10, candidate-4.9, eus-4.10, fast-4.10, fast-4.9, stable-4.10, stable-4.9). You have used --allow-explicit-channel to proceed anyway. Setting the update channel to "dummy-channel".
$oc adm upgrade
Cluster version is 4.9.31
Upstream: https://api.openshift.com/api/upgrades_info/v1/graph
Channel: dummy-channel
warning: Cannot display available updates:
Reason: VersionNotFound
Message: Unable to retrieve available updates: currently reconciling cluster version 4.9.31 not found in the "dummy-channel" channel
設定した Update Channel に従って、適切なメッセージが出力されることがわかります。