-
應用準備:使用以前springbootapp映象,xjk27400861/springbootapp:42與xjk27400861/springbootapp:43兩個映象,部署兩個版本的應用
-
建立名稱空間,springistiodemo,在k3s叢集的任意一個節點執行
命令:
sudo kubectl create namespace springistiodemo

-
自動注入(給名稱空間打指定標籤,啟用自動注入)
sudo kubectl label namespace springistiodemo istio-injection=enabled

-
檢視標籤狀態
sudo kubectl get ns springistiodemo --show-labels

-
禁用自動注入命令
sudo kubectl label namespace springistiodemo istio-injection=disabled –overwrite

-
啟用名稱空間,自動注入後,rancher介面顯示按鈕為:禁用Istio自動注入

-
手動注入方式,(其他安裝方式),rancher暫未找到執行istioctl命令的視窗
sudo istioctl kube-inject -f springbootapp-2nodes.yaml | sudo kubectl apply -f -
-
新建springbootapp-2nodes.yaml檔案,執行命令部署應用
sudo kubectl create -f springbootapp-2nodes.yaml -n springistiodemo
-
springbootapp-2nodes.yaml檔案內容,2個版本的服務,分別為v1和v2


-
稍等片刻,可以看到兩個服務建立完成

-
建立及部署目標規則springbootapp-destination.yaml
sudo kubectl apply -f springbootapp-destination.yaml -n springistiodemo

-
GateWay建立,供外網訪問
sudo kubectl apply -f springbootapp-vs-v1.yaml -n springistiodemo

-
建立及部署預設路由springbootapp-vs-v1.yaml,訪問都訪問v1版本服務
sudo kubectl apply -f springbootapp-vs-v1.yaml -n springistiodemo

-
輸入命令:sudo kubectl get svc istio-ingressgateway -n istio-system,檢視埠對映,發現31380埠對應80埠

-

-
檢視kiali介面,檢視呼叫路徑,namespace選擇2個istio-system和springistiodemo,發現通過ingressgateway訪問的服務都定位在了v1版本上

-
也可以通過在istio-ingressgateway的service中,新增埠對映,對映到應用上,可以不用80埠;例如:加埠對映8066-8080-31386,同時gateway的yaml檔案,number屬性改為8066,即可通過31386埠,訪問服務(http://ip:31386)
