Istio统一网关灰度流程

文章目录

⚡️:在上篇文章中提到了 Istio实现灰度发布的原理,也提到了 Desctination 的重要性,这篇我们结合统一网关来指定服务灰度发布的方案.

​ 现在我们知道了,Istio灰度无非就是制定好 VirtualService和DestinationRule 规则,来进行流量管理,那么,我们在对center—gatewaysvr 服务进行小部分调整即可实现。

Center-Gatewaysvr

我们查看下Helm 中VirtualService模板,可以看到,我们这里也新增了对服务灰度的开关。

---
{{- define "http-routes" -}}
{{- range $route := .Values.routes }}
  {{- range $preferTag := $route.preferTag }}
  - match:
      - headers:
          x-asm-prefer-tag:
            exact: {{ $preferTag }}
        uri:
          prefix: /gstrain
        ignoreUriCase: true
    rewrite:
      uri: /{{ $preferTag }}
    route:
      - destination:
          host: {{ $route.destination.host }}
          port:
            number: {{ $route.destination.port }}
          subset: {{ $route.destination.host }}
      {{- if $route.canary.enabled }}
        weight: {{ $route.canary.stable.weight | default 100  }}
      - destination:
          host: {{ $route.destination.host }}
          port:
            number: {{ $route.destination.port }}
          subset: {{ $route.destination.host }}-canary
        weight: {{  $route.canary.canary.weight | default 0 }}
      {{- end}}
  {{- end}}
{{- end}}
{{- end}}
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: {{ include "center-gatewaysvc.fullname" . }}
  labels:
    {{- include "center-gatewaysvc.labels" . | nindent 4 }}
spec:
  gateways:
  - {{ include "center-gatewaysvc.fullname" . }}
  hosts:
  {{- toYaml .Values.gateway.hostnames | nindent 4 }}
  http:
  {{- template "http-routes" . }}

这样做呢,和我们之前不同的是,我们把整个服务的Vs整合在一个下面,方便管理与配置

Value

先看来看渲染值,灰度调整好之后,我们只需要调整开关。

route:
  ## Values for mobilesvr
  - preferTag:
      - AcctInfo
      - CacheStore
      - CacheGet
    destination:
      host: ycloud
      port: 8080
    canary:
      enabled: false
      stable:
        weight: 80
      canary:
        weight: 20
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

努力做一名技术

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值