Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Methods of upgrading kubeadm/kubectl/kubelet version and upgrading Kubernetes Cluster

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

这篇文章主要讲解了"升级kubeadm/kubectl/kubelet版本和升级Kubernetes集群的方法",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"升级kubeadm/kubectl/kubelet版本和升级Kubernetes集群的方法"吧!

1、升级kubeadm/kubectl/kubelet版本sudo apt install kubeadm=1.13.1-00 kubectl=1.13.1-00 kubelet=1.13.1-00

查看该版本的容器镜像版本:

kubeadm config images list

输出如下:

~# kubeadm config images listk8s.gcr.io/kube-apiserver:v1.13.1k8s.gcr.io/kube-controller-manager:v1.13.1k8s.gcr.io/kube-scheduler:v1.13.1k8s.gcr.io/kube-proxy:v1.13.1k8s.gcr.io/pause:3.1k8s.gcr.io/etcd:3.2.24k8s.gcr.io/coredns:1.2.62、拉取容器镜像

原始的kubernetes镜像文件在gcr上,不能直接下载。我给镜像到了阿里云的杭州机房的容器仓库里,拉取还是比较快的。

echo ""echo "=========================================================="echo "Pull Kubernetes v1.13.1 Images from aliyuncs.com ......"echo "=========================================================="echo ""MY_REGISTRY=registry.cn-hangzhou.aliyuncs.com/openthings## 拉取镜像docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-apiserver:v1.13.1docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-controller-manager:v1.13.1docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-scheduler:v1.13.1docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-proxy:v1.13.1docker pull ${MY_REGISTRY}/k8s-gcr-io-etcd:3.2.24docker pull ${MY_REGISTRY}/k8s-gcr-io-pause:3.1docker pull ${MY_REGISTRY}/k8s-gcr-io-coredns:1.2.6## 添加Tagdocker tag ${MY_REGISTRY}/k8s-gcr-io-kube-apiserver:v1.13.1 k8s.gcr.io/kube-apiserver:v1.13.1docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-scheduler:v1.13.1 k8s.gcr.io/kube-scheduler:v1.13.1docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-controller-manager:v1.13.1 k8s.gcr.io/kube-controller-manager:v1.13.1docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-proxy:v1.13.1 k8s.gcr.io/kube-proxy:v1.13.1docker tag ${MY_REGISTRY}/k8s-gcr-io-etcd:3.2.24 k8s.gcr.io/etcd:3.2.24docker tag ${MY_REGISTRY}/k8s-gcr-io-pause:3.1 k8s.gcr.io/pause:3.1docker tag ${MY_REGISTRY}/k8s-gcr-io-coredns:1.2.6 k8s.gcr.io/coredns:1.2.6echo ""echo "=========================================================="echo "Pull Kubernetes v1.13.1 Images FINISHED."echo "into registry.cn-hangzhou.aliyuncs.com/openthings, "echo " by openthings@https://my.oschina.net/u/2306127."echo "=========================================================="echo ""

保存为shell脚本,然后执行。

或者,下载脚本:https://github.com/openthings/kubernetes-tools/blob/master/kubeadm/2-images/

3、升级Kubernetes集群

全新安装:

#指定IP地址,1.13.1版本:# sudo kubeadm init --kubernetes-version=v1.13.1 --apiserver-advertise-address=10.1.1.100 --pod-network-cidr=10.244.0.0/16 --feature-gates CoreDNS=true

先查看一下需要升级的各个组件的版本。

使用kubeadm upgrade plan ,输出的版本升级信息如下:

COMPONENT CURRENT AVAILABLEAPI Server v1.12.3 v1.13.1Controller Manager v1.12.3 v1.13.1Scheduler v1.12.3 v1.13.1Kube Proxy v1.12.3 v1.13.1CoreDNS 1.2.6 1.2.6Etcd 3.2.24 3.2.24

确保上面的容器镜像已经下载(如果没有提前下载,可能被网络阻隔导致挂起),然后执行升级:

kubeadm upgrade -y apply v1.13.1

看到下面信息,就OK了。

[upgrade/successful] SUCCESS! Your cluster was upgraded to "v1.13.1". Enjoy!

然后,配置当前用户环境:

mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config

就可以使用 kubectl version 来查看状态和 kubectl cluster-info 查看服务地址。

4、工作节点的升级

每个工作节点需要拉取上面对应版本的镜像,以及安装kubelet的对应版本。

检查版本:

~$ kubectl versionClient Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.1", GitCommit:"4ed3216f3ec431b140b1d899130a69fc671678f4", GitTreeState:"clean", BuildDate:"2018-10-05T16:46:06Z", GoVersion:"go1.10.4", Compiler:"gc", Platform:"linux/amd64"}Server Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.1", GitCommit:"4ed3216f3ec431b140b1d899130a69fc671678f4", GitTreeState:"clean", BuildDate:"2018-10-05T16:36:14Z", GoVersion:"go1.10.4", Compiler:"gc", Platform:"linux/amd64"}

查看Pod信息:

kubectl get pod --all-namespaces

完成。

感谢各位的阅读,以上就是"升级kubeadm/kubectl/kubelet版本和升级Kubernetes集群的方法"的内容了,经过本文的学习后,相信大家对升级kubeadm/kubectl/kubelet版本和升级Kubernetes集群的方法这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是,小编将为大家推送更多相关知识点的文章,欢迎关注!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report