概要
minikube環境をアップグレードしてKubernetesのv1.30.0を使えるようにしたので、
kubectlのバージョンもアップグレードしてみました。
minikubeアップグレード手順に関しては以下記事を参考にしてください。
ちなみに、Kubernetes環境がminikubeなので"minikube kubectl"でも実行できますが、
今回はWSLに設定しているkubectlのバージョンをアップグレードしてます。
環境
- minikube version: 1.33.1
- Ubuntu 22.04.4 LTS(WSL)
やってみる
- アップグレード前のkubectl コマンドのバージョンを確認
tech-0222@MSI:tmp$ kubectl version --client=true
Client Version: v1.28.2
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
tech-0222@MSI:tmp$
- アップグレードできるパッケージを確認するが、kubectl がありませんね。。
tech-0222@MSI:tmp$ apt list --upgradable
Listing... Done
containerd.io/jammy 1.7.19-1 amd64 [upgradable from: 1.6.31-1]
docker-buildx-plugin/jammy 0.16.1-1~ubuntu.22.04~jammy amd64 [upgradable from: 0.14.0-1~ubuntu.22.04~jammy]
docker-ce-cli/jammy 5:27.1.1-1~ubuntu.22.04~jammy amd64 [upgradable from: 5:26.1.3-1~ubuntu.22.04~jammy]
docker-ce-rootless-extras/jammy 5:27.1.1-1~ubuntu.22.04~jammy amd64 [upgradable from: 5:26.1.3-1~ubuntu.22.04~jammy]
docker-ce/jammy 5:27.1.1-1~ubuntu.22.04~jammy amd64 [upgradable from: 5:26.1.3-1~ubuntu.22.04~jammy]
docker-compose-plugin/jammy 2.29.1-1~ubuntu.22.04~jammy amd64 [upgradable from: 2.27.0-1~ubuntu.22.04~jammy]
libldap-2.5-0/jammy-updates 2.5.18+dfsg-0ubuntu0.22.04.2 amd64 [upgradable from: 2.5.17+dfsg-0ubuntu0.22.04.1]
libldap-common/jammy-updates 2.5.18+dfsg-0ubuntu0.22.04.2 all [upgradable from: 2.5.17+dfsg-0ubuntu0.22.04.1]
python3-update-manager/jammy-updates 1:22.04.20 all [upgradable from: 1:22.04.10]
snapd/jammy-updates 2.63+22.04 amd64 [upgradable from: 2.62+22.04]
tzdata/jammy-updates 2024a-0ubuntu0.22.04.1 all [upgradable from: 2024a-0ubuntu0.22.04]
ubuntu-advantage-tools/jammy-updates 32.3.1~22.04 all [upgradable from: 31.2.3~22.04]
ubuntu-minimal/jammy-updates 1.481.2 amd64 [upgradable from: 1.481.1]
ubuntu-pro-client-l10n/jammy-updates 32.3.1~22.04 amd64 [upgradable from: 31.2.3~22.04]
ubuntu-pro-client/jammy-updates 32.3.1~22.04 amd64 [upgradable from: 31.2.3~22.04]
ubuntu-standard/jammy-updates 1.481.2 amd64 [upgradable from: 1.481.1]
ubuntu-wsl/jammy-updates 1.481.2 amd64 [upgradable from: 1.481.1]
update-manager-core/jammy-updates 1:22.04.20 all [upgradable from: 1:22.04.10]
vim-common/jammy-updates 2:8.2.3995-1ubuntu2.17 all [upgradable from: 2:8.2.3995-1ubuntu2.16]
vim-runtime/jammy-updates 2:8.2.3995-1ubuntu2.17 all [upgradable from: 2:8.2.3995-1ubuntu2.16]
vim-tiny/jammy-updates 2:8.2.3995-1ubuntu2.17 amd64 [upgradable from: 2:8.2.3995-1ubuntu2.16]
vim/jammy-updates 2:8.2.3995-1ubuntu2.17 amd64 [upgradable from: 2:8.2.3995-1ubuntu2.16]
xxd/jammy-updates 2:8.2.3995-1ubuntu2.17 amd64 [upgradable from: 2:8.2.3995-1ubuntu2.16]
tech-0222@MSI:tmp$
#パッケージはある
tech-0222@MSI:tmp$ dpkg -l kubectl
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-============-============-=================================
ii kubectl 1.28.2-00 amd64 Kubernetes Command Line Tool
tech-0222@MSI:tmp$
-
インストール手順を調べてみると手順が変わってる。。
- Linux上でのkubectlのインストールおよびセットアップ
- ドキュメントみると以下記載があるので、別ドキュメントを確認してみます。
kubectlを他のマイナーリリースにアップグレードするためには、
apt-get update
とapt-get upgrade
を実行する前に、/etc/apt/sources.list.d/kubernetes.list
の中のバージョンを上げる必要があります。 この手順についてはChanging The Kubernetes Package Repositoryに詳細が記載されています -
Changing The Kubernetes Package Repository
- https://kubernetes.io/docs/tasks/administer-cluster/kubeadm/change-package-repository/
- ドキュメントの手順通りに現行設定を確認してみる
- ドメインが「apt.kubernetes.io」なので修正が必要みたい・・
tech-0222@MSI:tmp$ cat /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
tech-0222@MSI:tmp$
- 手順通りに、修正をしてみる
- バージョンv1.30が使いたいので、例を一部修正して編集します。
tech-0222@MSI:tmp$ sudo vi /etc/apt/sources.list.d/kubernetes.list
[sudo] password for tech-0222:
tech-0222@MSI:tmp$
tech-0222@MSI:tmp$ cat /etc/apt/sources.list.d/kubernetes.list
deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.30/deb/ /
tech-0222@MSI:tmp$
- 設定を一部変更したので利用可能なソフトウェアリポジトリのパッケージリストを更新
tech-0222@MSI:tmp$ sudo apt-get update
Hit:1 https://download.docker.com/linux/ubuntu jammy InRelease
Hit:3 http://archive.ubuntu.com/ubuntu jammy InRelease
Get:4 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [128 kB]
Get:2 https://prod-cdn.packages.k8s.io/repositories/isv:/kubernetes:/core:/stable:/v1.30/deb InRelease [1186 B]
Err:2 https://prod-cdn.packages.k8s.io/repositories/isv:/kubernetes:/core:/stable:/v1.30/deb InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 234654DA9A296436
Get:5 http://security.ubuntu.com/ubuntu jammy-security InRelease [129 kB]
Hit:6 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Reading package lists... Done
W: GPG error: https://prod-cdn.packages.k8s.io/repositories/isv:/kubernetes:/core:/stable:/v1.30/deb InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 234654DA9A296436
E: The repository 'https://pkgs.k8s.io/core:/stable:/v1.30/deb InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
tech-0222@MSI:tmp$
- エラーが出てますね
- メッセージを読むとGPG を変えないとダメみたいです
- インストール手順の以下を参考に修正してみます
- ネイティブなパッケージマネージャーを使用してインストールする
- Kubernetesパッケージリポジトリの公開署名キーをダウンロード
tech-0222@MSI:tmp$
tech-0222@MSI:tmp$ curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
tech-0222@MSI:tmp$ sudo chmod 644 /etc/apt/keyrings/kubernetes-apt-keyring.gpg
tech-0222@MSI:tmp$
- 利用可能なソフトウェアリポジトリのパッケージリスト更新をリトライ
- パッケージが更新できたので大丈夫そう
tech-0222@MSI:tmp$ sudo apt-get update
Hit:1 https://download.docker.com/linux/ubuntu jammy InRelease
Get:2 https://prod-cdn.packages.k8s.io/repositories/isv:/kubernetes:/core:/stable:/v1.30/deb InRelease [1186 B]
Get:3 https://prod-cdn.packages.k8s.io/repositories/isv:/kubernetes:/core:/stable:/v1.30/deb Packages [6445 B]
Hit:4 http://archive.ubuntu.com/ubuntu jammy InRelease
Hit:5 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:6 http://security.ubuntu.com/ubuntu jammy-security InRelease
Hit:7 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Fetched 7631 B in 1s (8429 B/s)
Reading package lists... Done
tech-0222@MSI:tmp$
- アップグレードできるパッケージを確認
- 「kubectl/unknown 1.30.3-1.1 amd64 [upgradable from: 1.28.2-00]」があるので大丈夫そう!
Listing... Done
containerd.io/jammy 1.7.19-1 amd64 [upgradable from: 1.6.31-1]
docker-buildx-plugin/jammy 0.16.1-1~ubuntu.22.04~jammy amd64 [upgradable from: 0.14.0-1~ubuntu.22.04~jammy]
docker-ce-cli/jammy 5:27.1.1-1~ubuntu.22.04~jammy amd64 [upgradable from: 5:26.1.3-1~ubuntu.22.04~jammy]
docker-ce-rootless-extras/jammy 5:27.1.1-1~ubuntu.22.04~jammy amd64 [upgradable from: 5:26.1.3-1~ubuntu.22.04~jammy]
docker-ce/jammy 5:27.1.1-1~ubuntu.22.04~jammy amd64 [upgradable from: 5:26.1.3-1~ubuntu.22.04~jammy]
docker-compose-plugin/jammy 2.29.1-1~ubuntu.22.04~jammy amd64 [upgradable from: 2.27.0-1~ubuntu.22.04~jammy]
kubectl/unknown 1.30.3-1.1 amd64 [upgradable from: 1.28.2-00]
libldap-2.5-0/jammy-updates 2.5.18+dfsg-0ubuntu0.22.04.2 amd64 [upgradable from: 2.5.17+dfsg-0ubuntu0.22.04.1]
libldap-common/jammy-updates 2.5.18+dfsg-0ubuntu0.22.04.2 all [upgradable from: 2.5.17+dfsg-0ubuntu0.22.04.1]
python3-update-manager/jammy-updates 1:22.04.20 all [upgradable from: 1:22.04.10]
snapd/jammy-updates 2.63+22.04 amd64 [upgradable from: 2.62+22.04]
tzdata/jammy-updates 2024a-0ubuntu0.22.04.1 all [upgradable from: 2024a-0ubuntu0.22.04]
ubuntu-advantage-tools/jammy-updates 32.3.1~22.04 all [upgradable from: 31.2.3~22.04]
ubuntu-minimal/jammy-updates 1.481.2 amd64 [upgradable from: 1.481.1]
ubuntu-pro-client-l10n/jammy-updates 32.3.1~22.04 amd64 [upgradable from: 31.2.3~22.04]
ubuntu-pro-client/jammy-updates 32.3.1~22.04 amd64 [upgradable from: 31.2.3~22.04]
ubuntu-standard/jammy-updates 1.481.2 amd64 [upgradable from: 1.481.1]
ubuntu-wsl/jammy-updates 1.481.2 amd64 [upgradable from: 1.481.1]
update-manager-core/jammy-updates 1:22.04.20 all [upgradable from: 1:22.04.10]
vim-common/jammy-updates 2:8.2.3995-1ubuntu2.17 all [upgradable from: 2:8.2.3995-1ubuntu2.16]
vim-runtime/jammy-updates 2:8.2.3995-1ubuntu2.17 all [upgradable from: 2:8.2.3995-1ubuntu2.16]
vim-tiny/jammy-updates 2:8.2.3995-1ubuntu2.17 amd64 [upgradable from: 2:8.2.3995-1ubuntu2.16]
vim/jammy-updates 2:8.2.3995-1ubuntu2.17 amd64 [upgradable from: 2:8.2.3995-1ubuntu2.16]
xxd/jammy-updates 2:8.2.3995-1ubuntu2.17 amd64 [upgradable from: 2:8.2.3995-1ubuntu2.16]
tech-0222@MSI:tmp$
- Upgrade kubelet and kubectl
- https://kubernetes.io/docs/tasks/administer-cluster/kubeadm/upgrading-linux-nodes/#upgrade-kubelet-and-kubectl
- ドキュメントのアップグレード手順を参考にバージョンをアップグレードしてみる
- バージョンを事前に確認した「1.30.3-1.1」に変更して実行
tech-0222@MSI:tmp$ sudo apt-mark unhold kubelet kubectl && \
> sudo apt-get update && sudo apt-get install -y kubelet='1.30.3-1.1' kubectl='1.30.3-1.1' && \
> sudo apt-mark hold kubelet kubectl
kubelet was already not on hold.
kubectl was already not on hold.
Hit:1 https://download.docker.com/linux/ubuntu jammy InRelease
Hit:3 http://security.ubuntu.com/ubuntu jammy-security InRelease
Hit:4 http://archive.ubuntu.com/ubuntu jammy InRelease
Hit:2 https://prod-cdn.packages.k8s.io/repositories/isv:/kubernetes:/core:/stable:/v1.30/deb InRelease
Hit:5 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:6 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
conntrack ebtables ethtool kubernetes-cni socat
The following NEW packages will be installed:
conntrack ebtables ethtool kubelet kubernetes-cni socat
The following packages will be upgraded:
kubectl
1 upgraded, 6 newly installed, 0 to remove and 23 not upgraded.
Need to get 62.5 MB of archives.
After this operation, 185 MB of additional disk space will be used.
Get:1 https://prod-cdn.packages.k8s.io/repositories/isv:/kubernetes:/core:/stable:/v1.30/deb kubectl 1.30.3-1.1 [10.8 MB]
Get:2 http://archive.ubuntu.com/ubuntu jammy/main amd64 conntrack amd64 1:1.4.6-2build2 [33.5 kB]
Get:5 http://archive.ubuntu.com/ubuntu jammy/main amd64 ebtables amd64 2.0.11-4build2 [84.9 kB]
Get:6 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 ethtool amd64 1:5.16-1ubuntu0.1 [207 kB]
Get:3 https://prod-cdn.packages.k8s.io/repositories/isv:/kubernetes:/core:/stable:/v1.30/deb kubernetes-cni 1.4.0-1.1 [32.9 MB]
Get:7 http://archive.ubuntu.com/ubuntu jammy/main amd64 socat amd64 1.7.4.1-3ubuntu4 [349 kB]
Get:4 https://prod-cdn.packages.k8s.io/repositories/isv:/kubernetes:/core:/stable:/v1.30/deb kubelet 1.30.3-1.1 [18.1 MB]
Fetched 62.5 MB in 6s (9744 kB/s)
Selecting previously unselected package conntrack.
(Reading database ... 45150 files and directories currently installed.)
Preparing to unpack .../0-conntrack_1%3a1.4.6-2build2_amd64.deb ...
Unpacking conntrack (1:1.4.6-2build2) ...
Selecting previously unselected package ebtables.
Preparing to unpack .../1-ebtables_2.0.11-4build2_amd64.deb ...
Unpacking ebtables (2.0.11-4build2) ...
Selecting previously unselected package ethtool.
Preparing to unpack .../2-ethtool_1%3a5.16-1ubuntu0.1_amd64.deb ...
Unpacking ethtool (1:5.16-1ubuntu0.1) ...
Preparing to unpack .../3-kubectl_1.30.3-1.1_amd64.deb ...
Unpacking kubectl (1.30.3-1.1) over (1.28.2-00) ...
Selecting previously unselected package kubernetes-cni.
Preparing to unpack .../4-kubernetes-cni_1.4.0-1.1_amd64.deb ...
Unpacking kubernetes-cni (1.4.0-1.1) ...
Selecting previously unselected package socat.
Preparing to unpack .../5-socat_1.7.4.1-3ubuntu4_amd64.deb ...
Unpacking socat (1.7.4.1-3ubuntu4) ...
Selecting previously unselected package kubelet.
Preparing to unpack .../6-kubelet_1.30.3-1.1_amd64.deb ...
Unpacking kubelet (1.30.3-1.1) ...
Setting up conntrack (1:1.4.6-2build2) ...
Setting up kubectl (1.30.3-1.1) ...
Setting up ebtables (2.0.11-4build2) ...
Setting up socat (1.7.4.1-3ubuntu4) ...
Setting up kubernetes-cni (1.4.0-1.1) ...
Setting up ethtool (1:5.16-1ubuntu0.1) ...
Setting up kubelet (1.30.3-1.1) ...
Processing triggers for man-db (2.10.2-1) ...
kubelet set on hold.
kubectl set on hold.
tech-0222@MSI:tmp$
- アップグレードしたkubectlのバージョンを確認してみる
- 実行結果が「Client Version: v1.30.3」なので大丈夫そうですね
#パッケージがアップグレードしていることを確認
tech-0222@MSI:tmp$ dpkg -l kubectl
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-============-============-==============================================================
hi kubectl 1.30.3-1.1 amd64 Command-line utility for interacting with a Kubernetes cluster
tech-0222@MSI:tmp$
#コマンドの結果もバージョンが変わっていることを確認
tech-0222@MSI:tmp$ kubectl version --client=true
Client Version: v1.30.3
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
tech-0222@MSI:tmp$