安裝Istio
下載istio
1 | curl -L https://git.io/getLatestIstio | sh - |
安裝istio
本文示範安裝Istio的時候不啟用sidecar之間的TLS雙向認證,使用istio-demo.yaml
由於是本機環境,需將yaml檔內istio-ingressgateway和tracing服務改為NodePort
1 | kubectl apply -f install/kubernetes/istio-demo.yaml |
若要啟用,請佈署istio-auth.yaml1
kubectl apply -f install/kubernetes/istio-demo-auth.yaml
驗證安裝是否成功
確保部署了以下Kubernetes服務,用指令查看service1
kubectl get svc -n istio-system
用指令查看pod1
kubectl get pods -n istio-system
Istio Sample - bookinfo
sidecar injection
1 | kubectl apply -f <(istioctl kube-inject -f samples/bookinfo/kube/bookinfo.yaml) |
配置bookinfo-gateway
與ingress功能類似,較不同的是可對外暴露一個不存在的”虛擬服務”,然後將該”虛擬服務”映射到istio中的Service上。1
istioctl create -f samples/bookinfo/routing/bookinfo-gateway.yaml
查看是否佈署成功
1 | kubectl get services |
1
kubectl get po
Productpage
因前面有設定bookinfo的gateway,所以只需要連istio-ingressgateway的IP:NodePort/productpage即可連到Bookinfo Sample
查看svc1
kubectl get svc -n istio-system
可以看到ingressgateway的NodePort為31380
在瀏覽器打上masterIP:31380/productpage
LoadBalance
可以試著重複刷新productpage頁面,會發現有不同的版本(無星、紅星、黑星),這是因為當時佈署productpage時一次佈署了3個不同的reviews版本,所以在reviews區域會看到不同的顯示。
Istio 插件
在Istio0.8.0版本中,佈署istio的yaml檔內直接將grafana、prometheus等服務一倂佈署,我們可以為這些插件設定ingress,方便訪問頁面。
需先佈署ingress controller
請參閱 K8S-Ingress
設定ingress
新增一個istio-ingress.yaml1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: istio-ingress
#namespace: kube-system
#annotations:
# ingress.kubernetes.io/force-ssl-redirect: "false"
# ingress.kubernetes.io/ssl-redirect: "false"
spec:
rules:
- 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-ingressgateway
servicePort: 80
佈署istio-ingress1
kubectl create -f istio-ingress.yaml -n istio-system
查看ingress1
kubectl describe ing istio-ingress -n istio-system
剛剛在yaml檔裡設的規則,可以很清楚的看到。
用Domain訪問
接下來就可以用剛剛設到的domain訪問頁面囉
grafana
prometheus
servicegraph
訪問servicegraph有不同的端點,呈現不同的服務圖。
/dotviz
/force/forcegraph.html
/force/forcegraph.html 交互式D3.js可視化
/dotvizis 靜態的Graphviz可視化
/dotgraph DOT序列化
/d3graph 為D3可視化提供了JSON序列
/graph 通用的jason序列