Closed12

Upgrade Ubuntu 18.04 to 20.04

t_umet_ume
  • 自宅k8sのOSをアップグレードしようと思ったら、OSのバージョンが違った・・・
  • 以前ネットワークをいじった際に壊れて、ControlPlaneだけバージョンを上げたVMを別で起動して好感した記憶がおぼろげに・・・
  • 折角なのでWorkerのOSのアップグレードを行う
t_umet_ume

現状

  • 環境はローカルPCにVagrant/Virtualboxで構築したVM
  • 一台だけお試しに上げてみて正常に動いていることを確認
  • OSやKernel、containerdのマイナーバージョンが揃って無いのはご愛嬌ってことで・・・
$ kc get no -owide
NAME   STATUS   ROLES           AGE      VERSION   INTERNAL-IP     EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION       CONTAINER-RUNTIME
cp11   Ready    control-plane   340d     v1.24.5   192.168.10.81   <none>        Ubuntu 20.04.5 LTS   5.4.0-162-generic    containerd://1.6.15
cp12   Ready    control-plane   339d     v1.24.5   192.168.10.82   <none>        Ubuntu 20.04.5 LTS   5.4.0-139-generic    containerd://1.6.15
cp13   Ready    control-plane   339d     v1.24.5   192.168.10.83   <none>        Ubuntu 20.04.5 LTS   5.4.0-163-generic    containerd://1.6.15
nd01   Ready    <none>          2y228d   v1.24.5   192.168.10.71   <none>        Ubuntu 20.04.6 LTS   5.4.0-169-generic    containerd://1.6.21
nd02   Ready    <none>          2y228d   v1.24.5   192.168.10.72   <none>        Ubuntu 18.04.5 LTS   4.15.0-213-generic   containerd://1.4.4
nd03   Ready    <none>          341d     v1.24.5   192.168.10.73   <none>        Ubuntu 18.04.5 LTS   4.15.0-213-generic   containerd://1.4.4
t_umet_ume
  • nd02(Worker)のOSをアップグレードする
  • 以下を参考にさせて頂いた。

https://tech.uzabase.com/entry/2022/10/05/163458

  • とりあえず現状は以下の通り
$ cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.5 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.5 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

$ uname -a
Linux nd02 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
t_umet_ume
  • アップグレード対象を確認
  • 想定通り、20.04が対象
    • 最新のLTSは22だが一足飛びにアップグレードは出来ない
$ sudo do-release-upgrade -c
Checking for a new Ubuntu release
New release '20.04.6 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
t_umet_ume
  • パッケージを最新化する
