istio 应用灰度发布部署注意点(包括 deploy、svc、gw、vs 和 dr)

创建 deployment

分别部署两个版本的 deployment。在灰度发布的过程中,注意 pod 标签的设置,后续 svc 和 dr 就是根据标签来划分 pod

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: bbjcxt
    version: v1
  name: bbjcxt
  namespace: mm-nbxt-huidu
spec:
  ...
  template:
    metadata:
      labels:
        app: bbjcxt
        version: v1
  ...
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: bbjcxt
    version: v1
  name: bbjcxt
  namespace: mm-nbxt-huidu
spec:
  ...
  template:
    metadata:
      labels:
        app: bbjcxt
        version: v2
  ...

app:后续创建的 service 通过此标签管理
version:后续创建的 destinationrule 通过此标签将应用分为两个子集

创建 service

因为灰度发布的原因,不同版本的 pod 的标签是不一样的,因此 service 的 selector 只能通过 app 标签来选择 pod

apiVersion: v1
kind: Service
...
spec:
  ...
  selector:
    app: bbjcxt
  ...

gw、vs 和 dr 的创建顺序没有要求,注意这三个资源的 host/hosts 参数设置
我的习惯是从外到内,即 gw -> vs -> dr

创建 gateway

host 参数设置的外部访问的域名

apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
  name: nbxt
  namespace: mm-nbxt-huidu
spec:
  selector:
    app: istio-ingressgateway # 选择 istio IngressGateway 的 label
  servers:
  - hosts:
    - nbxt.com # 自定义域名
    port:
      name: http
      number: 80
      protocol: HTTP

需要注意的是配置了自定义域后,需要在本机和服务器上的 hosts 域名解析文件上配置相关内容

# 如果服务器的 ip 为 1.1.1.1,则需要同时在本机和服务器上的 hosts 添加如下
1.1.1.1 nbxt.com

创建 virtualserivce

注意 host 和 destination 字段参数设置,还有一个很重要的 match 字段(后续文章解释)
host 参数设置的外部和内部访问的域名

内部访问的域名是一个规范,有一定的格式,可以简单理解为 service 的 name

apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: nbxt-vs
  namespace: mm-nbxt-huidu
spec:
  gateways:
  - nbxt # 上一步创建的 gw name
  hosts:
  - nbxt.com # 外部访问的 host
  - svc-bbjcxt # 内部访问的 host
  http:
  - name: default # 展示了一个默认无匹配的路由,通过百分比分流
    route:
    - destination:
        host: svc-bbjcxt
        subset: v1
      weight: 10
    - destination:
        host: svc-bbjcxt
        subset: v2
      weight: 90

创建 destinationrule

host 参数设置是内部访问的域名

内部访问的域名是一个规范,有一定的格式,可以简单理解为 service 的 name

labels 就是 pod 的第二个标签,根据这个标签将应用根据版本分为多个子集

apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
  name: nbxt-dr
  namespace: mm-nbxt-huidu
spec:
  host: svc-bbjcxt
  subsets:
  - labels:
      version: v1
    name: v1
  - labels:
      version: v2
    name: v2

相关推荐

  1. Istio 部署 Spring Coud 微服务应用

    2023-12-29 13:24:04       17 阅读
  2. 什么是灰度发布

    2023-12-29 13:24:04       14 阅读
  3. Kubernetes+istio部署bookinfo、Online boutiquesock shop

    2023-12-29 13:24:04       33 阅读

最近更新

  1. TCP协议是安全的吗?

    2023-12-29 13:24:04       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-29 13:24:04       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-29 13:24:04       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-29 13:24:04       18 阅读

热门阅读

  1. istio envoyfilter yaml 解释

    2023-12-29 13:24:04       37 阅读
  2. 回顾2023

    2023-12-29 13:24:04       36 阅读
  3. Ubuntu Linux 入门指南:面向初学者

    2023-12-29 13:24:04       38 阅读
  4. 常见负载均衡方案分析

    2023-12-29 13:24:04       36 阅读
  5. c#生成临时文件

    2023-12-29 13:24:04       32 阅读
  6. 基于SpringBoot的仓库管理系统

    2023-12-29 13:24:04       39 阅读
  7. Zookeeper相关面试题及答案

    2023-12-29 13:24:04       31 阅读