Istio 1.8— 环境搭建
Istio 是一个服务治理的开放平台,1.8 与前版本的命令不太一样;官网给了一个安装流程 Getting Started,
安装过程
下载 istio 1.8 版本
istio-1.8.1/
├── bin
├── LICENSE
├── manifests
├── README.md
├── samples
└── tools
设置 istioctl
cp bin/istioctl /usr/local/bin/
cp tools/istioctl.bash ~/.istioctl.bash
source ~/.istioctl.bash
安装 profile
可以看到内置的 profile,几个 profile 的区别 config-profiles;安装 demo 的 profile,因为可以有一个 bookinfo
的应用来做为实验,
# istioctl profile list
Istio configuration profiles:
default
demo
empty
minimal
openshift
preview
remote
# istioctl install --set profile=demo
This will install the Istio demo profile with ["Istio core" "Istiod" "Ingress gateways" "Egress gateways"] components into the cluster. Proceed? (y/N) y
Detected that your cluster does not support third party JWT authentication. Falling back to less secure first party JWT. See https://istio.io/v1.8/docs/ops/best-practices/security/#configure-third-party-service-account-tokens for details.
✔ Istio core installed
✔ Istiod installed
✔ Egress gateways installed
✔ Ingress gateways installed
✔ Installation complete
其他配置
配置 istio
允许注入 envoy
的 sidecar
代理
kubectl label namespace default istio-injection=enabled
部署示例 bookinfo
kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml
kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml
kubectl apply -f samples/addons
查看 bookInfo
访问地址:http://10.0.4.144:32351/productpage
# echo $(kubectl get po -l istio=ingressgateway -n istio-system -o jsonpath='{.items[0].status.hostIP}'):$( kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].nodePort}')/productpage
10.0.4.144:32351/productpage
配置 kiali
后台访问地址:http://10.0.4.175:20001/
kubectl -n istio-system port-forward $(kubectl -n istio-system get pod -l app=kiali -o jsonpath={.items[0].metadata.name}) 20001 --address=10.0.4.175
操作
bookInfo
这个应用的详解,里面有几个服务,刷新 http://10.0.4.144:32351/productpage
,打开 kiali 里面的【Graph –> Versiond app graph】视图即可开始查看;
- 微服务 details:页面上会显示书的详情信息,ISBN 等
- 微服务 reviews-v1:当请求这个微服务的时候,页面是没有星,因为服务不会调用 ratings
- 微服务 reviews-v2: 当请求 v2 版本的微服务时,页面是会有 1-5 个黑色的星
- 微服务 reviews-v3: 当请求 v3 版本的微服务时,页面是会有 1-5 个红星;
其他组件部署
grafana
kubectl -n istio-system port-forward $(kubectl -n istio-system get pod -l app=grafana -o jsonpath={.items[0].metadata.name}) 3000 --address=10.0.4.175
访问地址: http://10.0.4.175:3000
jaeger
uber 的一个分布式链路追踪项目,可以用来查看请求的路由进展情况
kubectl port-forward -n istio-system $(kubectl get pod -n istio-system -l app=jaeger -o jsonpath='{.items[0].metadata.name}') 16686 --address=10.0.4.175
访问地址:http://10.0.4.175:16686/
zipkin
zipkin 是 Java 写的,并且集成了各种语言,生态非常的强大,也是一个分布式链路追踪的组件,但是 bookinfo 没有集成,所以无法展示;
kubectl apply -f istio-1.8.1/samples/addons/extras/zipkin.yaml
kubectl port-forward -n istio-system $(kubectl get pod -n istio-system -l app=zipkin -o jsonpath='{.items[0].metadata.name}') 9411 --address=10.0.4.175
prometheus
kubectl port-forward -n istio-system $(kubectl get pod -n istio-system -l app=prometheus -o jsonpath='{.items[0].metadata.name}') 9090 --address=10.0.4.175
访问地址:http://10.0.4.175:9090/