$ sudo apt update
Get:1 https://download.docker.com/linux/ubuntu bionic InRelease [64.4 kB]
Hit:3 http://archive.ubuntu.com/ubuntu bionic InRelease
Hit:4 http://security.ubuntu.com/ubuntu bionic-security InRelease
Hit:2 https://packages.cloud.google.com/apt kubernetes-xenial InRelease
Hit:5 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:6 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
Fetched 64.4 kB in 1s (63.2 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
71 packages can be upgraded. Run 'apt list --upgradable' to see them.
  • 念のためパッケージを確認してみる
$ apt list --upgradable
...
kubeadm/kubernetes-xenial 1.28.2-00 amd64 [upgradable from: 1.24.5-00]
kubectl/kubernetes-xenial 1.28.2-00 amd64 [upgradable from: 1.24.5-00]
kubelet/kubernetes-xenial 1.28.2-00 amd64 [upgradable from: 1.24.5-00]
...
  • k8sのパッケージをアップグレードされそうだった・・・
  • k8sのアップグレードは別途行いたいので、aptのレポファイルを編集する
$ cat /etc/apt/sources.list.d/apt_kubernetes_io.list
deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main

# 編集して、コメントアウトしておく

$ cat /etc/apt/sources.list.d/apt_kubernetes_io.list
#deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main
  • aptで再確認
$ sudo apt update
Get:1 https://download.docker.com/linux/ubuntu bionic InRelease [64.4 kB]
Hit:2 http://security.ubuntu.com/ubuntu bionic-security InRelease
Hit:3 http://archive.ubuntu.com/ubuntu bionic InRelease
Hit:4 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:5 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
Fetched 64.4 kB in 1s (63.3 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
66 packages can be upgraded. Run 'apt list --upgradable' to see them.

# kube~は無くなっていた
$ sudo apt list --upgradable
...
klibc-utils/bionic-updates 2.0.4-9ubuntu2.2 amd64 [upgradable from: 2.0.4-9ubuntu2.1]
landscape-common/bionic-updates 18.01-0ubuntu3.6 amd64 [upgradable from: 18.01-0ubuntu3.5]
...
t_umet_ume
  • パッケージをアップグレードする
$ sudo apt upgrade
...
66 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 56.4 MB of archives.
After this operation, 12.8 MB disk space will be freed.
Do you want to continue? [Y/n] Y
  • containerdで設定ファイルの差分が出るようだったが、既存を維持のためNを選択
Configuration file '/etc/containerd/config.toml'
 ==> Modified (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** config.toml (Y/I/N/O/D/Z) [default=N] ? N ★Nを入力して、Enter
  • 以降は何も聞かれずに正常にアップグレードできた
  • k8sクラスタも正常稼働、containerdはこの時点でアップグレード
kc get no -owide
NAME   STATUS   ROLES           AGE      VERSION   INTERNAL-IP     EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION       CONTAINER-RUNTIME
cp11   Ready    control-plane   340d     v1.24.5   192.168.10.81   <none>        Ubuntu 20.04.5 LTS   5.4.0-162-generic    containerd://1.6.15
cp12   Ready    control-plane   339d     v1.24.5   192.168.10.82   <none>        Ubuntu 20.04.5 LTS   5.4.0-139-generic    containerd://1.6.15
cp13   Ready    control-plane   339d     v1.24.5   192.168.10.83   <none>        Ubuntu 20.04.5 LTS   5.4.0-163-generic    containerd://1.6.15
nd01   Ready    <none>          2y228d   v1.24.5   192.168.10.71   <none>        Ubuntu 20.04.6 LTS   5.4.0-169-generic    containerd://1.6.21
nd02   Ready    <none>          2y228d   v1.24.5   192.168.10.72   <none>        Ubuntu 18.04.6 LTS   4.15.0-213-generic   containerd://1.6.21
nd03   Ready    <none>          341d     v1.24.5   192.168.10.73   <none>        Ubuntu 18.04.5 LTS   4.15.0-213-generic   containerd://1.4.4
t_umet_ume
  • アップグレード前の準備
  • 不要なパッケージ、キャッシュの削除を試してみたが特に削除するものは無かった?
$ sudo apt autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

$ sudo apt autoclean
Reading package lists... Done
Building dependency tree
Reading state information... Done
t_umet_ume
  • 準備できたのでアップグレード
  • 今回はVirtualboxで起動しているので、コンソールから実施

  • パッケージアップデートしたらrebootしろと・・・
  • rebootしてから再実行
$ sudo do-release-upgrade
...
  • 以下はそのままEnter

  • パッケージのアップデート情報
  • 気になる場合はdで確認
  • 半強制なのでyを入力

  • 以下はサービス再起動の確認についてなのでNoを選択

  • もう一つ入力する画面があったが、スクリーンショット取る際に次にいってしまった・・・
  • 以下は推奨が4.0だったので、推奨の4.0を選択

  • GRUBの設定ファイルの書き込みエラー・・・
  • nd01ではでなかったのに・・・
  • /dev/sddは外付けなので、いったんyesで続行

  • パッケージの削除情報
  • こちらも半強制なのでyで続行

  • 無事?にアップグレード完了
  • yで再起動
  • ここまでで作業時間20分程

t_umet_ume
  • 再起動後の確認
$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.6 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.6 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

$ uname -a
Linux nd02 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
  • k8s上でも更新されていることを確認
  • コンテナも正常に稼働していた
$ kc get no -owide
NAME   STATUS   ROLES           AGE      VERSION   INTERNAL-IP     EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION       CONTAINER-RUNTIME
cp11   Ready    control-plane   340d     v1.24.5   192.168.10.81   <none>        Ubuntu 20.04.5 LTS   5.4.0-162-generic    containerd://1.6.15
cp12   Ready    control-plane   340d     v1.24.5   192.168.10.82   <none>        Ubuntu 20.04.5 LTS   5.4.0-139-generic    containerd://1.6.15
cp13   Ready    control-plane   340d     v1.24.5   192.168.10.83   <none>        Ubuntu 20.04.5 LTS   5.4.0-163-generic    containerd://1.6.15
nd01   Ready    <none>          2y228d   v1.24.5   192.168.10.71   <none>        Ubuntu 20.04.6 LTS   5.4.0-169-generic    containerd://1.6.21
nd02   Ready    <none>          2y228d   v1.24.5   192.168.10.72   <none>        Ubuntu 20.04.6 LTS   5.4.0-169-generic    containerd://1.6.21
nd03   Ready    <none>          341d     v1.24.5   192.168.10.73   <none>        Ubuntu 18.04.5 LTS   4.15.0-213-generic   containerd://1.4.4
t_umet_ume
  • 最後にディスクサイズの増減確認
  • 1.5~2G程増えていた
# アップグレード前
$ df -hT /
Filesystem     Type  Size  Used Avail Use% Mounted on
/dev/sda1      ext4   49G   30G   19G  62% /

# アップグレード後
$ df -hT /
Filesystem     Type  Size  Used Avail Use% Mounted on
/dev/sda1      ext4   49G   32G   18G  65% /
t_umet_ume

【追記】

  • 撮れていなかったスクリーンショットがnd03で撮れたので
  • NSSに関連したサービスの再起動するリストを求められていたみたいです

t_umet_ume

【追記】

  • nd03で別の画面が出た
  • GRUBのインストールみたいだったので、最初のパーティんしょんを指定して事なきを得た
このスクラップは4ヶ月前にクローズされました