【问题标题】:Enabling HTTPS port in k8s在 k8s 中启用 HTTPS 端口
【发布时间】:2021-12-12 20:16:09
【问题描述】:

我正在尝试将端口 5665 添加到 istio-ingressgatway 并且它已被添加但流量没有(我认为)正确路由,因为我不断收到 SSL 错误

curl -k https://api.loadbalancer.local.com:5665/v1/bla ; echo
curl: (35) error:1400410B:SSL routines:CONNECT_CR_SRVR_HELLO:wrong version number

我可以telnet ingressgateway LB 上的端口

❯ telnet api.loadbalancer.local.com 5665
Trying 10.239.49.9...
Connected to api.loadbalancer.local.com.
Escape character is '^]'.

如果我直接调用 POD IP 作为示例,服务响应良好

  IP:           10.23.49.90
Controlled By:  ReplicaSet/icinga2-84bd777b9
Containers:
  icinga2:
    Image:          jordan/icinga2:latest
    Ports:          80/TCP, 443/TCP, 5665/TCP
    Host Ports:     0/TCP, 0/TCP, 0/TCP
    State:          Running
      
    Ready:          True
    Restart Count:  0
    Liveness:       http-get http://:http/ delay=0s timeout=1s period=10s #success=1 #failure=3
❯ curl -k https://10.23.49.90:5665/
<h1>Unauthorized. Please check your user credentials.</h1>%
❯ curl -k https://10.23.49.90:5665/v1/bla
<h1>Unauthorized. Please check your user credentials.</h1>%
❯ curl -k http://10.23.49.90:5665/
curl: (52) Empty reply from server

路由配置

  • istio-ingress-gateway 用于打开端口
 - name: api
    nodePort: 30431
    port: 5665
    protocol: TCP
    targetPort: 5665
  • 网关配置
apiVersion: v1
items:
- apiVersion: networking.istio.io/v1beta1
  kind: Gateway
  spec:
    selector:
      istio: ingressgateway
    servers:
    - hosts:
      - '*'
      port:
        name: api
        number: 5665
        protocol: HTTPS
      tls:
        mode: SIMPLE

虚拟服务

apiVersion: v1
items:
- apiVersion: networking.istio.io/v1beta1
  kind: VirtualService
  spec:
    gateways:
    - icinga2
    hosts:
    - '*'
    http:
    - match:
      - port: 5665
      route:
      - destination:
          host: icinga2.default.svc.cluster.local
          port:
            number: 5665

问题 使该端口与直接调用 POD IP 时一样工作,我做错了什么?

我认为我收到 curl: (35) error:1400410B:SSL routines:CONNECT_CR_SRVR_HELLO:wrong version number 的原因是由于配置错误。

此外,我什至不知道在哪里解决问题,所以如果有人可以解释在哪里寻找也会有所帮助。

问候。

【问题讨论】:

  • @PeterClaes 谢谢你,是的,它帮助我修复并找到了我的错误配置,我发誓:) 我之前看过那个页面......但不知道我是如何错过http 和@987654333 @YAML 中的标签,谢谢

标签: kubernetes-ingress istio


【解决方案1】:

只是为其他人添加我如何解决问题的答案。

网关 变化:

spec:
  selector:
    istio: ingressgateway
  servers:
  - hosts:
    - '*'
    port:
      name: https
      number: 5665
      protocol: HTTPS
      targetPort: 5665
    tls:
      mode: PASSTHROUGH

虚拟服务 变化:

  spec:
    gateways:
    - icinga2
    hosts:
    - '*'
    tls:
    - match:
      - port: 5665
      route:
      - destination:
          host: icinga2.default.svc.cluster.local
          port:
            number: 5665

请注意匹配规则上方的TLS 标签,在不知何故我放在那里之前http

现在我可以通过 https 调用 api

❯ curl -k https://api.loadbalancer.local.com:5665/v1/bla ; echo
<h1>Unauthorized. Please check your user credentials.</h1>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-17
    • 2012-05-16
    • 2016-03-17
    • 1970-01-01
    • 1970-01-01
    • 2021-11-23
    相关资源
    最近更新 更多