下载二进制安装包
[root@lidabai-master ~]# $ wget https://github.com/istio/istio/releases/download/1.11.8/istio-1.11.8-linux-amd64.tar.gz
[root@lidabai-master ~]# tar zxvf istio-1.11.8-linux-amd64.tar.gz
[root@lidabai-master ~]# cd istio-1.11.8/
[root@lidabai-master ~]# ls
bin LICENSE manifests manifest.yaml README.md samples tools
samples: 示例应用程序;
bin: 包含istioctl的客户端文件,istioctl工具用于手动注入Envoy sidecar代理(边车代理)
安装Istioctl
把 istioctl 这个可执行文件拷贝到/usr/bin/目录
[root@lidabai-master ~]# mv bin/istioctl /usr/local/bin/ #安装Istioctl客户端工具
[root@lidabai-master ~]# istioctl install -y --set profile=demo
✔ Istio core installed
✔ Istiod installed
✔ Ingress gateways installed
✔ Egress gateways installed
✔ Installation complete
Thank you for installing Istio 1.11.
Please take a few minutes to tell us about your install/upgrade experience!
https://forms.gle/kWULBRjUv7hHci7T6
Install:在集群上安装或重新配置Istio。
--set profile=demo:生成演示配置文件,不要等待确认
镜像下载
最好每个节点都下载,安装istio的时候会自动下载,但比较慢而且可能会下载失败。
[root@lidabai-master ~]# docker pull docker.io/istio/proxyv2:1.11.8
[root@lidabai-master ~]# docker pull istio/pilot:1.11.8
[root@lidabai-master ~]# docker pull istio/examples-bookinfo-details-v1:1.15.0
[root@lidabai-master ~]# docker pull istio/examples-bookinfo-productpage-v1:1.16.2
[root@lidabai-master ~]# docker pull istio/examples-bookinfo-reviews-v1:1.15.0
[root@lidabai-master ~]# docker pull istio/examples-bookinfo-reviews-v2:1.15.0
[root@lidabai-master ~]# docker pull istio/examples-bookinfo-reviews-v3:1.15.0
[root@lidabai-master ~]# docker pull istio/examples-bookinfo-ratings-v1:1.15.0
[root@lidabai-master ~]# docker pull kennethreitz/httpbin:latest
服务验证
1)验证Pod是否正常
[root@lidabai-master ~]# kubectl -n istio-system get pods
NAME READY STATUS RESTARTS AGE
istio-egressgateway-66854b84df-snj2z 1/1 Running 0 48m
istio-ingressgateway-7dfd6876df-9m2q5 1/1 Running 0 48m
istiod-7f75778f86-ckkx8 1/1 Running 0 49m
Pod服务状态正常!
2)验证Service服务是否正常
[root@lidabai-master ~]# kubectl -n istio-system get svc
可以看到istio-ingressgateway入口网关的service服务异常,这是因为该服务使用的是公有云的访问方式,我们是自己的kubernetes集群环境,所以会异常。
3)修改istio-ingressgateway的访问方式
默认安装的istio-ingressgateway服务是以LoadBalancer(公有云环境)方式暴露的,服务处于pending状态而无法正常使用,需要修改为NodePort的访问方式。
[root@lidabai-master ~]# kubectl -n istio-system edit svc istio-ingressgateway
type: NodePort #将LoadBalancer修改为NodePort
status:
[root@lidabai-master ~]# kubectl -n istio-system get svc
istio-ingressgateway NodePort 10.102.50.201 <none>
可以看到服务正常了。
开启default命名空间的自动注入功能
给指定命名空间打上istio-injection=enabled的标签,istio就有向该命名空间中Pod有注入权限。
[root@lidabai-master ~]# kubectl label namespace default istio-injection=enabled
[root@lidabai-master ~]# kubectl describe namespaces default | grep Labels
Labels: injection=enabled
安装 Kiali 和其他插件
部署 Kiali仪表板、以及Prometheus、Grafana、还有 Jaeger。
Grafana: 可视化UI界面,展示Prometheus的监控数据;
Zipkin:全链路监控工具,监控服务间的调用关系;
1)安装相关插件
[root@lidabai-master ~]# ls samples/addons/
extras grafana.yaml jaeger.yaml kiali.yaml prometheus.yaml README.md
[root@lidabai-master ~]# kubectl apply -f samples/addons/
[root@lidabai-master ~]# kubectl rollout status deployment/kiali -n istio-system
[root@lidabai-master ~]# kubectl -n istio-system get pod
NAME READY STATUS RESTARTS AGE
grafana-556f8998cd-gdgvd 1/1 Running 0 2m4s
jaeger-5f65fdbf9b-vv7b5 1/1 Running 0 2m4s
kiali-787bc487b7-q6tvn 1/1 Running 0 2m4s
prometheus-9f4947649-p7s7k 2/2 Running 0 2m4s
[root@lidabai-master ~]# kubectl -n istio-system get svc #查看Service
2)修改服务访问方式
刚才部署的插件的服务默认是ClusterIP,无法在浏览器访问相关的服务,需要修改为NodePort。
[root@lidabai-master ~]# kubectl -n istio-system edit grafana
type: NodePort
[root@lidabai-master ~]# kubectl -n istio-system edit svc kiali
type: NodePort
3)浏览器访问 Kiali 仪表板
刚才已经修改了Kiali为nodeport的访问方式,在浏览器输入节点IP:port就可以进行访问了。
[root@lidabai-master ~]# kubectl -n istio-system get svc
kiali NodePort 10.96.53.145 <none> 20001:32162/TCP,9090:30809/TCP 22m
卸载istio集群
卸载集群不会卸载安装的插件,安装的插件得单独卸载。
[root@lidabai-master ~]# istioctl manifest generate --set profile=demo | kubectl delete -f -