十三 Istio:Istio項目實際案例——Online Boutique

目錄

  • 一.模塊概覽
  • 二.系統環境
  • 三.創建Kubernetes(k8s)集群
    • 3.1 創建Kubernetes(k8s)集群
    • 3.2 Kubernetes集群環境
  • 四.安裝istio
    • 4.1 安裝Istio
  • 五.部署online Boutique應用
    • 5.1 部署 Online Boutique 應用
  • 六.部署可觀察性工具
    • 6.1 部署可觀察性工具
  • 七.流量路由
    • 7.1 流量路由
  • 八.故障注入
    • 8.1 故障注入
  • 九.彈性
    • 9.1 彈性
一.模塊概覽在本模塊中,我們將部署名為 Online Boutique 的微服務應用程序,試用 Istio 的不同功能 。
Online Boutique 是一個云原生微服務演示應用程序 。Online Boutique 是一個由 10 個微服務組成的應用 。該應用是一個基于 Web 的電子商務應用,用戶可以瀏覽商品,將其添加到購物車,并購買商品 。
二.系統環境服務器版本docker軟件版本Kubernetes(k8s)集群版本Istio軟件版本CPU架構CentOS Linux release 7.4.1708 (Core)Docker version 20.10.12v1.21.9Istio1.14x86_64三.創建Kubernetes(k8s)集群3.1 創建Kubernetes(k8s)集群我們需要一套可以正常運行的Kubernetes集群,關于Kubernetes(k8s)集群的安裝部署,可以查看博客《Centos7 安裝部署Kubernetes(k8s)集群》https://www.cnblogs.com/renshengdezheli/p/16686769.html
3.2 Kubernetes集群環境Kubernetes集群架構:k8scloude1作為master節點,k8scloude2,k8scloude3作為worker節點
服務器操作系統版本CPU架構進程功能描述k8scloude1/192.168.110.130CentOS Linux release 7.4.1708 (Core)x86_64docker , kube-apiserver,etcd , kube-scheduler,kube-controller-manager , kubelet , kube-proxy,coredns,calicok8s master節點k8scloude2/192.168.110.129CentOS Linux release 7.4.1708 (Core)x86_64docker,kubelet,kube-proxy,calicok8s worker節點k8scloude3/192.168.110.128CentOS Linux release 7.4.1708 (Core)x86_64docker , kubelet,kube-proxy,calicok8s worker節點四.安裝istio4.1 安裝IstioIstio最新版本為1.15,因為我們Kubernetes集群版本為1.21.9 , 所以我們選擇安裝Istio 1.14版本 。
[root@k8scloude1 ~]# kubectl get nodeNAMESTATUSROLESAGEVERSIONk8scloude1Readycontrol-plane,master288dv1.21.9k8scloude2Ready<none>288dv1.21.9k8scloude3Ready<none>288dv1.21.9我們將安裝 Istio的demo 配置文件 , 因為它包含所有的核心組件 , 啟用了跟蹤和日志記錄 , 便于學習不同的 Istio 功能 。關于istio的詳細安裝部署,請查看博客《Istio(二):在Kubernetes(k8s)集群上安裝部署istio1.14》https://www.cnblogs.com/renshengdezheli/p/16836404.html
也可以按照如下使用 GetMesh CLI 在Kubernetes集群中安裝 Istio。
下載 GetMesh CLI:
curl -sL https://istio.tetratelabs.io/getmesh/install.sh | bash安裝 Istio:
getmesh istioctl install --set profile=demoIstio安裝完成后,創建一個命名空間online-boutique,新的項目就部署在online-boutique命名空間下,給命名空間online-boutique設置上 istio-injection=enabled 標簽,啟用sidecar 自動注入 。
#創建命名空間online-boutique[root@k8scloude1 ~]# kubectl create ns online-boutiquenamespace/online-boutique created#切換命名空間[root@k8scloude1 ~]# kubens online-boutiqueContext "kubernetes-admin@kubernetes" modified.Active namespace is "online-boutique".#讓命名空間online-boutique啟用sidecar 自動注入[root@k8scloude1 ~]# kubectl label ns online-boutique istio-injection=enablednamespace/online-boutique labeled[root@k8scloude1 ~]# kubectl get ns -l istio-injection --show-labelsNAMESTATUSAGELABELSonline-boutiqueActive16mistio-injection=enabled,kubernetes.io/metadata.name=online-boutique五.部署online Boutique應用5.1 部署 Online Boutique 應用在集群和 Istio 準備好后 , 我們可以克隆 Online Boutique 應用庫了 。istio和k8s集群版本如下:
[root@k8scloude1 ~]# istioctl versionclient version: 1.14.3control plane version: 1.14.3data plane version: 1.14.3 (1 proxies)[root@k8scloude1 ~]# kubectl get nodesNAMESTATUSROLESAGEVERSIONk8scloude1Readycontrol-plane,master283dv1.21.9k8scloude2Ready<none>283dv1.21.9k8scloude3Ready<none>283dv1.21.9使用git克隆代碼倉庫:
#安裝git[root@k8scloude1 ~]# yum -y install git#查看git版本[root@k8scloude1 ~]# git versiongit version 1.8.3.1#創建online-boutique目錄,項目放在該目錄下[root@k8scloude1 ~]# mkdir online-boutique[root@k8scloude1 ~]# cd online-boutique/[root@k8scloude1 online-boutique]# pwd/root/online-boutique#git克隆代碼[root@k8scloude1 online-boutique]# git clone https://github.com/GoogleCloudPlatform/microservices-demo.git正克隆到 'microservices-demo'...remote: Enumerating objects: 8195, done.remote: Counting objects: 100% (332/332), done.remote: Compressing objects: 100% (167/167), done.remote: Total 8195 (delta 226), reused 241 (delta 161), pack-reused 7863接收對象中: 100% (8195/8195), 30.55 MiB | 154.00 KiB/s, done.處理 delta 中: 100% (5823/5823), done.[root@k8scloude1 online-boutique]# lsmicroservices-demo

推薦閱讀