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

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

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

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

  • istio的环境准备

  • istioVirtualService

    • vs-and-ingress
    • gateway
    • vs-http-rewrite-by-uri
    • dr-subset
    • vs-http-rewrite-by-header
    • vs-http-redirect
    • vs-http-retry
    • vs-http-fault-injection
    • vs-http-delegate
    • vs-http-header-operation
    • gw-https-support-standard
      • 创建证书 k8s secret
      • 创建支持 https 的 istio Gateway
      • 测试
    • dr-simple-loadbalance
  • 老麦 Go
  • istioVirtualService
老麦
2023-02-01
目录

gw-https-support-standard

# 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

编辑 (opens new window)
上次更新: 2023/02/05, 02:48:13
vs-http-header-operation
dr-simple-loadbalance

← vs-http-header-operation dr-simple-loadbalance→

最近更新
01
Coding 102 Writing code other people can read
02-26
02
Kotlin Flow响应式编程,StateFlow和SharedFlow
02-05
03
Kotlin Flow响应式编程,操作符函数进阶
02-05
更多文章>
Theme by Vdoing | Copyright © 2022-2023 IT七剑客 | MIT License
  • 闽ICP备2021006579号-4
  • 闽公网安备 35012102500470号
    • 跟随系统
    • 浅色模式
    • 深色模式
    • 阅读模式