升级kubeadm部署的k8s集群

K爷 DevOps视角

升级k8s集群


使用kubeadm部署kubernetes集群介绍了使用kubeadm快速部署k8s集群,这篇文章将升级k8s集群。

此升级方法仅适用于使用kubeadm部署的k8s集群。

升级kubeadm


升级k8s集群必须先升级kubeadm版本到要升级的版本。即要升级kubeadm部署的k8s级群,必须先升级kubeadm版本。

# kubeadm versionkubeadm version: &version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.2", GitCommit:"59603c6e503c87169aea6106f57b9f242f64df89", GitTreeState:"clean", BuildDate:"2020-01-18T23:27:49Z", GoVersion:"go1.13.5", Compiler:"gc", Platform:"linux/amd64"}

各master升级到目的版本kubeadm


  • 升级kubeadm
# apt-cache madison kubeadm# apt-get install kubeadm=1.17.4-00# kubeadm versionkubeadm version: &version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.4", GitCommit:"8d8aa39598534325ad77120c120a22b3a990b5ea", GitTreeState:"clean", BuildDate:"2020-03-12T21:01:11Z", GoVersion:"go1.13.8", Compiler:"gc", Platform:"linux/amd64"}
  • 查看升级计划
# kubeadm upgrade plan[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'[preflight] Running pre-flight checks.[upgrade] Making sure the cluster is healthy:[upgrade] Fetching available versions to upgrade to[upgrade/versions] Cluster version: v1.17.2[upgrade/versions] kubeadm version: v1.17.4I0723 15:10:34.814329   40861 version.go:251] remote version is much newer: v1.18.6; falling back to: stable-1.17[upgrade/versions] Latest stable version: v1.17.9[upgrade/versions] Latest version in the v1.17 series: v1.17.9Components that must be upgraded manually after you have upgraded the control plane with 'kubeadm upgrade apply':COMPONENT   CURRENT       AVAILABLEKubelet     6 x v1.17.2   v1.17.9Upgrade to the latest version in the v1.17 series:COMPONENT            CURRENT   AVAILABLEAPI Server           v1.17.2   v1.17.9Controller Manager   v1.17.2   v1.17.9Scheduler            v1.17.2   v1.17.9Kube Proxy           v1.17.2   v1.17.9CoreDNS              1.6.5     1.6.5Etcd                 3.4.3     3.4.3-0You can now apply the upgrade by executing the following command:        kubeadm upgrade apply v1.17.9Note: Before you can perform this upgrade, you have to update kubeadm to v1.17.9.

升级master

在各个master节点进行升级
master节点要一个一个升级,不要一起同时升级

# kubeadm upgrade apply v1.17.4......[upgrade/successful] SUCCESS! Your cluster was upgraded to "v1.17.4". Enjoy![upgrade/kubelet] Now that your control plane is upgraded, please proceed with upgrading your kubelets if you haven't already done so.# docker images|grep v1.17.4registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy                v1.17.4             6dec7cfde1e5        4 months ago        116MBregistry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver            v1.17.4             2e1ba57fe95a        4 months ago        171MBregistry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager   v1.17.4             7f997fcf3e94        4 months ago        161MBregistry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler            v1.17.4

升级kubelet和kubectl

# apt install kubelet=1.17.4-00 kubectl=1.17.4-00

升级node节点


查看当前node 版本

# kubectl get nodeNAME          STATUS   ROLES    AGE   VERSIONk8s-master1   Ready    master   25h   v1.17.4k8s-master2   Ready    master   24h   v1.17.4k8s-master3   Ready    master   24h   v1.17.4k8s-node1     Ready    <none>   23h   v1.17.2k8s-node2     Ready    <none>   23h   v1.17.2k8s-node3     Ready    <none>   23h   v1.17.2

升级node节点配置文件

# kubeadm upgrade node --kubelet-version 1.17.4[upgrade] Reading configuration from the cluster...[upgrade] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -oyaml'[upgrade] Skipping phase. Not a control plane node.[upgrade] Using kubelet config version 1.17.4, while kubernetes-version is v1.17.4[kubelet-start] Downloading configuration for the kubelet from the "kubelet-config-1.17" 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.

升级node节点的kubelet、kubeadm

# apt install kubelet=1.17.4-00 kubeadm=1.17.4-00

查看node

# kubectl get nodeNAME          STATUS   ROLES    AGE   VERSIONk8s-master1   Ready    master   25h   v1.17.4k8s-master2   Ready    master   24h   v1.17.4k8s-master3   Ready    master   24h   v1.17.4k8s-node1     Ready    <none>   24h   v1.17.4k8s-node2     Ready    <none>   24h   v1.17.4k8s-node3     Ready    <none>   24h   v1.17.4
©著作权归作者所有:来自51CTO博客作者mob604756e75222的原创作品,如需转载,请注明出处,否则将追究法律责任

更多相关文章

  1. 如何落地全球最大 Kubernetes 生产集群
  2. Nginx版本平滑升级
  3. Kafka 集群部署
  4. 使用kubeadm部署kubernetes集群
  5. 容器云平台No.3~kubernetes简单使用
  6. 容器云平台No.6~企业级分布式存储Ceph~v14.2.10
  7. 容器云平台No.4~kubernetes 服务暴露之Ingress
  8. 浅析Kubernrtes服务类型(Service Types)
  9. Kubernetes集群管理容器实践(概念篇)

随机推荐

  1. Centos6.10 安装Python 2.7.16
  2. python入门经典(一)
  3. 用Python和Pygame写游戏-从入门到精通(8)
  4. 字典(dict)按键(key)和值(value)排序
  5. python3使用 openpyxl 操作excel表格
  6. Python基础数据类型-函数传参详解
  7. Python—插入排序算法
  8. 2D Numpy Array的边缘值
  9. 学习python的第十六天(迭代器,三元表达式,
  10. python 装饰器和 functools 模块