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

How to quickly upgrade and expand the capacity of Kubernetes 1.20.2 High availability Cluster

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to quickly upgrade and expand the Kubernetes 1.20.2 high availability cluster". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to quickly upgrade and expand the Kubernetes 1.20.2 high availability cluster.

Transfer the mirror to the appropriate node in advance, and then run the following command on any master node to complete the upgrade.

Kubeadm upgrade apply v1.20.2

Add a node to the current cluster:

The first step is to recreate certificate key and token:

Sudo kubeadm init phase upload-certs-upload-certs### Got:# [upload-certs] Using certificate key:# 2ffe5bbf7d2e670d5bcfb03dac194e2f21eb9715f2099c5f8574e4ba7679ff78# Add certificate-key for Multi Master Node.kubeadm token create-print-join-command-certificate-key 2ffe5bbf7d2e670d5bcfb03dac194e2f21eb9715f2099c5f8574e4ba7679ff78

The second step is to add Worker nodes:

Kubeadm join 192.168.199.173Groupe 6443-token rlxvkn.2ine1loolri50tzt-discovery-token-ca-cert-hash sha256:86e68de8febb844ab8f015f6af4526d78a980d9cdcf7863eebb05b17c24b9383

The third step is to add master nodes:

Kubeadm join 192.168.199.173Viru 6443-token rlxvkn.2ine1loolri50tzt-discovery-token-ca-cert-hash sha256:86e68de8febb844ab8f015f6af4526d78a980d9cdcf7863eebb05b17c24b9383-control-plane-certificate-key 440a880086e7e9cbbcebbd7924e6a9562d77ee8de7e0ec63511436f2467f7dde

Deploy kubernetes on arm reference:

Kubernetes for arm 1.18.0 Quick installation

Development status of kubernetes on arm

Some minor errors occurred during the upgrade, which were later resolved:

Etcd error for kubernetes high availability cluster upgrade

Resolution of errors in Ubuntu cross-version upgrade

The solution of error "NO_PUBKEY" appearing in Ubuntu apt upgrade

1. Upgrade kubeadm/kubectl/kubelet version sudo apt install kubeadm=1.20.2-00 kubectl=1.20.2-00 kubelet=1.20.2-00

To set up the software source in China, refer to: kubernetes for china

View the container image version of this version:

Kubeadm config images list

The output is as follows:

~ # kubeadm config images listk8s.gcr.io/kube-apiserver:v1.20.2k8s.gcr.io/kube-controller-manager:v1.20.2k8s.gcr.io/kube-scheduler:v1.20.2k8s.gcr.io/kube-proxy:v1.20.2k8s.gcr.io/pause:3.2k8s.gcr.io/etcd:3.4.13-0k8s.gcr.io/coredns:1.7.02, pull container image

The original kubernetes image file is on gcr and cannot be downloaded directly. I originally mirrored it into the container warehouse of Ariyun's Hangzhou computer room, and it was relatively fast to pull it. Now there is no problem with hub.docker.com access, some students put the image into the material, and the update is quite timely, you can use it directly.

