1. 程式人生 > >Google、IBM和Lyft開源的微服務管理框架Istio安裝文件

Google、IBM和Lyft開源的微服務管理框架Istio安裝文件

威海朱口

(題圖:威海東部海灣 May 28,2017)

前言

本文根據官網的文件整理而成,步驟包括安裝istio 0.1.5並建立一個bookinfo的微服務來測試istio的功能。

文中使用的yaml檔案可以在kubernetes-handbookmanifests/istio目錄中找到,所有的映象都換成了我的私有映象倉庫地址,請根據官網的映象自行修改。

安裝環境

  • CentOS 7.3.1611
  • Docker 1.12.6
  • Kubernetes 1.6.0

安裝

1.下載安裝包

下載Linux版本的當前最新版安裝包

wget https://github.com/istio
/istio/releases/download/0.1.5/istio-0.1.5-linux.tar.gz

2.解壓

解壓後,得到的目錄結構如下:

.
├── bin
│   └── istioctl
├── install
│   └── kubernetes
│       ├── addons
│       │   ├── grafana.yaml
│       │   ├── prometheus.yaml
│       │   ├── servicegraph.yaml
│       │   └── zipkin.yaml
│       ├── istio-auth.yaml
│       ├── istio-rbac
-alpha.yaml │ ├── istio-rbac-beta.yaml │ ├── istio.yaml │ ├── README.md │ └── templates │ ├── istio-auth │ │ ├── istio-auth-with-cluster-ca.yaml │ │ ├── istio-cluster-ca.yaml │ │ ├── istio-egress-auth.yaml │ │ ├── istio-ingress
-auth.yaml │ │ └── istio-namespace-ca.yaml │ ├── istio-egress.yaml │ ├── istio-ingress.yaml │ ├── istio-manager.yaml │ └── istio-mixer.yaml ├── istio.VERSION ├── LICENSE └── samples ├── apps │ ├── bookinfo │ │ ├── bookinfo.yaml │ │ ├── cleanup.sh │ │ ├── destination-ratings-test-delay.yaml │ │ ├── loadbalancing-policy-reviews.yaml │ │ ├── mixer-rule-additional-telemetry.yaml │ │ ├── mixer-rule-empty-rule.yaml │ │ ├── mixer-rule-ratings-denial.yaml │ │ ├── mixer-rule-ratings-ratelimit.yaml │ │ ├── README.md │ │ ├── route-rule-all-v1.yaml │ │ ├── route-rule-delay.yaml │ │ ├── route-rule-reviews-50-v3.yaml │ │ ├── route-rule-reviews-test-v2.yaml │ │ ├── route-rule-reviews-v2-v3.yaml │ │ └── route-rule-reviews-v3.yaml │ ├── httpbin │ │ ├── httpbin.yaml │ │ └── README.md │ └── sleep │ ├── README.md │ └── sleep.yaml └── README.md 11 directories, 41 files

從檔案裡表中可以看到,安裝包中包括了kubernetes的yaml檔案,示例應用和安裝模板。

3.安裝istioctl

./bin/istioctl拷貝到你的$PATH目錄下。

4.檢查RBAC

因為我們安裝的kuberentes版本是1.6.0預設支援RBAC,這一步可以跳過。如果你使用的其他版本的kubernetes,請參考官方文件操作。

執行以下命令,正確的輸出是這樣的:

$ kubectl api-versions | grep rbac
rbac.authorization.k8s.io/v1alpha1
rbac.authorization.k8s.io/v1beta1

5.建立角色繫結

$ kubectl create -f install/kubernetes/istio-rbac-beta.yaml
clusterrole "istio-manager" created
clusterrole "istio-ca" created
clusterrole "istio-sidecar" created
clusterrolebinding "istio-manager-admin-role-binding" created
clusterrolebinding "istio-ca-role-binding" created
clusterrolebinding "istio-ingress-admin-role-binding" created
clusterrolebinding "istio-sidecar-role-binding" created

注意:官網的安裝包中的該檔案中存在RoleBinding錯誤,應該是叢集級別的clusterrolebinding,而release裡的程式碼只是普通的rolebinding,檢視該Issue Istio manager cannot list of create k8s TPR when RBAC enabled #327

6.安裝istio核心元件

用到的映象有:

docker.io/istio/mixer:0.1.5
docker.io/istio/manager:0.1.5
docker.io/istio/proxy_debug:0.1.5

注意:本文中用到的所有yaml檔案中的type: LoadBalancer去掉,使用預設的ClusterIP,然後配置Traefik ingress,就可以在叢集外部訪問。請參考安裝Traefik ingress

kubectl apply -f install/kubernetes/istio.yaml

7.安裝監控外掛

用到的映象有:

docker.io/istio/grafana:0.1.5
quay.io/coreos/prometheus:v1.1.1
gcr.io/istio-testing/servicegraph:latest
docker.io/openzipkin/zipkin:latest

為了方便下載,其中兩個映象我備份到了時速雲:

index.tenxcloud.com/jimmy/prometheus:v1.1.1
index.tenxcloud.com/jimmy/servicegraph:latest

安裝外掛

kubectl apply -f install/kubernetes/addons/prometheus.yaml
kubectl apply -f install/kubernetes/addons/grafana.yaml
kubectl apply -f install/kubernetes/addons/servicegraph.yaml
kubectl apply -f install/kubernetes/addons/zipkin.yaml

在traefik ingress中增加增加以上幾個服務的配置,同時增加istio-ingress配置。

    - host: grafana.istio.io
      http:
        paths:
        - path: /
          backend:
            serviceName: grafana
            servicePort: 3000
    - host: servicegraph.istio.io
      http:
        paths:
        - path: /
          backend:
            serviceName: servicegraph
            servicePort: 8088
    - host: prometheus.istio.io
      http:
        paths:
        - path: /
          backend:
            serviceName: prometheus
            servicePort: 9090
    - host: zipkin.istio.io
      http:
        paths:
        - path: /
          backend:
            serviceName: zipkin
            servicePort: 9411
    - host: ingress.istio.io
      http:
        paths:
        - path: /
          backend:
            serviceName: istio-ingress
            servicePort: 80

測試

我們使用Istio提供的測試應用bookinfo微服務來進行測試。

該微服務用到的映象有:

istio/examples-bookinfo-details-v1
istio/examples-bookinfo-ratings-v1
istio/examples-bookinfo-reviews-v1
istio/examples-bookinfo-reviews-v2
istio/examples-bookinfo-reviews-v3
istio/examples-bookinfo-productpage-v1

該應用架構圖如下:

BookInfo Sample應用架構圖

部署應用

kubectl create -f <(istioctl kube-inject -f samples/apps/bookinfo/bookinfo.yaml)

在本機的/etc/hosts下增加VIP節點和ingress.istio.io的對應資訊。具體步驟參考:邊緣節點配置

監控

不斷重新整理productpage頁面,將可以在以下幾個監控中看到如下介面。

Grafana頁面

Istio Grafana介面

Prometheus頁面

Prometheus頁面

Zipkin頁面

Zipkin頁面

ServiceGraph頁面

可以用來檢視服務間的依賴關係。

ServiceGraph頁面

更進一步

BookInfo示例中有三個版本的reviews,可以使用istio來配置路由請求,將流量分攤到不同版本的應用上。參考Configuring Request Routing

還有一些更高階的功能,我們後續將進一步探索。

參考