僅需4步,輕松升級(jí)K3s集群!

Rancher 2.4是Rancher目前最新的版本,在這一版本中你可以通過Rancher UI對(duì)K3s集群進(jìn)行升級(jí)管理。 K3s是一個(gè)輕量級(jí)Kubernetes發(fā)行版,借助它你可以幾分鐘之內(nèi)設(shè)置你的開發(fā)Kubernetes環(huán)境。它非常適用于生產(chǎn)用例,主要用于IoT和Edge設(shè)備。 在Rancher 2.4中,你可以導(dǎo)入K3s集群并且可以通過Rancher本身對(duì)其進(jìn)行升級(jí)管理。在本篇教程中,我們將了解如何在一個(gè)正在運(yùn)行的K3s集群上執(zhí)行實(shí)時(shí)升級(jí)。

創(chuàng)新互聯(lián)建站是一家專業(yè)提供無極企業(yè)網(wǎng)站建設(shè),專注與網(wǎng)站制作、成都網(wǎng)站建設(shè)、HTML5建站、小程序制作等業(yè)務(wù)。10年已為無極眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)絡(luò)公司優(yōu)惠進(jìn)行中。

Step1:創(chuàng)建K3s集群

在執(zhí)行升級(jí)之前,我們需要啟動(dòng)一個(gè)K3s集群。在本文中我是在一個(gè)CentOS VM上啟動(dòng)的,你可以在任意云上執(zhí)行這一操作。 登錄到VM,并運(yùn)行以下命令: ```

[root@demo3 ~]# curl -sfL [https://get.k3s.io] | INSTALL_K3S_VERSION="v1.0.1" sh -s -** Using v1.0.1 as release Downloading hash [https://github.com/rancher/k3s/releases/download/v1.0.1/sha256sum-amd64.txt] Downloading binary [https://github.com/rancher/k3s/releases/download/v1.0.1/k3s] Verifying binary download Installing k3s to /usr/local/bin/k3s Creating /usr/local/bin/kubectl symlink to k3s Creating /usr/local/bin/crictl symlink to k3s Creating /usr/local/bin/ctr symlink to k3s Creating killall script /usr/local/bin/k3s-killall.sh Creating uninstall script /usr/local/bin/k3s-uninstall.sh env: Creating environment file /etc/systemd/system/k3s.service.env systemd: Creating service file /etc/systemd/system/k3s.service systemd: Enabling k3s unit Created symlink from /etc/systemd/system/multi-user.target.wants/k3s.service to /etc/systemd/system/k3s.service. systemd: Starting k3sAbove will install k3s version **[root@demo3 ~]# kubectl get nodes** NAME STATUS ROLES AGE VERSION demo3 Ready master 5m55s **v1.16.3-k3s.2** ``` 你可以看到我們?cè)赩M上已經(jīng)安裝了Kubernetes v1.16.3。

Step2:安裝Rancher** 為了從Rancher UI中執(zhí)行升級(jí),必須通過以下命令安裝Rancher: ``` **[root@demo3 ~]# sudo docker run -d --restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher **Unable to find image 'rancher/rancher:latest' locally Trying to pull repository docker.io/rancher/rancher ... latest: Pulling from docker.io/rancher/rancher 5bed26d33875: Pull complete f11b29a9c730: Pull complete 930bda195c84: Pull complete 78bf9a5ad49e: Pull complete fdb587a45dfe: Pull complete 0c3f7647a659: Pull complete 02c5407ca821: Pull complete ebc009758b56: Pull complete 57a6e40f0f6e: Pull complete 30a88d01aca6: Pull complete 76505b705d6f: Pull complete e585ea16af8d: Pull complete 6b069694034e: Pull complete 8c5d309f94d1: Pull complete 8ec56f5fa6c2: Pull complete 75872eb736b7: Pull complete e774fd043162: Pull complete c76d81e7a658: Pull complete 49bf6b83af1c: Pull complete Digest: sha256:248ddca1169e8a4e06babd50e8105cbba0a326f86ec4de3e38d61e8909ffdb4e Status: Downloaded newer image for docker.io/rancher/rancher:latest ef7f9a0d5bca831af19900a6ceafd30daca51e4f951295762cf7516e48d3d742 ```

