kubernetes之二---基于kubeadm升级K8S版本

升级kubernetes到指定版本实战

1、在master节点上查看此时的kubernetes的版本

因为是yum安装的kubernetes,需要查看此时的版本,然后再去官网查看1.14.1的最新版本是多少

[ ~]# rpm -qi  kubeadm
Name        : kubeadm
Version     : 1.14.1
Release     : 0
Architecture: x86_64
Install Date: Mon 13 Jan 2020 02:41:35 PM CST
Group       : Unspecified
Size        : 39588940
License     : ASL 2.0
Signature   : RSA/SHA512, Tue 09 Apr 2019 05:09:51 AM CST, Key ID f09c394c3e1ba8d5
Source RPM  : kubelet-1.14.1-0.src.rpm
Build Date  : Tue 09 Apr 2019 05:02:41 AM CST
Build Host  : bf8516edf970
Relocations : (not relocatable)
URL         : https://kubernetes.io
Summary     : Command-line utility for administering a Kubernetes cluster.
Description :
Command-line utility for administering a Kubernetes cluster.

github官方网站:https://github.com/kubernetes/kubernetes/tags 

2、在master上升级kubeadm到指定版本

1、在官网上查看此时1.14的最新版本是1.14.10版本,因此直接在master安装1.14.3版本的kubeadm

[ ~]# yum -y install kubeadm-1.14.3

2、在master查看kubeadm帮助

[ ~]# kubeadm upgrade --help
Upgrade your cluster smoothly to a newer version with this command.

Usage:
  kubeadm upgrade [flags]
  kubeadm upgrade [command]

Available Commands:
  apply       Upgrade your Kubernetes cluster to the specified version.
  diff        Show what differences would be applied to existing static pod manifests. See also: kubeadm upgrade apply --dry-run
  node        Upgrade commands for a node in the cluster. Currently only supports upgrading the configuration, not the kubelet itself.
  plan        Check which versions are available to upgrade to and validate whether your current cluster is upgradeable. To skip the internet check, pass in the optional [version] parameter.

Flags:
  -h, --help   help for upgrade

Global Flags:
      --log-file string   If non-empty, use this log file
      --rootfs string     [EXPERIMENTAL] The path to the ‘real‘ host root filesystem.
      --skip-headers      If true, avoid header prefixes in the log messages
  -v, --v Level           number for the log level verbosity

Use "kubeadm upgrade [command] --help" for more information about a command.
[ ~]#

3、在master节点查看升级计划,验证是否可以升级到此版本

[ ~]# kubeadm upgrade plan
[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] Fetching available versions to upgrade to
[upgrade/versions] Cluster version: v1.14.1
[upgrade/versions] kubeadm version: v1.14.10
I0118 12:04:06.330170    5191 version.go:96] could not fetch a Kubernetes version from the internet: unable to get URL "https://dl.k8s.io/release/stable.txt": Get https://dl.k8s.io/release/stable.txt: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
I0118 12:04:06.330206    5191 version.go:97] falling back to the local client version: v1.14.10
[upgrade/versions] Latest stable version: v1.14.10
I0118 12:04:16.392134    5191 version.go:96] could not fetch a Kubernetes version from the internet: unable to get URL "https://dl.k8s.io/release/stable-1.14.txt": Get https://dl.k8s.io/release/stable-1.14.txt: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
I0118 12:04:16.392166    5191 version.go:97] falling back to the local client version: v1.14.10
[upgrade/versions] Latest version in the v1.14 series: v1.14.10

Components that must be upgraded manually after you have upgraded the control plane with ‘kubeadm upgrade apply‘:
COMPONENT   CURRENT       AVAILABLE
Kubelet     3 x v1.14.1   v1.14.3

Upgrade to the latest version in the v1.14 series:

COMPONENT            CURRENT   AVAILABLE
API Server           v1.14.1   v1.14.3  #可以看到此时要升级的版本
Controller Manager   v1.14.1   v1.14.3
Scheduler            v1.14.1   v1.14.3
Kube Proxy           v1.14.1   v1.14.3
CoreDNS              1.3.1     1.3.1
Etcd                 3.3.10    3.3.3

You can now apply the upgrade by executing the following command:

	kubeadm upgrade apply v1.14.3

4、在master节点开始升级到指定的版本

[ ~]# kubeadm upgrade  apply v1.14.3

 显示以下框的内容就说明已经升级成功!!!

 kubernetes之二---基于kubeadm升级K8S版本

 kubernetes之二---基于kubeadm升级K8S版本

 5、在master节点上升级各node节点配置文件

[ ~]# kubeadm upgrade node config --kubelet-version 1.14.3
[kubelet-start] Downloading configuration for the kubelet from the "kubelet-config-1.14" ConfigMap in the kube-system namespace
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[upgrade] The configuration for this node was successfully updated!
[upgrade] Now you should go ahead and upgrade the kubelet package using your package manager.

3、在各个node节点上安装最新版本的kubeadm、kubelet、kubectl包

[ ~]# yum -y install kubelet-1.14.3  kubeadm-1.14.3 kubectl-1.14.3
[ ~]# yum -y install kubelet-1.14.3  kubeadm-1.14.3 kubectl-1.14.3

4、验证最后K8S升级后的版本    

[ network-scripts]# kubectl get node
NAME     STATUS   ROLES    AGE   VERSION
master   Ready    master   21m   v1.14.3
node1    Ready    <none>   20m   v1.14.3
node2    Ready    <none>   20m   v1.14.3

相关推荐