安裝

在安裝 Istio 之前要確保 Kubernetes 集群(僅支持 v1.9.0 及以後版本)已部署並配置好本地的 kubectl 客戶端。比如,使用 minikube:

minikube start --memory=4096 --kubernetes-version=v1.11.1 --vm-driver=hyperkit

下載 Istio

curl -L https://git.io/getLatestIstio | sh -
sudo apt-get install -y jq
ISTIO_VERSION=$(curl -L -s https://api.github.com/repos/istio/istio/releases/latest | jq -r .tag_name)
cd istio-${ISTIO_VERSION}
cp bin/istioctl /usr/local/bin

部署 Istio 服務

初始化 Helm Tiller:

kubectl create -f install/kubernetes/helm/helm-service-account.yaml
helm init --service-account tiller

然後使用 Helm 部署:

kubectl apply -f install/kubernetes/helm/istio/templates/crds.yaml
helm install install/kubernetes/helm/istio --name istio --namespace istio-system \
  --set ingress.enabled=true \
  --set gateways.enabled=true \
  --set galley.enabled=true \
  --set sidecarInjectorWebhook.enabled=true \
  --set mixer.enabled=true \
  --set prometheus.enabled=true \
  --set grafana.enabled=true \
  --set servicegraph.enabled=true \
  --set tracing.enabled=true \
  --set kiali.enabled=false

部署完成後,可以檢查 isotio-system namespace 中的服務是否正常運行:

網格擴展

Istio 還支持管理非 Kubernetes 應用。此時需要在應用所在的 VM 或者物理中部署 Istio,具體步驟請參考 https://istio.io/docs/setup/kubernetes/additional-setup/mesh-expansion/。注意,在部署前需要滿足以下條件

  • 待接入服務器必須能夠通過 IP 接入網格中的服務端點。通常這需要 VPN 或者 VPC 的支持,或者容器網絡爲服務端點提供直接路由(非 NAT 或者防火牆屏蔽)。該服務器無需訪問 Kubernetes 指派的集群 IP 地址。

  • Istio 控制平面服務(Pilot、Mixer、Citadel)以及 Kubernetes 的 DNS 服務器必須能夠從虛擬機進行訪問,通常會使用內部負載均衡器(也可以使用 NodePort)來滿足這一要求,在虛擬機上運行 Istio 組件,或者使用自定義網絡配置。

部署好後,就可以向 Istio 註冊應用,如

Prometheus、Grafana 和 Zipkin

等所有 Pod 啓動後,可以通過 NodePort、負載均衡服務的外網 IP 或者 kubectl proxy 來訪問這些服務。比如通過 kubectl proxy 方式,先啓動 kubectl proxy

通過 http://localhost:8001/api/v1/namespaces/istio-system/services/grafana:3000/proxy/ 訪問 Grafana 服務

通過 http://localhost:8001/api/v1/namespaces/istio-system/services/servicegraph:8088/proxy/ 訪問 ServiceGraph 服務,展示服務之間調用關係圖

  • /force/forcegraph.html As explored above, this is an interactive D3.js visualization.

  • /dotviz is a static Graphviz visualization.

  • /dotgraph provides a DOT serialization.

  • /d3graph provides a JSON serialization for D3 visualization.

  • /graph provides a generic JSON serialization.

通過 http://localhost:8001/api/v1/namespaces/istio-system/services/zipkin:9411/proxy/ 訪問 Zipkin 跟蹤頁面

通過 http://localhost:8001/api/v1/namespaces/istio-system/services/prometheus:9090/proxy/ 訪問 Prometheus 頁面

Last updated