日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

边缘使用 K8s 门槛太高?OpenYurt 这个功能帮你快速搭建集群!

發布時間:2025/3/20 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 边缘使用 K8s 门槛太高?OpenYurt 这个功能帮你快速搭建集群! 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

OpenYurt 作為阿里巴巴首個開源的邊緣云原生項目,涉及到邊緣計算和云原生兩個領域。然而,許多邊緣計算的開發者并不熟悉云原生相關的知識。為了降低 OpenYurt 的使用門檻,幫助更多地開發者快速上手 OpenYurt,社區提供了 OpenYurt 易用性工具 yurtctl。該工具致力于屏蔽 OpenYurt 集群創建的復雜性,幫助開發者在本地快速地搭建 OpenYurt 開發測試集群。

OpenYurt 采用云管邊的架構,在原生 Kubernetes 集群之上,以 Addon 的形式進行功能增強,解決了云管邊場景中,云邊網絡不穩定、云邊運維難等關鍵問題,并實現了工作負載/流量的單元化管理、邊緣本地存儲、物聯網設備管理等核心功能。本文實驗的拓撲如圖所示:

其中,藍色部分是原生的 k8s 組件,橙色部分是 OpenYurt 提供的組件。

  • Master 節點位于云端,作為 OpenYurt 集群的管控節點,同時也作為集群的 Cloud Node,上面部署了原生 k8s 的控制面組件 controlplane,以及 OpenYurt 的管控組件 yurt-controller-manager、yurt-app-manager、yurt-tunnel-server
  • Cloud-Node 節點位于云端,作為 OpenYurt 集群的 Cloud Node,可以用于部署 OpenYurt 的管控組件,本文實驗中只用于演示了云端節點接入操作,沒有實際部署OpenYurt的管控組件。
  • Edge-Node 位于邊緣,作為集群的邊緣節點,部署了節點自治組件 YurtHub,以及云端通道組件 tunnel-agent。

環境準備

(1)三臺 Linux 操作系統的計算機。一個作為控制平面節點(同時也是云端節點)、一個作為云端節點和一個作為邊緣節點,系統均為 Ubuntu18.04)。

(2)系統預安裝 Docker,安裝方式參考。

(3)關閉系統交換分區,不同版本系統的關閉方式存在差異,本文環境執行 swapoff -a 關閉。

(4)下載 OpenYurt 社區代碼,構建 yurtctl 工具,并將 yurtctl 拷貝到三臺主機上。

git clone https://github.com/openyurtio/openyurt.git cd openyurt export GOOS=linux GOARCH=amd64; make build WHAT=cmd/yurtctl

構建的 yurtctl 在目錄_output/bin/中,其中本文采用的 yurtctl 版本為:

root@master:~# ./yurtctl --version yurtctl version: projectinfo.Info{GitVersion:"v0.4.1", GitCommit:"3315ccc", BuildDate:"2021-09-08T02:48:34Z", GoVersion:"go1.13", Compiler:"gc", Platform:"linux/amd64"}

一鍵拉起控制面節點?

在 yurtctl 中,提供了init子命令用于拉起 OpenYurt 的管控節點。該節點中部署了 Kubernetes 集群的管控組件(kube-apiserver/kube-scheduler/kube-controller-manager/etcd)。同時也作為 OpenYurt 云端管控節點部署了 OpenYurt 的管控組件(yurt-controller-manager/yurt-app-manager/yurt-tunnel-server)

在控制面節點上,執行如下命令

root@master:~# ./yurtctl init --image-repository=registry.cn-hangzhou.aliyuncs.com/google_containers --kubernetes-version=v1.18.8 --pod-network-cidr=10.244.0.0/16

該命令指定了 Kubernetes 相關組件的鏡像倉庫為 registry.cn-hangzhou.aliyuncs.com/google_containers,此外指定的 Kubernetes 集群的版本為1.18.8(推薦)。yurtctl init 指令的更多參數可以參考yurtctl init --help.

yurtctl init 命令執行成功之后會同步輸出添加云端節點和邊緣節點的指令。

