OpenShift Upgrade Path の確認 2025

この投稿は、以下の更新版です。

https://qiita.com/qiita2021user/items/496a428453de62cc5242

Red Hat OpenShift Container Platform (OCP) では製品の Life Cycle Policy が明確に定義されており、これに従って定期的に Update Release が提供されます。
__Red Hat OpenShift Container Platform Life Cycle Policy__
https://access.redhat.com/support/policy/updates/openshift

また、OCP の Update には Upgrade Path (または Update Path) が設定されており、Update Path を確認した上で目的の Release (Cluster Version) に Update する必要があります。Update Path は以下から確認することができます。
__OpenShift Container Platform (OCP) 4 upgrade paths__
https://access.redhat.com/solutions/4583231
__Red Hat OpenShift Container Platform Update Graph__
https://access.redhat.com/labs/ocpupgradegraph/update_channel

ここでは、`oc` コマンドと、上記 Link 先に記載されている `curl` コマンドを併用した Update Path の確認方法をご紹介します。

#### 現在の Release (Cluster Version) の確認
以下のコマンドで現在の Release を確認します。
```bash
$ oc get clusterversion
NAME      VERSION   AVAILABLE   PROGRESSING   SINCE   STATUS
version   4.17.15   True        False         96d     Cluster version is 4.17.15
```

#### Update Path の確認
##### OCP Console
現在の Release からの Update Path は、OCP Console で確認することができます。

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2128125/4ad84e3c-28ae-4d08-978d-84a99e0a61b9.png)

`+More` をクリックすると、全ての Update Path が確認できます。

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2128125/b1c33f93-da43-4e57-b2e1-21d93bfcc48f.png)

`Channel` の箇所にあるペンシルアイコンをクリックすることで Update Channel を変更することができます。

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2128125/5017686f-cae2-4c24-8676-30afe23fbd27.png)

ここでは、`4.17.15` を `4.18.11` に Update するため、`stable-4.18` を設定します。Update Path の表示が、先程は Gray Out されていた `stalbe-4.18 channel` のみに変更されます。

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2128125/c8bb4f9f-4b63-45dc-ac09-eb5637535393.png)

##### Red Hat OpenShift Container Platform Update Graph
以下で提供されている Update Path を視覚的に確認できるツールを使用してみます。

__Red Hat OpenShift Container Platform Update Graph__
https://access.redhat.com/labs/ocpupgradegraph/update_channel

`Update Path` でそれぞれの項目で先程の情報を選択して `Generate` ボタンを押すと、両者間の Update が可能であること、`4.18.11` に2つの `Known Issue` があることが分かります。
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2128125/8c8e43cc-8bc4-4b94-9684-c6e283887605.png)

`Update Graph` では、同様の情報を樹形図形式で確認することができます。

![1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2128125/b8f93aa0-b48a-4a10-900d-9497616eaf6e.png)

図上では `4.17.15` と `4.18.11` が線で結ばれておらず、右側のリストで `4.18.11` が赤字で表示され `Known Issue` があることが分かります。このような場合、`oc adm upgrade` 実行時に `--allow-not-recommended` を追加する必要があります。
```shell
$ oc adm upgrade --to=4.18.11 --allow-not-recommended
```

以下のような場合は `--allow-not-recommended` は不要です。
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2128125/aa25a6a0-737b-4dcd-9a90-d39ae600a5f3.png)

なお、複数回の Update が必要な場合は、以下のように表示されます。例として `4.16.10` から `4.18.13` への `Update Path` を表示してみます。

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2128125/32d5848a-8e86-4cff-8ba0-d2ae15d32915.png)

`Update Graph` では、`To` の一覧に `4.18.13` が存在しないことが分かります。

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2128125/7d4a9a13-c4dc-4973-9996-c6035719ba4d.png)

上記は、以下で提供される `graph.sh` と `curl` コマンドの組み合わせでも取得できます。

