<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # SOFAMesh中運行Dubbo on x-protocol **注意:本書中的 Service Mesh 章節已不再維護,請轉到 [istio-handbook](https://jimmysong.io/istio-handbook) 中瀏覽。** 原文作者:彭澤文,阿里巴巴UC事業部高級開發工程師,有改動。 X-protocol 的定位是云原生、高性能、低侵入性的通用 Service Mesh 落地方案,依托 Kubernetes 基座,利用其原生的服務注冊和服務發現機制,支持各種私有 RPC 協議低成本、易擴展的接入,快速享受 Service Mesh 所帶來的紅利。 本文將以 [Dubbo](https://dubbo.incubator.apache.org/) 為例,演示 Dubbo on x-protocol 場景下 Service Mesh 路由功能,涵蓋 Version route 、Weighted route 功能。 關于 x-protocol 的介紹請參考 [螞蟻金服開源的 SOFAMesh 的通用協議擴展解析](http://www.servicemesher.com/blog/ant-financial-sofamesh-common-protocol-extension/)。 ## 前期準備 1. 部署 Kubernetes 集群,建議使用 https://github.com/rootsongjc/kubernetes-vagrant-centos-cluster 2. 安裝 kubectl 命令行工具,請參考 [https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl) 3. 安裝 VM Driver,推薦安裝 Virtual Box、Mac 用戶也可以選擇 hyperkit 4. 了解 Istio Traffic Management 相關概念,相關鏈接:[https://istio.io/zh/docs/tasks/traffic-management/](https://istio.io/zh/docs/tasks/traffic-management/) ## 部署 先看部署效果圖: ![Mosn x-protocol部署圖.png | left | 747x382](https://cdn.nlark.com/yuque/0/2018/png/151172/1536291419546-2aa160de-69cd-497f-a280-fae20a1f87a3.png "") 本示例中dubbo-consumer的部署方式采用直連模式,即不走注冊中心,完全依托kubernetes平臺提供的服務注冊及服務發現能力。 ### 1. 安裝 Kubernetes 安裝 kubectl 命令行工具 推薦使用 Kubernetes 1.10 版本,并使用合適的 VM Driver,推薦使用默認的 VirtualBox。 ```bash minikube start --memory=8192 --cpus=4 --kubernetes-version=v1.10.0 \ --extra-config=controller-manager.cluster-signing-cert-file="/var/lib/localkube/certs/ca.crt" \ --extra-config=controller-manager.cluster-signing-key-file="/var/lib/localkube/certs/ca.key" ``` Mac OSX 用戶使用的 hyperkit 需要特別指定: ```bash minikube start --memory=8192 --cpus=4 --kubernetes-version=v1.10.0 \ --extra-config=controller-manager.cluster-signing-cert-file="/var/lib/localkube/certs/ca.crt" \ --extra-config=controller-manager.cluster-signing-key-file="/var/lib/localkube/certs/ca.key" \ --vm-dirver=hyperkit ``` 等待 Kubernetes 啟動完畢,通過 kubectl 命令檢查 ```bash kubectl get pods --namespace=kube-system ``` ### 2. 部署 SOFAMesh 本示例演示從源代碼的 master 分支直接安裝最新的 SOFAMesh,安裝過程使用 Helm 完成。 從 GitHub 拉取最新代碼: ```bash git clone https://github.com/alipay/sofa-mesh.git cd sofa-mesh ``` 創建 SOFAMesh 需要的 CRD: ```bash kubectl apply -f install/kubernetes/helm/istio/templates/crds.yaml kubectl apply -f install/kubernetes/helm/istio/charts/certmanager/templates/crds.yaml ``` 使用 Helm 安裝 SOFAMesh: ```bash kubectl apply -f install/kubernetes/helm/helm-service-account.yaml helm init --service-account tiller helm install install/kubernetes/helm/istio --name istio --namespace istio-system ``` 安裝 istioctl 命令行工具: ```bash # 使用 make 工具安裝 istioctl make istioctl-install ``` ### 3. 創建示例的命名空間 以下示例都將運行在 e2e-dubbo 命名空間下,如無 e2e-dubbo 命名空間,需先創建該命名空間: ```bash kubectl apply -f samples/e2e-dubbo/platform/kube/e2e-dubbo-ns.yaml ``` ### 4. 注入 SOFAMosn 部署 dubbo-consumer 和 dubbo-provider,部署前需要先使用 istioctl 進行 sidecar 注入,以下示例采用手動注入方式,也可以通過 istio namespace inject 功能來自動注入。 ```bash # mosn sidecar inject and deploy kubectl apply -f <(istioctl kube-inject -f samples/e2e-dubbo/platform/kube/dubbo-consumer.yaml) kubectl apply -f <(istioctl kube-inject -f samples/e2e-dubbo/platform/kube/dubbo-provider-v1.yaml) kubectl apply -f <(istioctl kube-inject -f samples/e2e-dubbo/platform/kube/dubbo-provider-v2.yaml) ``` ### 5. 部署示例應用 部署 dubbo consumer service 及 dubbo provider service。 ```bash # http service for dubbo consumer kubectl apply -f samples/e2e-dubbo/platform/kube/dubbo-consumer-service.yaml # dubbo provider service kubectl apply -f samples/e2e-dubbo/platform/kube/dubbo-provider-service.yaml ``` 檢查部署狀態: ```bash #kubectl get pods -n e2e-dubbo NAME READY STATUS RESTARTS AGE e2e-dubbo-consumer-589d8c465d-cp7cx 2/2 Running 0 13s e2e-dubbo-provider-v1-649d7cff94-52gfd 2/2 Running 0 13s e2e-dubbo-provider-v2-5f7d5ff648-m6c45 2/2 Running 0 13s #kubectl get svc -n e2e-dubbo NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE e2e-dubbo-consumer ClusterIP 192.168.1.7 <none> 8080/TCP 10s e2e-dubbo-provider ClusterIP 192.168.1.62 <none> 12345/TCP 10s ``` e2e-dubbo-consumer 是一個 Dubbo 客戶端應用,它暴露了一個 8080 端口的 HTTP 服務,方便我們進行驗證,e2e-dubbo-provider 是一個 Dubbo 應用。 當 e2e-dubbo-consumer 通過 12345 端口調用 e2e-dubbo-provider 時,流量會被 IPtable 規則攔截,導流給 SOFAMosn。 ## 驗證路由能力 本示例將驗證 Version route 和 Weighted route 能力。 ### 1. 驗證 Version Route 能力 本例將演示控制 dubbo-consumer的所有請求指向 dubo-provider-v1 配置DestinationRule: ```bash istioctl create -f samples/e2e-dubbo/platform/kube/dubbo-consumer.destinationrule.yaml ``` `dubbo-consumer.destinationrule.yaml` 內容如下: ```yaml apiVersion: networking.istio.io/v1alpha3 kind: DestinationRule metadata: name: e2e-dubbo-provider namespace: e2e-dubbo spec: host: e2e-dubbo-provider subsets: - name: v1 labels: ver: v1 - name: v2 labels: ver: v2 ``` 配置VirtualService: ```bash istioctl create -f samples/e2e-dubbo/platform/kube/dubbo-consumer.version.vs.yaml ``` `dubbo-consumer.version.vs.yaml` 內容如下: ```yaml apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: e2e-dubbo-provider namespace: e2e-dubbo spec: hosts: - e2e-dubbo-provider http: - route: - destination: host: e2e-dubbo-provider subset: v1 ``` 路由策略已經生效,可以 http 請求 dubbo consumer 來觸發 rpc 請求觀察效果,由于使用 Minikube 的關系,需要啟動一個 Pod 用來測試 ```bash # 啟動一個 busybox Pod 并登陸 kubectl run -i -t busybox --image=yauritux/busybox-curl --restart=Never # 使用 e2e-dubbo-consumer 的域名訪問服務 curl e2e-dubbo-consumer.e2e-dubbo.svc.cluster.local:8080/sayHello?name=dubbo-mosn ``` 清理路由策略: ```bash istioctl delete -f samples/e2e-dubbo/platform/kube/dubbo-consumer.destinationrule.yaml istioctl delete -f samples/e2e-dubbo/platform/kube/dubbo-consumer.version.vs.yaml ``` 退出 Minikube shell ### 2. 驗證 Weight Route 能力 本例將演示控制 dubbo-consumer 的請求指向 dubo-provider-v1,dubo-provider-v2。并控制流量分配比例為 v1:20%,v2:80%。 配置DestinationRule: ```bash # 如果在上一示例中已經創建好了,請跳過這一步 istioctl create -f samples/e2e-dubbo/platform/kube/dubbo-consumer.destinationrule.yaml ``` `dubbo-consumer.destinationrule.yaml` 內容如下: ```yaml apiVersion: networking.istio.io/v1alpha3 kind: DestinationRule metadata: name: e2e-dubbo-provider namespace: e2e-dubbo spec: host: e2e-dubbo-provider subsets: - name: v1 labels: ver: v1 - name: v2 labels: ver: v2 ``` 配置 VirtualService: ```bash istioctl create -f samples/e2e-dubbo/platform/kube/dubbo-consumer.weight.vs.yaml ``` `dubbo-consumer.weight.vs.yaml` 內容如下: ```yaml apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: e2e-dubbo-provider namespace: e2e-dubbo spec: hosts: - e2e-dubbo-provider http: - route: - destination: host: e2e-dubbo-provider subset: v1 weight: 20 - destination: host: e2e-dubbo-provider subset: v2 weight: 80 ``` 路由策略已經生效,可以 http 請求 dubbo consumer 來觸發 rpc 請求觀察效果: ```bash # 啟動一個 busybox Pod 并登陸 kubectl run -i -t busybox --image=yauritux/busybox-curl --restart=Never # 使用 e2e-dubbo-consumer 的域名訪問服務 curl e2e-dubbo-consumer.e2e-dubbo.svc.cluster.local:8080/sayHello?name=dubbo-mosn ``` 清理路由策略: ```bash istioctl delete -f samples/e2e-dubbo/platform/kube/dubbo-consumer.destinationrule.yaml istioctl delete -f samples/e2e-dubbo/platform/kube/dubbo-consumer.weight.vs.yaml ``` SOFAMesh Github 地址:https://github.com/alipay/sofa-mesh ## 參考文檔 - [螞蟻金服開源的 SOFAMesh 的通用協議擴展解析 - servicemesher.com](http://www.servicemesher.com/blog/ant-financial-sofamesh-common-protocol-extension/) - [在 Kubernetes 中快速開始 - istio.io](https://preliminary.istio.io/zh/docs/setup/kubernetes/quick-start/) - [注入 Istio sidecar - istio.io](https://preliminary.istio.io/zh/docs/setup/kubernetes/sidecar-injection/) - [Dubbo quick start - dubbo.incubator.apache.org](https://dubbo.incubator.apache.org/en-us/docs/user/quick-start.html) - 關于SOFAMesh的更多信息請訪問 http://www.sofastack.tech
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看