kubernetes Upgrade

  • Category: 電腦相關
  • Last Updated: Sunday, 23 September 2018 23:10
  • Published: Sunday, 23 September 2018 15:34
  • Written by sam

試更新版本號

目前是

root@ubuntu134:~# kubectl version -o json
{
  "clientVersion": {
    "major": "1",
    "minor": "10",
    "gitVersion": "v1.10.3",
    "gitCommit": "2bba0127d85d5a46ab4b778548be28623b32d0b0",
    "gitTreeState": "clean",
    "buildDate": "2018-05-21T09:17:39Z",
    "goVersion": "go1.9.3",
    "compiler": "gc",
    "platform": "linux/amd64"
  },

  "serverVersion": {
    "major": "1",
    "minor": "10",
    "gitVersion": "v1.10.3",
    "gitCommit": "2bba0127d85d5a46ab4b778548be28623b32d0b0",
    "gitTreeState": "clean",
    "buildDate": "2018-05-21T09:05:37Z",
    "goVersion": "go1.9.3",
    "compiler": "gc",
    "platform": "linux/amd64"
  }
}
root@ubuntu134:~# export VERSION=$(curl -sSL https://dl.k8s.io/release/stable.txt)
root@ubuntu134:~# export ARCH=amd64
root@ubuntu134:~# curl -sSL https://dl.k8s.io/release/${VERSION}/bin/linux/${ARCH}/kubeadm > /usr/bin/kubeadm
root@ubuntu134:~# chmod a+rx /usr/bin/kubeadm
root@ubuntu134:~# kubeadm upgrade plan

Upgrade to the latest stable version:

COMPONENT            CURRENT   AVAILABLE
API Server           v1.10.3   v1.11.3
Controller Manager   v1.10.3   v1.11.3
Scheduler            v1.10.3   v1.11.3
Kube Proxy           v1.10.3   v1.11.3
CoreDNS                        1.1.3
Kube DNS             1.14.8    
Etcd                 3.1.12    3.2.18

這個命令可以列出本次可以更新的項目,這次的最大不同就是CoreDNS替換了原本的DNS了

root@ubuntu134:~# kubeadm upgrade apply v1.11.3
[preflight] Running pre-flight checks.
[upgrade] Making sure the cluster is healthy:
[upgrade/config] Making sure the configuration is correct:
[upgrade/config] Reading configuration from the cluster...
[upgrade/config] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -oyaml'
[upgrade/apply] Respecting the --cri-socket flag that is set with higher priority than the config file.
[upgrade/version] You have chosen to change the cluster version to "v1.11.3"
[upgrade/versions] Cluster version: v1.10.3
[upgrade/versions] kubeadm version: v1.11.3
[upgrade/confirm] Are you sure you want to proceed with the upgrade? [y/N]:

然後等待一下,在更新前會自動先備份設定檔

最後會見到成功的訊息

[upgrade/successful] SUCCESS! Your cluster was upgraded to "v1.11.3". Enjoy!
root@ubuntu134:~# kubectl drain $HOST --ignore-daemonsets #每node
root@ubuntu134:~# apt-get update &;& apt-get upgrade -y kubelet kubeadm #每node
root@ubuntu134:~# systemctl restart kubelet  #每node
root@ubuntu136:~# systemctl status kubelet #檢查狀態
● kubelet.service - kubelet: The Kubernetes Node Agent
   Loaded: loaded (/lib/systemd/system/kubelet.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/kubelet.service.d
           └─10-kubeadm.conf
   Active: active (running) since Sun 2018-09-23 23:00:35 CST; 31s ago
root@ubuntu134:~# kubectl uncordon ubuntu134 #每node
root@ubuntu134:~# kubectl get nodes #最後查看node狀態
NAME        STATUS    ROLES     AGE       VERSION
ubuntu134   Ready     master    111d      v1.11.3
ubuntu135   Ready     <none>    111d      v1.11.3
ubuntu136   Ready     <none>    111d      v1.11.3

至此完成!!!