使用istio资源实现版本流量路由 本章节介绍如何使用istio资源实现版本流量路由 前提条件 1. 已开通云容器引擎,至少有一个云容器引擎实例。产品入口:云容器引擎。 2. 开通天翼云应用服务网格实例。 3. 开通天翼云微服务引擎,并在服务网格控制面集群同VPC内创建云原生网关实例。产品入口:微服务引擎MSE。 操作步骤 部署多版本reviews服务 这里以bookinfo应用里面的reviews服务为例,使用istio资源实现对reviews服务的多版本路由,首先到云容器引擎控制台部署reviews服务的v2和v3版本,yaml如下: apiVersion: apps/v1 kind: Deployment metadata: name: reviewsv2 labels: withServiceMesh: "true" spec: replicas: 1 selector: matchLabels: name: reviewsv2 template: metadata: labels: app: reviews version: v2 name: reviewsv2 source: CCSE "sidecar.istio.io/inject": "true" csmAutoEnable: "on" annotations: "sidecar.istio.io/inject": "true" spec: containers: name: reviews image: 'registryvpccrshuadong1.cnspinternal.ctyun.cn/library/istioexamplesbookinforeviewsv2:1.16.2' imagePullPolicy: IfNotPresent env: name: LOGDIR value: "/tmp/logs" volumeMounts: name: tmp mountPath: /tmp name: wlpoutput mountPath: /opt/ibm/wlp/output volumes: name: wlpoutput emptyDir: {} name: tmp emptyDir: {} apiVersion: apps/v1 kind: Deployment metadata: name: reviewsv3 labels: withServiceMesh: "true" spec: replicas: 1 selector: matchLabels: name: reviewsv3 template: metadata: labels: app: reviews version: v3 name: reviewsv3 source: CCSE "sidecar.istio.io/inject": "true" csmAutoEnable: "on" annotations: "sidecar.istio.io/inject": "true" spec: containers: name: reviews image: 'registryvpccrshuadong1.cnspinternal.ctyun.cn/library/istioexamplesbookinforeviewsv3:1.16.2' imagePullPolicy: IfNotPresent env: name: LOGDIR value: "/tmp/logs" volumeMounts: name: tmp mountPath: /tmp name: wlpoutput mountPath: /opt/ibm/wlp/output volumes: name: wlpoutput emptyDir: {} name: tmp emptyDir: {} 通过云原生网关持续访问bookinfo应用可以看到前端页面在三种效果内跳变,分别对应reviews服务的三个版本: (1)Review内没有评分。 (2)Review内有评分信息,评分的星星颜色是黑色。 (3)Review内有评分信息,评分的星星颜色是红色。