Your OpenYurt cluster control-plane has initialized successfully!To start using your cluster, you need to run the following as a regular user:mkdir -p $HOME/.kubesudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/configsudo chown $(id -u):$(id -g) $HOME/.kube/configThen you can join any number of edge-nodes by running the following on each as root:yurtctl join 111.32.157.130:6443 --token tfdxae.lvmb7orduikbyjqu \--discovery-token-ca-cert-hash sha256:0e1faf696fe976a7b28c03e0dece429c85d72e6e1e6bc2dd1ac3d30d0416f3f0 --node-type=edge-nodeAnd you can join any number of cloud-nodes by running the following on each as root:yurtctl join 111.32.157.130:6443 --token tfdxae.lvmb7orduikbyjqu \--discovery-token-ca-cert-hash sha256:0e1faf696fe976a7b28c03e0dece429c85d72e6e1e6bc2dd1ac3d30d0416f3f0 --node-type=cloud-node

根據提示,執行如下命令,拷貝證書到相應的目錄,就可以使用 kubectl 操作集群

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

在 master 節點上,查看 master 節點的狀態

root@master:~# kubectl get nodes NAME STATUS ROLES AGE VERSION master Ready <none> 50s v1.18.8

查看 master 節點組件是否 Running

root@master:~# kubectl get pods -A NAMESPACE NAME READY STATUS RESTARTS AGE kube-system controlplane-master 4/4 Running 0 55s kube-system coredns-546565776c-88hs6 1/1 Running 0 46s kube-system coredns-546565776c-v5wxb 1/1 Running 0 46s kube-system kube-flannel-ds-h6qqc 1/1 Running 0 45s kube-system kube-proxy-6rnq2 1/1 Running 0 45s kube-system yurt-app-manager-75b7f76546-6dsw9 1/1 Running 0 45s kube-system yurt-app-manager-75b7f76546-x6wzm 1/1 Running 0 45s kube-system yurt-controller-manager-697877d548-kd5xf 1/1 Running 0 46s kube-system yurt-tunnel-server-bc5cb5bf-xxqgj 1/1 Running 0 46s

其中,各個組件的功能如下:

  • controlplane為 all-in-one 的 Kubernetes 管控組件,為了便于理解 OpenYurt 與 Kubernetes 的關系,yurtctl init將 Kubernetes 的管控組件以黑盒的形式部署在同一個 Pod 中。
  • yurt-app-manager為 OpenYurt 的單元化組件,提供 workload 的單元化部署、運維等能力;
  • yurt-controller-manager為節點生命周期管理組件,與邊緣節點上的 yurt-hub 配合實現邊緣節點的自治功能;
  • yurt-tunnel-server為云邊運維通道的 server 端,與邊緣節點上的yurt-tunnel-agent配合實現從云到邊的運維能力。

一鍵接入云端節點

云端節點用來部署 OpenYurt 相關的系統組件。在 yurtctl 中,提供了 join 子命令,用于向 OpenYurt 集群中增加云端節點。此外,在用 yurtctl init 初始化 master 節點時,會將 master 節點也作為一個云端節點使用。如果需要增加新的云端節點,可以使用 init 的輸出,拷貝云端節點接入指令到需要添加的云端節點上執行。

root@cloud-node:~#./yurtctl join 111.32.157.130:6443 --token vowclg.k7059m0f0qbcebpg --discovery-token-ca-cert-hash sha256:30846295ea024260bc3c4988507c4408e8756ca5440221e109fe8167f636f125 --node-type=cloud-node

接入命令中指定了 master 節點的地址,以及接入認證需要的 token 和要接入的節點類型(cloud-node),執行成功輸出如下

This node has joined the cluster: * Certificate signing request was sent to apiserver and a response was received. * The Kubelet was informed of the new secure connection details.Run 'kubectl get nodes' on the control-plane to see this node join the cluster.

在 master 節點上查看剛接入的云端節點狀態是否 Ready