Step3:在Rancher中導(dǎo)入集群** 打開Rancher UI并點(diǎn)擊以下按鈕導(dǎo)入K3s集群: 復(fù)制最后一條命令并在安裝了K3s的VM上運(yùn)行該命令: ``` **[root@demo3 ~]# curl --insecure -sfL [https://185.136.232.236/v3/import/pxv5g7xswnnqkhl4dx7nrn8swndwshk9g8426lnldrvt7vjvfc2fgr.yaml] | kubectl apply -f -** clusterrole.rbac.authorization.k8s.io/proxy-clusterrole-kubeapiserver created clusterrolebinding.rbac.authorization.k8s.io/proxy-role-binding-kubernetes-master created namespace/cattle-system created serviceaccount/cattle created clusterrolebinding.rbac.authorization.k8s.io/cattle-admin-binding created secret/cattle-credentials-d6e5b6d created clusterrole.rbac.authorization.k8s.io/cattle-admin created deployment.apps/cattle-cluster-agent created daemonset.apps/cattle-node-agent created ```

Step4:執(zhí)行升級(jí)** 點(diǎn)擊三個(gè)小點(diǎn)點(diǎn),并選擇【Edit】。選擇最新的Kubernetes版本并點(diǎn)擊保存。 點(diǎn)擊保存之后,你可以看到集群狀態(tài)從Active變成了Upgrading。 一會(huì)兒之后,狀態(tài)會(huì)重新變?yōu)锳ctive,你將看到K3s集群升級(jí)到了最新版本。 僅需幾次點(diǎn)擊,我們已經(jīng)通過Rancher UI直接將導(dǎo)入的K3s集群升級(jí)到了v1.17.4版本。

Troubleshooting 社區(qū)用戶經(jīng)過實(shí)踐之后發(fā)現(xiàn)K3s集群處于Upgrading的狀態(tài)會(huì)持續(xù)很長(zhǎng)一段時(shí)間。經(jīng)過Rancher中國(guó)的社區(qū)技術(shù)經(jīng)理本地操作復(fù)現(xiàn)后,給出如下解決方案: K3s 分為master和agent角色。K3s集群?jiǎn)?dòng)成功后,可以導(dǎo)入到Rancher server去納管。如果Rancher server和K3s master在同一個(gè)節(jié)點(diǎn)上,在Rancher UI上升級(jí)K3s 版本就會(huì)出現(xiàn)失敗的情況。 此外,由于https://github.com/rancher/k3s-upgrade/blob/v1.18.4+k3s1/scripts/upgrade.sh#L15的邏輯,升級(jí)時(shí)會(huì)grep兩個(gè)進(jìn)程,分別是K3s master和Rancher server中的K3s,所以會(huì)報(bào)錯(cuò)。 如要解決上述問題,需要先將Rancher server 停掉,等待K3s升級(jí)成功后,再啟動(dòng)Rancher server。 **結(jié) 論** Rancher推出的K3s輕巧易用,加上Rancher 2.4對(duì)其的支持,升級(jí)集群更是易如反掌。當(dāng)你通過Rancher UI導(dǎo)入K3s集群,Rancher會(huì)自動(dòng)檢測(cè)并啟用帶有可用版本列表的升級(jí)集群選項(xiàng)。通過這一功能,你可以升級(jí)任意K3s集群,無論該集群是自管理還是托管在云上。

當(dāng)前文章:僅需4步,輕松升級(jí)K3s集群!
URL鏈接:http://muchs.cn/article6/sdehog.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)建站、網(wǎng)頁設(shè)計(jì)公司做網(wǎng)站、面包屑導(dǎo)航App設(shè)計(jì)、云服務(wù)器

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站建設(shè)網(wǎng)站維護(hù)公司