IT七剑客 IT七剑客
首页
wresource
郭霖
孤寒者
IT邦德
沉默王二
老麦
stackoverflow
GitHub (opens new window)
首页
wresource
郭霖
孤寒者
IT邦德
沉默王二
老麦
stackoverflow
GitHub (opens new window)
  • 从零开始写 k8s 发布工具(一)

  • 从零开始写 k8s 发布工具(二)

  • 从零开始写 k8s 发布工具(三)

  • 从零开始写 k8s 发布工具(四)

  • istio的环境准备

  • istioVirtualService

    • isti VirtualService 和 k8s Ingress
    • 使用 istio Gateway 允许外部访问
    • VirtualService 使用路径重写
    • 使用 DestinationRule Subset 进行路由分组(版本控制)
    • VirtualService 使用 header 重写路由
    • VirtualService 路由重定向
    • VirtualService 重试机制
    • VirtualService 混沌测试/错误注入
    • VirtualService 服务委托
    • VirtualService Header 操作
    • Gateway 支持 https 访问 - 标准模式
      • 创建证书 k8s secret
      • 创建支持 https 的 istio Gateway
      • 测试
    • 使用 DestionationRule 流量控制策略 - 简单负载均衡
  • 老麦 Go
  • istioVirtualService
老麦
2023-02-01
目录

Gateway 支持 https 访问 - 标准模式

# Gateway 支持 https 访问 - 标准模式

https://istio.io/latest/docs/reference/config/networking/gateway/#ServerTLSSettings

credentialName: The secret (of type generic) should contain the following keys and values: key: <privateKey> and cert: <serverCert>

# 创建证书 k8s secret

  1. 在 标准模式 下, 必须使用 key 作为私钥文件名, cert 作为证书文件名。
  2. 证书文件需要 保持 与 istio-ingressgateway 服务在 相同 的命名空间。

因此证书文件的创建命令如下

kubectl create secret generic wild-tangx-in \
    --from-file=key=./certificates/_.tangx.in.key  \
    --from-file=cert=./certificates/_.tangx.in.crt  \
    -n istio-system
1
2
3
4

其中

  1. wild-tangx-in: 是 secret name。 之后 istio gateway 需要使用
  2. ./certificates/_.tangx.in.key(crt) 是证书私钥/文件所在的路径。
kg secret -n istio-system

    NAME                       TYPE                 DATA   AGE
    wild-tangx-in              Opaque               2      175m
1
2
3
4

# 创建支持 https 的 istio Gateway


---
# https://istio.io/latest/docs/reference/config/networking/gateway/

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: istio-tangx-in
  namespace: myistio
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
      - istio.tangx.in
    tls:
      httpsRedirect: true   # 开启 http -> https 301 重定向

  - port:
      number: 443
      name: https
      protocol: HTTPS   # 匹配协议
    hosts:
      - "*.tangx.in"    # 匹配域名, 这部分和 http 一样
    tls:
      mode: SIMPLE      # tls 模式
      credentialName: wild-tangx-in # 创建在 istio-system 下的证书 secret 
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
  1. .tls.httpRedirect: 是否开启 http -> https 的 301 重定向。
  2. .tls.mode: tls 模式。 https 使用 SIMPLE 模式。 支持所有模式为 PASSTHROUGH / SIMPLE / MUTUAL / AUTO_PASSTHROUGH / ISTIO_MUTUAL。
  3. .tls.credentialName: 在 k8s 环境下, 证书使用的 secret name。 不用特意挂载到 istio-ingressgateway 服务中。

# 测试

通过请求可以看到

17-standard-istio

上次更新: 2023/04/05, 05:23:58
VirtualService Header 操作
使用 DestionationRule 流量控制策略 - 简单负载均衡

← VirtualService Header 操作 使用 DestionationRule 流量控制策略 - 简单负载均衡→

最近更新
01
How the creator of Angular is dehydrating the web (Ep 574)
06-07
02
For those who just don’t Git it (Ep 573)
06-07
03
Modern work requires attention. Constant alerts steal it
06-07
更多文章>
Theme by Vdoing | Copyright © 2022-2024 IT七剑客 | MIT License
  • 闽ICP备2021006579号-4
  • 闽公网安备 35012102500470号
    • 跟随系统
    • 浅色模式
    • 深色模式
    • 阅读模式