概要
kubectlのバージョンはクラスターのマイナーバージョンとの差分が±1以内でなければならない。
そのためクラスターのバージョンを上げる際には、kubectlのバージョンが上記条件を満たしているか気にする必要がある。
本投稿ではkubectlのバージョンを1.24→1.25にアップデートしてみる。
なお、利用可能なバージョンの一覧は下記URLのtagにて確認できる。
https://github.com/kubernetes/kubernetes
環境
OS:Ubuntu 22.04.2 LTS
Kubernetes Cluster:v1.25.6
現在のバージョン確認
command
$ kubectl version --short
Flag --short has been deprecated, and will be removed in the future. The --short output will become the default.
Client Version: v1.24.10
Kustomize Version: v4.5.4
Server Version: v1.25.6
Client Versionがv1.24.10となっている。これを1.25.6に上げる。
バージョンアップ
1.kubectlダウンロード
command
$ curl -LO https://dl.k8s.io/release/v1.25.6/bin/linux/amd64/kubectl
※URLのv1.25.6の部分は適宜目的のバージョンに変える。
カレントディレクトリにkubectlがダウンロードできた。
command
$ ll kubectl
-rw-rw-r-- 1 usr usr 45031424 Jul 11 06:51 kubectl
2.実行可能にする
command
$ chmod +x ./kubectl
実行権限がついた。
command
$ ll kubectl
-rwxrwxr-x 1 usr usr 45031424 Jul 11 06:51 kubectl*
3./usr/local/binに移動
command
$ sudo mv ./kubectl /usr/local/bin/kubectl
バージョンが上がっているか確認
command
$ kubectl version --short
Flag --short has been deprecated, and will be removed in the future. The --short output will become the default.
Client Version: v1.25.6
Kustomize Version: v4.5.7
Server Version: v1.25.6
Client Versionがv1.25.6に上がった。
最後にkubectl cluster-infoやkubectl get podコマンドなどでクラスターに接続できていることが確認できればOK。
参考