如何利用 kind 與 WSL 2 測試 Open Service Mesh (OSM) 範例應用程式...
source link: https://blog.miniasp.com/post/2020/09/27/Run-Open-Service-Mesh-OSM-Demo-App-in-kind-and-WSL-2
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
昨天在 Kubernetes Summit 2020 主持了一場實戰工作坊,幫助大家體驗 Istio 強大的 Service Mesh 能力。今天在家抽空玩了一下原先由微軟主導的 Open Service Mesh (OSM),這套最近貢獻給 CNCF (雲端原生運算基金會),正式成為 CNCF 沙盒專案的成員之一,十分有發展潛力。本篇文章就帶大家試試這套 SMI 服務網格介面 (Service Mesh Interface) 實作。
前置條件 (Prerequisites)
本篇雖然文章主要採用 Windows 10 與 WSL 2 進行實作,但事實上你只要有 Docker Engine 與 Shell 環境就可以進行操作:
- Windows
- 作業系統:Windows 10 版本 2004 (Build 19041) 以上
- 安裝 Docker Desktop for Windows 穩定版本 (Stable)
- 請先安裝好 Chocolatey 套件管理器
- 執行的 Ubuntu 20.04 LTS 作業系統環境請記得啟用 WSL 2 功能 (Optional)
- 請記得透過
wsl.exe --set-default-version 2
將之後安裝的 Distro 預設都調整為 WSL 2 版本 - 官方文件: Windows Subsystem for Linux Installation Guide for Windows 10
- 可以參考 使用 WSL 2 打造優質的多重 Linux 開發環境 文章進行調整環境
- 可以到 Microsoft Store 安裝 Ubuntu 20.04 LTS 應用程式
- 請記得透過
- macOS
- 作業系統:10.13 以上版本 (Catalina, Mojave, or High Sierra)
- 安裝 Docker Desktop on Mac 穩定版本 (Stable)
- 請先安裝好 Homebrew 套件管理器
- Linux
- 作業系統: Ubuntu 20.04 LTS
- 請參考 Install Docker Engine on Ubuntu 進行安裝
-
安裝各項建置工具 (
make
)sudo apt-get install build-essential -y
-
安裝 Go 建置環境
curl -sLO https://golang.org/dl/go1.15.2.linux-amd64.tar.gz sudo tar -C /usr/local -xzf go1.15.2.linux-amd64.tar.gz export PATH=$PATH:/usr/local/go/bin go version
-
安裝 kind 工具
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.9.0/kind-linux-amd64 chmod +x ./kind sudo mv ./kind /usr/local/bin/kind
-
下載 OSM CLI 工具
curl -sLO https://github.com/openservicemesh/osm/releases/download/v0.4.0/osm-v0.4.0-linux-amd64.tar.gz tar zxvf osm-v0.4.0-linux-amd64.tar.gz --strip-components=1 -C /usr/local/bin/ linux-amd64/osm
-
下載 OSM 專案原始碼
git clone https://github.com/openservicemesh/osm.git cd osm
-
建立 kind 叢集
預設透過以下命令建立的 kind 叢集名稱為
osm
,執行命令為./scripts/kind-with-registry.sh
,他會額外建立一個 Docker Registry 供 kind 叢集使用:make kind-up
如果你想建立含有 Docker Registry 的 kind 叢集,可以參考 kind 網站的 Local Registry 文件。
建立完成後,你可以用
kind get clusters
查詢所有已建立的 kind 叢集名稱。 -
建立範例應用程式
先準備好
.env
環境變數檔 (Declare default environment variables in file)cat .env.example > .env
請修改
.env
檔案的內容,特別將export ENABLE_GRAFANA=true
環境變數啟用(請取消這行的註解)正式建立 OSM 內建的 Demo 應用程式
make kind-demo
上述命令也會包含
make kind-up
動作,但如果你已經建立,他會自動跳過建立 kind 叢集的動作。 -
建立 Web UI 連線
預設該應用程式所有的 Service Type 都是以
ClusterIP
為主,並沒有對外連接的端點。因此你可以透過kubectl port-forward
命令,快速建立本機網路可連接的端點。以下是 OSM 內建的命令,可一次開啟所有 Web UI 的連線。相關連結:Use Port Forwarding to Access Applications in a Cluster
/scripts/port-forward-all.sh
-
刪除 kind 叢集
make kind-reset
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK