0
点赞
收藏
分享

微信扫一扫

k8s 蓝绿部署

五殳师兄 2023-07-03 阅读 67

蓝绿部署,2个版本同事存在,新版本接替旧版本,  借助 istio 实现

k8s 蓝绿部署_重定向

k8s 蓝绿部署_新版本_02


kubectl -n demo-project get virtualservice -o yaml

# 这是一个 Istio 虚拟服务列表,包含 4 个服务:details、productpage、ratings 和 reviews

apiVersion: v1  
items:
# 这个虚拟服务配置了 details 服务的路由规则
- apiVersion: networking.istio.io/v1beta1  
  kind: VirtualService
  metadata:  
    name: details
    namespace: demo-project
  spec:
    hosts:  
    - details   # 应用了此规则的主机
    http:
    - match:  
      - port: 9080   # 匹配端口 9080 的流量
      route:
      - destination:  
          host: details   # 流量被重定向到 details 服务
          subset: v1    # 流量被定向到子集 v1
        weight: 100   # 100% 的流量被重定向

# 这个虚拟服务配置了 productpage 服务的路由规则  
- apiVersion: networking.istio.io/v1beta1  
  kind: VirtualService
  metadata:  
    name: productpage
    namespace: demo-project
  spec:  
   # ...

# 这个虚拟服务配置了 ratings 服务的路由规则  
- apiVersion: networking.istio.io/v1beta1  
  kind: VirtualService
  metadata:  
    name: ratings
    namespace: demo-project
  spec:  
   # ...  

# 这个虚拟服务最初配置了 reviews 服务的路由规则,后来又更新了  
- apiVersion: networking.istio.io/v1beta1  
  kind: VirtualService
  metadata:  
    name: reviews
    namespace: demo-project
  spec:  
    hosts:  
    - reviews
    http:
    - match:  
      - port: 9080  
      route:
      - destination:  
          host: reviews  
          subset: v2    # 这次更新将流量路由到子集 v2
        weight: 100


举报

相关推荐

K8S部署

K8s部署

kudeadm 部署 k8s

K8S集群部署

k8s部署minio

快速部署k8s

k8s部署nginx

k8s 单机 部署

0 条评论