官方文檔:git
https://preliminary.istio.io/zh/docs/setup/kubernetes/quick-start/github
1.下載 Istio 發佈包docker
curl -L https://git.io/getLatestIstio | sh -api
2.拉取相關鏡像app
----------------拉取相關鏡像----------- docker pull istio/pilot:1.0.1 docker tag istio/pilot:1.0.1 gcr.io/istio-release/pilot:1.0.1 docker rmi istio/pilot:1.0.1 docker pull istio/grafana:1.0.1 docker tag istio/grafana:1.0.1 gcr.io/istio-release/grafana:1.0.1 docker rmi istio/grafana:1.0.1 docker pull istio/citadel:1.0.1 docker tag istio/citadel:1.0.1 gcr.io/istio-release/citadel:1.0.1 docker rmi istio/citadel:1.0.1 docker pull istio/galley:1.0.1 docker tag istio/galley:1.0.1 gcr.io/istio-release/galley:1.0.1 docker rmi istio/galley:1.0.1 docker pull istio/policy:1.0.1 docker tag istio/policy:1.0.1 gcr.io/istio-release/policy:1.0.1 docker rmi istio/policy:1.0.1 docker pull istio/sidecar_injector:1.0.1 docker tag istio/sidecar_injector:1.0.1 gcr.io/istio-release/sidecar_injector:1.0.1 docker rmi istio/sidecar_injector:1.0.1 docker pull istio/mixer:1.0.1 docker tag istio/mixer:1.0.1 gcr.io/istio-release/mixer:1.0.1 docker rmi istio/mixer:1.0.1 docker pull istio/servicegraph:1.0.1 docker tag istio/servicegraph:1.0.1 gcr.io/istio-release/servicegraph:1.0.1 docker rmi istio/servicegraph:1.0.1 docker pull istio/proxy_init:1.0.1 docker tag istio/proxy_init:1.0.1 gcr.io/istio-release/proxy_init:1.0.1 docker rmi istio/proxy_init:1.0.1
3.安裝 Istio 而不啓用 Sidecar 之間的雙向 TLS 驗證負載均衡
kubectl apply -f install/kubernetes/istio-demo.yamlcurl
4.檢查相關鏡像是否啓動正常、確認部署結果。ide
確認下列 Kubernetes 服務已經部署:istio-pilot、istio-ingressgateway、istio-egressgateway、istio-policy、istio-telemetry、prometheus、istio-galley 以及可選的 istio-sidecar-injector。 $ kubectl get svc -n istio-system NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE istio-citadel ClusterIP 10.47.247.12 <none> 8060/TCP,9093/TCP 7m istio-egressgateway ClusterIP 10.47.243.117 <none> 80/TCP,443/TCP 7m istio-galley ClusterIP 10.47.254.90 <none> 443/TCP 7m istio-ingress LoadBalancer 10.47.244.111 35.194.55.10 80:32000/TCP,443:30814/TCP 7m istio-ingressgateway LoadBalancer 10.47.241.20 130.211.167.230 80:31380/TCP,443:31390/TCP,31400:31400/TCP 7m istio-pilot ClusterIP 10.47.250.56 <none> 15003/TCP,15005/TCP,15007/TCP,15010/TCP,15011/TCP,8080/TCP,9093/TCP 7m istio-policy ClusterIP 10.47.245.228 <none> 9091/TCP,15004/TCP,9093/TCP 7m istio-sidecar-injector ClusterIP 10.47.245.22 <none> 443/TCP 7m istio-statsd-prom-bridge ClusterIP 10.47.252.184 <none> 9102/TCP,9125/UDP 7m istio-telemetry ClusterIP 10.47.250.107 <none> 9091/TCP,15004/TCP,9093/TCP,42422/TCP 7m prometheus ClusterIP 10.47.253.148 <none> 9090/TCP 7m 若是該集羣在不支持外部負載均衡器的環境中運行(例如 minikube),istio-ingressgateway 的 EXTERNAL-IP 將會顯示爲 <pending> 狀態。這種狀況下,只能經過服務的 NodePort,或者使用 port-forwarding 方式來訪問服務。 確保全部相應的 Kubernetes pod 都已被部署且全部的容器都已啓動並正在運行:istio-pilot-*、istio-ingressgateway-*、istio-egressgateway-*、istio-policy-*、istio-telemetry-*、istio-citadel-*、prometheus-*、istio-galley-* 以及 istio-sidecar-injector-*(可選)。 $ kubectl get pods -n istio-system NAME READY STATUS RESTARTS AGE istio-citadel-75c88f897f-zfw8b 1/1 Running 0 1m istio-egressgateway-7d8479c7-khjvk 1/1 Running 0 1m istio-galley-6c749ff56d-k97n2 1/1 Running 0 1m istio-ingress-7f5898d74d-t8wrr 1/1 Running 0 1m istio-ingressgateway-7754ff47dc-qkrch 1/1 Running 0 1m istio-policy-74df458f5b-jrz9q 2/2 Running 0 1m istio-sidecar-injector-645c89bc64-v5n4l 1/1 Running 0 1m istio-statsd-prom-bridge-949999c4c-xjz25 1/1 Running 0 1m istio-telemetry-676f9b55b-k9nkl 2/2 Running 0 1m prometheus-86cb6dd77c-hwvqd 1/1 Running 0 1m
五、部署應用ui
https://preliminary.istio.io/zh/docs/examples/bookinfo/url
kubectl apply -f <(istioctl kube-inject -f samples/bookinfo/platform/kube/bookinfo.yaml)
給應用定義 Ingress gateway:
kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml
確認全部的服務和 Pod 都已經正確的定義和啓動: $ kubectl get services NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE details 10.0.0.31 <none> 9080/TCP 6m kubernetes 10.0.0.1 <none> 443/TCP 7d productpage 10.0.0.120 <none> 9080/TCP 6m ratings 10.0.0.15 <none> 9080/TCP 6m reviews 10.0.0.170 <none> 9080/TCP 6m 還有: $ kubectl get pods NAME READY STATUS RESTARTS AGE details-v1-1520924117-48z17 2/2 Running 0 6m productpage-v1-560495357-jk1lz 2/2 Running 0 6m ratings-v1-734492171-rnr5l 2/2 Running 0 6m reviews-v1-874083890-f0qf0 2/2 Running 0 6m reviews-v2-1343845940-b34q5 2/2 Running 0 6m reviews-v3-1813607990-8ch52
6.訪問
http://masterIp:31380/productpage
7.遙測監控相關訪問
7.1 將配置文件install/kubernetes/istio-demo.yaml中相關service修改成 type: NodePort ,供外部訪問
[root@dev-es-16-102 istio-1.0.1]# kubectl get svc -n istio-system NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE grafana NodePort 10.68.118.91 <none> 3000:22585/TCP 1m istio-citadel ClusterIP 10.68.79.90 <none> 8060/TCP,9093/TCP 1m istio-egressgateway ClusterIP 10.68.131.232 <none> 80/TCP,443/TCP 1m istio-galley ClusterIP 10.68.100.252 <none> 443/TCP,9093/TCP 1m istio-ingressgateway LoadBalancer 10.68.168.52 <pending> 80:31380/TCP,443:31390/TCP,31400:31400/TCP,15011:31185/TCP,8060:20179/TCP,853:20917/TCP,15030:28634/TCP,15031:29370/TCP 1m istio-pilot ClusterIP 10.68.199.239 <none> 15010/TCP,15011/TCP,8080/TCP,9093/TCP 1m istio-policy ClusterIP 10.68.40.65 <none> 9091/TCP,15004/TCP,9093/TCP 1m istio-sidecar-injector ClusterIP 10.68.85.208 <none> 443/TCP 1m istio-statsd-prom-bridge ClusterIP 10.68.231.8 <none> 9102/TCP,9125/UDP 1m istio-telemetry ClusterIP 10.68.32.204 <none> 9091/TCP,15004/TCP,9093/TCP,42422/TCP 1m jaeger-agent ClusterIP None <none> 5775/UDP,6831/UDP,6832/UDP 1m jaeger-collector ClusterIP 10.68.11.34 <none> 14267/TCP,14268/TCP 1m jaeger-query ClusterIP 10.68.98.159 <none> 16686/TCP 1m prometheus NodePort 10.68.146.157 <none> 9090:21774/TCP 1m servicegraph ClusterIP 10.68.184.201 <none> 8088/TCP 1m tracing ClusterIP 10.68.39.252 <none> 80/TCP 1m zipkin NodePort 10.68.140.109 <none> 9411:22366/TCP 1m
7.2 能夠配置 Ingress gateway 供外部訪問。好比traefik。不要經過istio-ingressgateway 作代理,由於經過istio-ingressgateway 作代理的入口的話,pod還須要而外的注入
apiVersion: extensions/v1beta1 kind: Ingress metadata: name: prometheus namespace: istio-system spec: rules: - host: prometheus.test.com http: paths: - path: / backend: serviceName: prometheus servicePort: 9090
8.先關命令
kubectl apply -f install/kubernetes/istio-demo.yaml kubectl delete -f install/kubernetes/istio-demo.yaml kubectl get pods -n istio-system kubectl get pods --all-namespaces -o wide kubectl get svc --all-namespaces -o wide kubectl describe pod grafana-6f6dff9986-vxqj4 -n istio-system kubectl apply -f <(/root/istio/istio-1.0.1/bin/istioctl kube-inject -f samples/bookinfo/platform/kube/bookinfo.yaml) kubectl delete -f samples/bookinfo/platform/kube/bookinfo.yaml kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml kubectl delete -f samples/bookinfo/networking/bookinfo-gateway.yaml kubectl apply -f samples/bookinfo/networking/grafana-gateway.yaml kubectl delete -f samples/bookinfo/networking/grafana-gateway.yaml ------istioctl-------------------------------------- bin/istioctl get virtualservices kubectl get gateway bin/istioctl get virtualservices -n istio-system bin/istioctl delete virtualservice grafana -n istio-system http://10.10.16.102:31380/productpage