# mirrorgcrio has not been updated. # MY_REGISTRY=mirrorgcrioMY_REGISTRY=registry.cn-hangzhou.aliyuncs.com/google_containersK8S_VERSION= "1.20.2" echo "echo" = = "echo" Pull Kubernetes for x64 v$K8S_VERSION Images from docker.io. "echo" = = "echo"# # pull image docker pull ${MY_REGISTRY} / kube-apiserver:v$K8S_VERSIONdocker pull ${MY_REGISTRY} / kube-controller-manager:v$K8S_VERSIONdocker pull ${MY_REGISTRY } / kube-scheduler:v$K8S_VERSIONdocker pull ${MY_REGISTRY} / kube-proxy:v$K8S_VERSIONdocker pull ${MY_REGISTRY} / etcd:3.4.13-0docker pull ${MY_REGISTRY} / pause:3.2#docker pull ${MY_REGISTRY} / coredns-arm64:1.7.0docker pull coredns/coredns:1.7.0## add Tagdocker tag ${MY_REGISTRY} / kube-apiserver:v$K8S_VERSION k8s.gcr.io/kube-apiserver:v$K8S_VERSIONdocker tag ${ MY_REGISTRY} / kube-scheduler:v$K8S_VERSION k8s.gcr.io/kube-scheduler:v$K8S_VERSIONdocker tag ${MY_REGISTRY} / kube-controller-manager:v$K8S_VERSION k8s.gcr.io/kube-controller-manager:v$K8S_VERSIONdocker tag ${MY_REGISTRY} / kube-proxy:v$K8S_VERSION k8s.gcr.io/kube-proxy:v$K8S_VERSIONdocker tag ${MY_REGISTRY} / etcd:3.4.13-0 k8s.gcr.io/etcd:3.4.13-0docker tag ${ MY_REGISTRY} / pause:3.2 k8s.gcr.io/pause:3.2#docker tag ${MY_REGISTRY} / coredns-arm64:1.7.0 k8s.gcr.io/coredns:1.7.0docker tag coredns/coredns:1.7.0 k8s.gcr.io/coredns:1.7.0echo "" echo "= =" echo "Pull Kubernetes for x64 v$K8S_VERSION Images FINISHED." echo "into docker.io/mirrorgcrio "echo" by openthings@ https://my.oschina.net/u/2306127."echo "=" echo ""

Save as a shell script and execute it.

3. Upgrade Kubernetes cluster

New installation:

# specify IP address, version 1.20.2: sudo kubeadm init-kubernetes-version=v1.20.2-apiserver-advertise-address=10.1.1.199-pod-network-cidr=10.244.0.0/16

Highly available installation (multiple master nodes):

Sudo kubeadm init-kubernetes-version=v1.20.2-apiserver-advertise-address=192.168.199.173-control-plane-endpoint=192.168.199.173:6443-pod-network-cidr=10.244.0.0/16-upload-certs

Deploy highly available Kubernetes 1.17.0 using kubeadm

First take a look at the versions of the components that need to be upgraded.

Using kubeadm upgrade plan, the version upgrade information is output as follows:

Components that must be upgraded manually after you have upgraded the control plane with 'kubeadm upgrade apply':COMPONENT CURRENT AVAILABLEKubelet 1 x v1.20.0 v1.20.28 x v1.20.0 v1.20.2Upgrade to the latest version in the v1.20 series:COMPONENT CURRENT AVAILABLEAPI Server v1.20.0 v1.20.2Controller Manager v1.20.0 v1.20.2Scheduler v1.20.0 v1.20.2Kube Proxy v1.20.0 v1.20.2CoreDNS 1.7.0 1.7.0Etcd 3.4.13-0 3.4.13-0You can now apply the upgrade by executing the following command:kubeadm upgrade apply v1.20.2

Make sure that the above container image has been downloaded (if it is not downloaded in advance, it may be suspended by the network), and then perform the upgrade:

Kubeadm upgrade apply v1.20.2

If you see the following message, OK it.

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

Then, configure the current user environment:

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

You can use kubectl version to view the status and kubectl cluster-info to view the service address.

If the service is not up, test it:

View the service version, kubectl version

View cluster information, kubectl cluster-info

View service status, sudo systemctl status kubelet

View the service log, journalctl-xefu kubelet

4. Upgrade of work node

Each worker node needs to pull the image facing the corresponding version and install the corresponding version of kubelet.

Check the version:

~ $kubectl version

View Pod information:

Kubectl get pod-all-namespaces

Done.

⚠️ Note: after version 1.17, if you use kubeadm to install in high availability mode, all master nodes can be upgraded to the latest version (you need to put the container image of K8s on the node in advance).

At this point, I believe you have a deeper understanding of "how to quickly upgrade and expand the Kubernetes 1.20.2 high availability cluster". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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