https://github.com/openshift/cincinnati/blob/master/hack/graph.sh

##### oc コマンド
OCP Console で確認した内容は、`oc` コマンドでも確認可能です。
なお、下記の情報は最新 Release が `4.18.11` の時点で取得したものです。

現在の Release からの Update Path は `clusterversion.status.availableUpdates` に記載されています。なお、`.channels` は、現在の Version ではなく Update 後の Version で選択可能な Update Channel になります。
```bash
$ oc -o json get clusterversion | jq -r '.items[].status.availableUpdates | sort_by(.version)'
[
  {
    "channels": [
      "candidate-4.17",
      "candidate-4.18",
      "eus-4.18",
      "fast-4.17",
      "fast-4.18",
      "stable-4.17",
      "stable-4.18"
    ],
    "image": "quay.io/openshift-release-dev/ocp-release@sha256:7e8b4557c0a15765440c543ab50cd591bb94f0745c20564e5f15d57bf5f76a82",
    "url": "https://access.redhat.com/errata/RHSA-2025:3297",
    "version": "4.17.23"
  },
  {
    "channels": [
      "candidate-4.17",
      "candidate-4.18",
      "eus-4.18",
      "fast-4.17",
      "fast-4.18",
      "stable-4.17",
      "stable-4.18"
    ],
    "image": "quay.io/openshift-release-dev/ocp-release@sha256:65fbb79f801b621121793d347e4405d52edf114d7eea4f4b8c11115db57e5aa4",
    "url": "https://access.redhat.com/errata/RHSA-2025:3565",
    "version": "4.17.24"
  },
  {
    "channels": [
      "candidate-4.17",
      "candidate-4.18",
      "eus-4.18",
      "fast-4.17",
      "fast-4.18",
      "stable-4.17",
      "stable-4.18"
    ],
    "image": "quay.io/openshift-release-dev/ocp-release@sha256:61b5415f1395d5b1266621031ff0d57969f7d086d1da5847e60b6ef549d692f6",
    "url": "https://access.redhat.com/errata/RHSA-2025:3798",
    "version": "4.17.25"
  },
  {
    "channels": [
      "candidate-4.17",
      "candidate-4.18",
      "eus-4.18",
      "fast-4.17",
      "fast-4.18",
      "stable-4.17",
      "stable-4.18"
    ],
    "image": "quay.io/openshift-release-dev/ocp-release@sha256:a659df5d19dcdbc7fd9ede710b213cf5b269c31612d1b5ae3d01a8e5e5619bfc",
    "url": "https://access.redhat.com/errata/RHSA-2025:4012",
    "version": "4.17.26"
  },
  {
    "channels": [
      "candidate-4.17",
      "candidate-4.18",
      "eus-4.18",
      "fast-4.17",
      "fast-4.18",
      "stable-4.17",
      "stable-4.18"
    ],
    "image": "quay.io/openshift-release-dev/ocp-release@sha256:f225d0f0fd7d4509ed00e82f11c871731ee04aecff7d924f820ac6dba7c7b346",
    "url": "https://access.redhat.com/errata/RHSA-2025:4204",
    "version": "4.17.27"
  }
]
```
また、`oc adm upgrade` コマンド(オプション指定なし)でも確認可能です。
```bash
$ oc adm upgrade
Cluster version is 4.17.15

Upstream is unset, so the cluster will use an appropriate default.
Channel: stable-4.18 (available channels: candidate-4.17, candidate-4.18, eus-4.18, fast-4.17, fast-4.18, stable-4.17, stable-4.18)

Recommended updates:

  VERSION     IMAGE
  4.17.27     quay.io/openshift-release-dev/ocp-release@sha256:f225d0f0fd7d4509ed00e82f11c871731ee04aecff7d924f820ac6dba7c7b346
  4.17.26     quay.io/openshift-release-dev/ocp-release@sha256:a659df5d19dcdbc7fd9ede710b213cf5b269c31612d1b5ae3d01a8e5e5619bfc
  4.17.25     quay.io/openshift-release-dev/ocp-release@sha256:61b5415f1395d5b1266621031ff0d57969f7d086d1da5847e60b6ef549d692f6
  4.17.24     quay.io/openshift-release-dev/ocp-release@sha256:65fbb79f801b621121793d347e4405d52edf114d7eea4f4b8c11115db57e5aa4
  4.17.23     quay.io/openshift-release-dev/ocp-release@sha256:7e8b4557c0a15765440c543ab50cd591bb94f0745c20564e5f15d57bf5f76a82

Additional updates which are not recommended for your cluster configuration are available, to view those re-run the command with --include-not-recommended.
```
現在の Update Channel は `clusterversion.spec.channel` に記載されています。
```bash
$ oc get clusterversion -o jsonpath='{.items[].spec.channel}{"\n"}'
stable-4.18
```
選択可能な Update Channel は `clusterversion.status.desired.channels` に記載されています。
```bash
$ oc get clusterversions -o json | jq -r '.items[].status.desired'
{
  "channels": [
    "candidate-4.17",
    "candidate-4.18",
    "eus-4.18",
    "fast-4.17",
    "fast-4.18",
    "stable-4.17",
    "stable-4.18"
  ],
  "image": "quay.io/openshift-release-dev/ocp-release@sha256:68ffa083a5ab473d9fd87cedcb01c6f27740aad92de0ee39a7ac408da9a65857",
  "url": "https://access.redhat.com/errata/RHSA-2025:0876",
  "version": "4.17.15"
}
```
前述の OCP Console の代わりに、`oc patch` コマンドでも Update Channel の変更が可能です。
```bash
$ oc get clusterversion -o jsonpath='{.items[].spec.channel}{"\n"}'
stable-4.17

$ oc patch clusterversion version --type json -p '[{"op": "add", "path": "/spec/channel", "value": "stable-4.18" }]'
clusterversion.config.openshift.io/version patched

$ oc get clusterversion -o jsonpath='{.items[].spec.channel}{"\n"}'
stable-4.18
```

