LoginSignup
1
1

More than 5 years have passed since last update.

kubesprayで、v2.5.0(k8s v1.9.5)からv2.7.0(k8s v1.11.3)へアップグレード

Last updated at Posted at 2018-10-11

はじめに

以前、記事にまとめたkubesprayでk8s環境を構築している件について、気がついたら少しkubesprayのバージョンが上がっていたので更新することにしました。

環境について

Ansibleホスト環境

  • Ubuntu 18.04.1 LTS 64bit on VMWare Workstation 14
  • Ansible v2.7.0

クライアント環境 (Kubernetesノード)

下記のAPU2 4台を、ホスト側のAnsibleから構成しています。

  • Hardware: APU2 (PC Engines社製 apu2c4) AMD GX-412TC (4コア 1.2GHz), Memory 4GB, mSATA 128GB
  • OS: Ubuntu 16.04.5 LTS (xenial) 64bit版

現行のKubesprayでdeployしているkubernetes(k8s)は下記のとおりです。

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.5", GitCommit:"f01a2bf98249a4db383560443a59bed0c13575df", GitTreeState:"clean", BuildDate:"2018-03-19T15:50:45Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.5", GitCommit:"f01a2bf98249a4db383560443a59bed0c13575df", GitTreeState:"clean", BuildDate:"2018-03-19T15:50:45Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}

準備作業

Ansibleが稼動するホスト環境で作業を実施します。
v1.9.5が稼動している状態で、あらかじめパッケージ類を最新にしておきます。
hosts.iniファイルへのパスは、"sample" → "mycluster"など適宜変換してください。

$ ansible all -i inventory/sample/hosts.ini -b -m command -a 'apt-get -y update'
$ ansible all -i inventory/sample/hosts.ini -b -m command -a 'apt-get -y dist-upgrade'
$ ansible all -i inventory/sample/hosts.ini -b -m command -a 'apt-get -y autoremove'
$ ansible all -i inventory/sample/hosts.ini -b -m command -a 'shutdown -r now'

後述した手順の中でエラー(etcdでのno attributes error)が出たので、下記のようにpipで~/.local/以下に必要なバージョンのパッケージをインストールしています。

$ pip install -r requirements.txt

作業の流れ

公式ドキュメントにあるように進めていきますが、headではなくv2.7.0タグをcheckoutするよう変更しています。

まず modified ステータスのファイルがないか確認します。

$ cd $KUBESPRAY_ROOTDIR ## まずkubesprayのトップディレクトリに移動します
$ git status

下記のように ansible.cfg が編集中であることが表示されます。

...
(use "git checkout -- ..." to discard changes in working directory)

modified: ansible.cfg

Untracked files:
...

このファイルのバックアップを取得して、元に戻します。

$ cp -ip ansible.cfg ansible.cfg.local
$ git checkout ansible.cfg

modifiedなファイルがなくなってから、リポジトリを同期します。

$ git fetch origin
$ git checkout origin/master
$ git checkout -b v2.7.0

ここでリビジョンをチェックしておきます。
$ git log -1

commit abe711dcb59191128644fde15f9d4e937586870d
Author: Pierluigi Lenoci 36044817+PierluigiLenociAkelius@users.noreply.github.com
Date: Wed Oct 10 21:37:47 2018 +0200

ここから、k8sをv2.7.0が対応する、1.11.3に更新します。

$ ansible-playbook upgrade-cluster.yml -b -i inventory/sample/hosts.ini -e kube_version=v1.11.3

作業の結果

この構成ではおよそ60分弱で作業が完了しました。

同様の方法で構成しているXeon e3-1220v2を搭載しているサーバー機を使ったクライアント4台(ホスト側はHP Microserver Gen8 E3-1220Lv2 8GB)では、30分程度で完了しています。

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.3", GitCommit:"a4529464e4629c21224b3d52edfe0ea91b072862", GitTreeState:"clean", BuildDate:"2018-09-09T17:53:03Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.3", GitCommit:"a4529464e4629c21224b3d52edfe0ea91b072862", GitTreeState:"clean", BuildDate:"2018-09-09T17:53:03Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}

以上

1
1
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
1
1