2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

OpenShift Upgrade Path の確認

Last updated at Posted at 2022-05-12

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#ocp4_phases

また、OCP の Update には Upgrade Path が設定されており、Upgrade Path を確認した上で目的の Release (Cluster Version) に Update する必要があります。Upgrade 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 コマンドを併用した Upgrade Path の確認方法をご紹介します。

現在の Release (Cluster Version) の確認

以下のコマンドで現在の Release を確認します。

$ oc get clusterversion
NAME      VERSION   AVAILABLE   PROGRESSING   SINCE   STATUS
version   4.7.48    True        False         16d     Cluster version is 4.7.48

Upgrade Path の確認

OCP Console

現在の Release からの Upgrade Path は、OCP Console で確認することができます。
pic1.png

+More をクリックすると、全ての Upgrade Path が確認できます。
pic2.png

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

oc コマンド

OCP Console で確認した内容は、oc コマンドでも確認可能です。
現在の Release からの Upgrade Path は clusterversion.status.availableUpdates に記載されています。なお、.channels は、現在の Version ではなく Update 後の Version で選択可能な Update Channel になります。

$ oc -o json get clusterversion | jq -r '.items[].status.availableUpdates | sort_by(.version)'
[
  {
    "channels": [
      "candidate-4.7",
      "candidate-4.8",
      "eus-4.8",
      "fast-4.7",
      "fast-4.8",
      "stable-4.7",
      "stable-4.8"
    ],
    "image": "quay.io/openshift-release-dev/ocp-release@sha256:f0787fbe916a18888a90d3517db72d7adbaf8985698dfd6c6f904302130967ed",
    "url": "https://access.redhat.com/errata/RHBA-2022:1337",
    "version": "4.7.49"
  },
  {
    "channels": [
      "candidate-4.8",
      "candidate-4.9",
      "eus-4.8",
      "fast-4.8",
      "fast-4.9",
      "stable-4.8",
      "stable-4.9"
    ],
    "image": "quay.io/openshift-release-dev/ocp-release@sha256:462178399720c61fc4f9a99e572e3c10428c35f704ed36a44e75def2fc6261c7",
    "url": "https://access.redhat.com/errata/RHBA-2022:1369",
    "version": "4.8.37"
  },
  {
    "channels": [
      "candidate-4.8",
      "candidate-4.9",
      "eus-4.8",
      "fast-4.8",
      "fast-4.9",
      "stable-4.8",
      "stable-4.9"
    ],
    "image": "quay.io/openshift-release-dev/ocp-release@sha256:7b6225ae221d92645083a04ceae214974e121108c1edbc8b4985ba84f945f5d8",
    "url": "https://access.redhat.com/errata/RHBA-2022:1427",
    "version": "4.8.39"
  }
]

また、oc adm upgrade コマンド(オプション指定なし)でも確認可能です。

$ oc adm upgrade
Cluster version is 4.7.48

Updates:

VERSION IMAGE
4.7.49  quay.io/openshift-release-dev/ocp-release@sha256:f0787fbe916a18888a90d3517db72d7adbaf8985698dfd6c6f904302130967ed
4.8.37  quay.io/openshift-release-dev/ocp-release@sha256:462178399720c61fc4f9a99e572e3c10428c35f704ed36a44e75def2fc6261c7
4.8.39  quay.io/openshift-release-dev/ocp-release@sha256:7b6225ae221d92645083a04ceae214974e121108c1edbc8b4985ba84f945f5d8

現在の Update Channel は clusterversion.spec.channel に記載されています。

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

選択可能な Update Channel は clusterversion.status.desired.channels に記載されています。

$ oc get clusterversions -o json | jq -r '.items[].status.desired'
{
  "channels": [
    "candidate-4.7",
    "candidate-4.8",
    "eus-4.8",
    "fast-4.7",
    "fast-4.8",
    "stable-4.7",
    "stable-4.8"
  ],
  "image": "quay.io/openshift-release-dev/ocp-release@sha256:b1fab3144a5bd2e6c4ac2dc2df4eca9deaf942ef9c28519991ab81e593174978",
  "url": "https://access.redhat.com/errata/RHBA-2022:1249",
  "version": "4.7.48"
}

oc patch コマンドで、Update Channel の変更が可能です。

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

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

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

curl コマンドによる Upgrade Path の確認

先述の Link 先には、以下のような Upgrade Path の確認方法が記載されています。

$ 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 を作成して、Upgrade Path を確認してみます。

$ 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.7.48 stable-4.8
[
  "4.7.49",
  "4.8.37",
  "4.8.39"
]

先程確認した clusterversion.status.availableUpdates の Upgrade Path を確認してみます。

$ 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.7.49 ===
    candidate-4.7 : ["4.7.50"]
    candidate-4.8 : ["4.7.50","4.8.37","4.8.38","4.8.39"]
          eus-4.8 : ["4.8.37","4.8.39"]
         fast-4.7 : []
         fast-4.8 : ["4.8.37","4.8.39"]
       stable-4.7 : []
       stable-4.8 : ["4.8.37","4.8.39"]

=== VER: 4.8.37 ===
    candidate-4.8 : ["4.8.38","4.8.39"]
    candidate-4.9 : ["4.8.38","4.8.39","4.9.29","4.9.30","4.9.31","4.9.32"]
          eus-4.8 : ["4.8.39"]
         fast-4.8 : ["4.8.39"]
         fast-4.9 : ["4.8.39","4.9.29","4.9.31"]
       stable-4.8 : ["4.8.39"]
       stable-4.9 : ["4.8.39","4.9.29","4.9.31"]

=== VER: 4.8.39 ===
    candidate-4.8 : []
    candidate-4.9 : ["4.9.31","4.9.32"]
          eus-4.8 : []
         fast-4.8 : []
         fast-4.9 : ["4.9.31"]
       stable-4.8 : []
       stable-4.9 : ["4.9.31"]

これによって、Update 後の Release における Upgrade Path を確認することが可能です。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?