名词解释 服务网格 :用来描述组成这些应用程序的微服务网络以及他们之间的相互调用 为什么使用Istio 通过负载均衡、服务间的身份验证、监控等方法,Istio 可以轻松地创建一个已经部署了服务的网络,而服务的代码只需 很少更改甚至无需更改。通过在整个环境中部署一个特殊的 sidecar 代理为服务添加 Istio 的支持,而代理会拦截微服务之间的所有网络通信,然后使用其控制平面的功能来配置和管理 Istio Istio 核心特性流量管理:Istio 简单的规则配置和流量路由允许您控制服务之间的流量和 API 调用过程。Istio 简化了服务级属性(如熔断器、超时和重试)的配置,并且让它轻而易举地执行重要的任务(如 A/B 测试、金丝雀发布和按流量百分比划分的分阶段发布) 安全 可观察性:Istio 健壮的追踪、监控和日志特性让您能够深入地了解服务网格部署 多平台支持:Istio 独立于平台,被设计为可以在各种环境中运行,包括跨云、内部环境、Kubernetes、Mesos 等等 整合和定制:Istio 的策略实施组件可以扩展和定制,与现有的 ACL、日志、监控、配额、审查等解决方案集成。 前置条件本示例前置条件:可以正常使用的 kubernetes 集群 下载Istio下载地址 https://github.com/istio/istio/releases/tag/1.15.0下载命令 curl -L https://istio.io/downloadIstio | ISTIO_VERSION=1.15.0 TARGET_ARCH=x86_64 sh - #istio 版本为 1.15.0 #处理器架构为x86_64, 在服务器上执行 uname -i 获取处理器架构,本次示例安装使用的是 aarch64,因此实际执行命令如下 例:curl -L https://istio.io/downloadIstio | ISTIO_VERSION=1.15.0 TARGET_ARCH=aarch64 sh -解压并进入包目录 tar -zxvf istio-1.15.0-linux-arm64.tar.gz cd istio-1.15.0 #目录说明 #samples:示例应用程序 #bin 目录下的 istioctl 客户端二进制文件配置环境变量 export PATH=/root/istio-1.15.0/bin:$PATH #示例中 直接解压到 /root 目录安装Istio对于本次安装,我们采用 demo 配置组合。 选择它是因为它包含了一组专为测试准备的功能集合,另外还有用于生产或性能测试的配置组合。其他平台请参考:Istio / 平台安装 [root@master2 istio-1.15.0]# istioctl install --set profile=demo -y ✔ Istio core installed ✔ Istiod installed ✔ Egress gateways installed ✔ Ingress gateways installed ✔ Installation complete Making this installation the default for injection and validation.Thank you for installing Istio 1.15. Please take a few minutes to tell us about your install/upgrade experience! https://forms.gle/SWHFBmwJspusK1hv6给命名空间增加标签,指示Istio 在部署应用的时候,自动注入Envoy 边车代理 kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml #由于处理器架构为 aarch64,因此实际 替换了bookinfo.yaml 文件中镜像,替换后的镜像为: docker pull arkodg/examples-bookinfo-details-v1:latest docker pull arkodg/examples-bookinfo-ratings-v1:latest docker pull arkodg/examples-bookinfo-reviews-v1:latest docker pull arkodg/examples-bookinfo-reviews-v2:latest docker pull massivezh/examples-bookinfo-reviews-v3:latest docker pull arkodg/examples-bookinfo-productpage-v1:latest查看部署情况 [root@master2 ~]# kubectl get pod,svc NAME READY STATUS RESTARTS AGE pod/details-v1-8464b7b547-lq4jq 2/2 Running 0 21h pod/productpage-v1-55b8849485-8pzd2 2/2 Running 0 21h pod/ratings-v1-8d5bd46bc-rbpdc 2/2 Running 0 21h pod/reviews-v1-7bd8fb5987-clw8n 2/2 Running 0 21h pod/reviews-v2-7c48f4dcf5-pbfl9 2/2 Running 0 21h pod/reviews-v3-5bf5cb5b89-jsrd7 2/2 Running 0 21h NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/details ClusterIP 11.233.48.1479080/TCP 21h service/kubernetes ClusterIP 11.233.0.1 443/TCP 22h service/productpage ClusterIP 11.233.20.241 9080/TCP 21h service/ratings ClusterIP 11.233.52.157 9080/TCP 21h service/reviews ClusterIP 11.233.37.87 9080/TCP 21h对外开放应用应用关联到Istio网关 kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml istioctl analyze确定入站IP和端口本示例集群中没有外部负载均衡器,因此执行如下,其余请参考:Istio / 入门 export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath="{.spec.ports[?(@.name=="http2")].nodePort}") export SECURE_INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath="{.spec.ports[?(@.name=="https")].nodePort}") export INGRESS_HOST=$(kubectl get po -l istio=ingressgateway -n istio-system -o jsonpath="{.items[0].status.hostIP}") export GATEWAY_URL=$INGRESS_HOST:$INGRESS_PORT获取设置的环境变量 echo "$GATEWAY_URL" 192.168.0.164:31840外部浏览器访问----(192.168.0.164 为 istio-ingressgateway pod 所在节点的内网IP,如果需要外网访问,请自行查找对应的公网IP,确保安全组放行端口) 安装仪表盘安装 kiali及其他插件 kubectl apply -f samples/addons istioctl dashboard kiali 注:示例中自行暴露了 kiali service 的nodeport 访问,通过节点的IP和端口访问