#### curl コマンドによる Update Path の確認
先述の Link 先には、以下のような Update Path の確認方法が記載されています。
```bash
$ export CURRENT_VERSION=4.2.18;
$ export CHANNEL_NAME=fast-4.3;
$
$ curl -sH 'Accept:application/json' "https://api.openshift.com/api/upgrades_info/v1/graph?channel=${CHANNEL_NAME}" | jq -r --arg CURRENT_VERSION "${CURRENT_VERSION}" '. as $graph | $graph.nodes | map(.version=='\"$CURRENT_VERSION\"') | index(true) as $orig | $graph.edges | map(select(.[0] == $orig)[1]) | map($graph.nodes[.].version) | sort_by(.)'
[
  "4.2.19",
  "4.3.1"
]
$
```
簡単な Bash Script を作成して、Update Path を確認してみます。
```bash
$ cat chkpath.sh
#!/bin/bash

[[ $# < 2 ]] && { echo "Usage: $(basename $0) CURRENT_VERSION CHANNEL_NAME"; exit 0; }
CURRENT_VERSION=$1
CHANNEL_NAME=$2

curl -sH 'Accept:application/json' "https://api.openshift.com/api/upgrades_info/v1/graph?channel=${CHANNEL_NAME}" |
jq -r --arg CURRENT_VERSION "${CURRENT_VERSION}" '. as $graph | $graph.nodes | map(.version=='\"$CURRENT_VERSION\"') |
index(true) as $orig | $graph.edges | map(select(.[0] == $orig)[1]) | map($graph.nodes[.].version) | sort_by(.)'

$ chkpath.sh 4.17.15 stable-4.18
[
  "4.17.23",
  "4.17.24",
  "4.17.25",
  "4.17.26",
  "4.17.27"
]
```
先程確認した `clusterversion.status.availableUpdates` の Update Path を確認してみます。
```bash
$ for V in $(oc -o json get clusterversion | jq -r '[.items[].status.availableUpdates[].version] | sort_by(.) | .[]')
do
    echo -e "\n=== VER: $V ==="
    for C in $(oc -o json get clusterversion | jq -r --arg V $V '.items[].status.availableUpdates[] | select(.version == $V) | .channels[]')
    do
        printf %20s "$C : "
        chkpath.sh $V $C | jq -rc .
    done
done

=== VER: 4.17.23 ===
   candidate-4.17 : ["4.17.24","4.17.25","4.17.26","4.17.27","4.17.28","4.17.29"]
   candidate-4.18 : ["4.17.24","4.17.25","4.17.26","4.17.27","4.17.28","4.17.29","4.18.13"]
         eus-4.18 : ["4.17.24","4.17.25","4.17.26","4.17.27"]
        fast-4.17 : ["4.17.24","4.17.25","4.17.26","4.17.27","4.17.28","4.17.29"]
        fast-4.18 : ["4.17.24","4.17.25","4.17.26","4.17.27","4.17.28","4.17.29","4.18.13"]
      stable-4.17 : ["4.17.24","4.17.25","4.17.26","4.17.27","4.17.28"]
      stable-4.18 : ["4.17.24","4.17.25","4.17.26","4.17.27"]

=== VER: 4.17.24 ===
   candidate-4.17 : ["4.17.25","4.17.26","4.17.27","4.17.28","4.17.29"]
   candidate-4.18 : ["4.17.25","4.17.26","4.17.27","4.17.28","4.17.29","4.18.13"]
         eus-4.18 : ["4.17.25","4.17.26","4.17.27"]
        fast-4.17 : ["4.17.25","4.17.26","4.17.27","4.17.28","4.17.29"]
        fast-4.18 : ["4.17.25","4.17.26","4.17.27","4.17.28","4.17.29","4.18.13"]
      stable-4.17 : ["4.17.25","4.17.26","4.17.27","4.17.28"]
      stable-4.18 : ["4.17.25","4.17.26","4.17.27"]

=== VER: 4.17.25 ===
   candidate-4.17 : ["4.17.26","4.17.27","4.17.28","4.17.29"]
   candidate-4.18 : ["4.17.26","4.17.27","4.17.28","4.17.29","4.18.13"]
         eus-4.18 : ["4.17.26","4.17.27"]
        fast-4.17 : ["4.17.26","4.17.27","4.17.28","4.17.29"]
        fast-4.18 : ["4.17.26","4.17.27","4.17.28","4.17.29","4.18.13"]
      stable-4.17 : ["4.17.26","4.17.27","4.17.28"]
      stable-4.18 : ["4.17.26","4.17.27"]

=== VER: 4.17.26 ===
   candidate-4.17 : ["4.17.27","4.17.28","4.17.29"]
   candidate-4.18 : ["4.17.27","4.17.28","4.17.29","4.18.13"]
         eus-4.18 : ["4.17.27"]
        fast-4.17 : ["4.17.27","4.17.28","4.17.29"]
        fast-4.18 : ["4.17.27","4.17.28","4.17.29","4.18.13"]
      stable-4.17 : ["4.17.27","4.17.28"]
      stable-4.18 : ["4.17.27"]

=== VER: 4.17.27 ===
   candidate-4.17 : ["4.17.28","4.17.29"]
   candidate-4.18 : ["4.17.28","4.17.29","4.18.13"]
         eus-4.18 : []
        fast-4.17 : ["4.17.28","4.17.29"]
        fast-4.18 : ["4.17.28","4.17.29","4.18.13"]
      stable-4.17 : ["4.17.28"]
      stable-4.18 : []
```
これによって、Update 後の Release における Update Path を確認することが可能です。