root@master:~# kubectl get nodes -l openyurt.io/is-edge-worker=false NAME STATUS ROLES AGE VERSION cloud-node Ready <none> 5m4s v1.18.8 master Ready <none> 9m40s v1.18.8

一鍵接入邊緣節點

邊緣節點作為 OpenYurt 集群實際部署業務的節點,通常部署在用戶的內網環境,與管控組件的網絡連接通常不穩定。因此,邊緣節點上需要部署節點自治組件 yurt-hub 以及云邊運維組件 yurt-tunnel-agent。在 yurtctl 中,提供了 join 子命令,用于向 OpenYurt 集群中添加邊緣節點。使用 init 中的輸出命令,拷貝邊緣節點接入指令到需要添加的邊緣節點上執行。

root@edge-node:~# ./yurtctl join 111.32.157.130:6443 --token vowclg.k7059m0f0qbcebpg --discovery-token-ca-cert-hash sha256:30846295ea024260bc3c4988507c4408e8756ca5440221e109fe8167f636f125 --node-type=edge-node

接入命令中指定了 master 節點的地址,以及接入認證需要的 token 和要接入的節點類型(edge-node),執行成功輸出如下

This node has joined the cluster: * Certificate signing request was sent to apiserver and a response was received. * The Kubelet was informed of the new secure connection details.Run 'kubectl get nodes' on the control-plane to see this node join the cluster.

在master節點上查看剛接入的邊緣節點狀態是否Ready

root@master:~# kubectl get nodes -l openyurt.io/is-edge-worker=true NAME STATUS ROLES AGE VERSION edge-node Ready <none> 26s v1.18.8

查看邊緣節點的組件是否 Running

root@master:~# kubectl get pods -A -o wide | grep edge-node kube-system kube-flannel-ds-tdqtx 1/1 Running 0 58s 103.15.99.183 edge-node <none> <none> kube-system kube-proxy-8r76s 1/1 Running 0 58s 103.15.99.183 edge-node <none> <none> kube-system yurt-hub-edge-node 1/1 Running 0 16s 103.15.99.183 edge-node <none> <none> kube-system yurt-tunnel-agent-v4jwt 1/1 Running 0 38s 103.15.99.183 edge-node <none> <none>

其中,各個邊緣節點上各個組件功能如下:

  • yurt-hub 邊緣節點自治組件,邊緣節點上的組件通過yurt-hub與kube-apiserver交互。當云邊網絡良好時,yurt-hub轉發節點組件的請求到kube-apiserver,并緩存 Response 內容。當云邊斷網時,edge-hub從本地緩存中獲取數據響應邊緣節點組件的請求。
  • yurt-tunnel-agent云邊運維通道客戶端,與yurt-tunnel-server配合,實現從云到邊的運維。
    ?
    經過以上4個步驟,您就可以在本地擁有一套 OpenYurt 集群。如果需要清理 OpenYurt 集群,可以在集群中的每個節點上執行./yurtctl reset。

OpenYurt 背靠原生的 Kubernetes,同時又面向邊緣計算場景。由于 Kubernetes 本身的復雜性,導致很多非原生領域的同學難以上手使用。而 OpenYurt 集群的搭建作為上手的第一步,阻擋了大部分的邊緣計算玩家。為了提升 OpenYurt 的易用性,yurtctl 設計了 init、join、reset、convert 等工具,目的在于幫助用戶快速地在本地搭建 OpenYurt 集群,跨越使用 OpenYurt 的第一步。雖然目前易用性有了很大的提升,但是仍然有很多不足之處。期待社區的同學積極參與,基于 OpenYurt,一起打造更加易用的邊緣云原生基礎設施。

溝通與交流

如果您對于 OpenYurt 有任何疑問,歡迎使用釘釘掃描二維碼或者搜索群號(31993519)加入釘釘交流群。


相關鏈接:
https://github.com/openyurtio/openyurt
https://docs.docker.com/engine/install/

總結

以上是生活随笔為你收集整理的边缘使用 K8s 门槛太高?OpenYurt 这个功能帮你快速搭建集群!的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。