惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

有赞技术团队
有赞技术团队
Apple Machine Learning Research
Apple Machine Learning Research
IT之家
IT之家
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog RSS Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
人人都是产品经理
人人都是产品经理
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
V
V2EX
aimingoo的专栏
aimingoo的专栏
爱范儿
爱范儿
博客园 - 聂微东
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Stack Overflow Blog
Stack Overflow Blog
罗磊的独立博客
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
MongoDB | Blog
MongoDB | Blog
Jina AI
Jina AI
T
The Blog of Author Tim Ferriss
月光博客
月光博客
云风的 BLOG
云风的 BLOG

陈少文的网站

巨变与机遇的未来十年 Kubernetes 平台管理软件压力测试方案 使用镜像部署 Hexo 静态页面 终于等到你 - GitHub 镜像仓库服务(ghcr.io) 一起来学 Go --(6)Interface 一起来学 Go --(5)Goroutine 和 Channel 什么是函数式编程 如何在 Kubernetes 集群集成 Kata 柯里化与偏函数 使用 PyGithub 自动创建 Label 软件产品是团队能力的输出 Helm 2 、Helm 3 比较 IoT 变现 Kubernetes 中的 DNS 服务 国内的 Helm 镜像源 Harbor 使用自签证书支持 Https 访问 DevOps 工具链之 Prow 如何使用 kfctl 安装 Kubeflow VS Code 无法下载 Go 插件的工具包 工程师更应具有服务精神 你不知道的 Docker 使用技巧 使用 Docker 运行 Tensorflow 论中国 什么是左移 如何清空 Git 仓库全部历史记录 一禅小和尚 有风吹过厨房 时间的玫瑰 如何在 CentOS 安装 GPU 驱动 开发 Tips(19)
Istio Gateway 下的几种流量配置路径
微信公众号 · 2023-02-21 · via 陈少文的网站

1. 常用对象配置

1.1 Gateway

  • selector
    • 选择规则生效的 Envoy
  • servers
    • 匹配的域名
    • 端口
    • 协议
    • TLS 证书

1.2 VirtualService

  • gateways
    • 指定生效的网关,默认值 mesh 为东西向流量;如果指定 Gateway 对象则为南北向流量
  • http
    • 七层路由
    • 重定向
    • 重写
    • 重试
    • 条件规则
    • 超时
    • 故障注入
    • 跨站策略
  • tcp
    • 七层路由
  • tls
    • 带证书路由
    • TLS 证书

1.3 DestinationRule

  • host
    • 路由
  • trafficPolicy
    • 镜像流量
    • 故障转移
    • 熔断器
    • 负载均衡
  • subsets
    • 提供 Pod 分组,可用于蓝绿发布

2. 七层 Gateway->HTTPRoute->Service

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
  name: default-gateway
  namespace: default
spec:
  selector:
    istio: ingressgateway
  servers:
    - hosts:
        - "*"
      port:
        name: http
        number: 80
        protocol: HTTP
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: chenshaowen
  namespace: default
spec:
  gateways:
    - default/default-gateway
  hosts:
    - "istio.chenshaowen.com"
  http:
    - match:
        - uri:
            exact: /
      route:
        - destination:
            host: blog.default.svc.cluster.local
            port:
              number: 80

这样就将 default 空间下的 blog 服务通过 Istio Gateway 暴露到了外部。

通过主机端口 + Istio Gateway 映射到主机的 NodePort 即可访问服务。如下图:

3. 四层 Gateway->TCPRoute->Service

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
  name: default-gateway
  namespace: default
spec:
  selector:
    istio: ingressgateway
  servers:
    - hosts:
        - "*"
      port:
        name: tcp
        number: 80
        protocol: TCP
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: chenshaowen
  namespace: default
spec:
  gateways:
    - default/default-gateway
  hosts:
    - "istio.chenshaowen.com"
  tcp:
    - match:
        - port: 80
      route:
        - destination:
            host: blog.default.svc.cluster.local
            port:
              number: 80

当 VirtualService 中使用 TCP 时,Gateway 也需要使用 TCP ,协议需要匹配。