使用带有 TCP 协议的出口网关执行 TLS 发起

时间:2021-05-14 17:04:25

标签: kubernetes ldap tls1.2 istio

我的用例如下我想拦截 172.28.0.3:389 中对 LDAP 的调用,并使用 TLS 转发到 172.28.0.3:636。

我已按照 egress tls originate 的步骤操作,并且运行良好。现在我正在尝试使用网关,不幸的是我在设置端口时遇到了问题。我基本上复制并粘贴了 documentation 的设置,并将协议从 HTTP 和 HTTPS 调整为 TCP,并将端口 80 和 443 分别调整为 389 和 636:

    apiVersion: networking.istio.io/v1alpha3
    kind: ServiceEntry
    metadata:
      name: cnn
    spec:
      hosts:
      - ldap.host
      addresses:
      - 172.28.0.3
      ports:
      - number: 389
        name: tcp
        protocol: TCP
      - number: 636
        name: tcp-secure
        protocol: TCP
      resolution: STATIC
      endpoints:
       - address: 172.28.0.3

------ 


apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: istio-egressgateway
spec:
  selector:
    istio: egressgateway
  servers:
  - port:
      number: 389 # I am not sure about this
      name: tpc-port-for-tls-origination
      protocol: tcp
    hosts:
    - ldap.host
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: egressgateway-for-cnn
spec:
  host: istio-egressgateway.istio-system.svc.cluster.local
  subsets:
  - name: cnn


apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: direct-cnn-through-egress-gateway
spec:
  hosts:
  - ldap.host
  gateways:
  - istio-egressgateway
  - mesh
  tcp: # I AM NOT SURE ABOUT THIS PART
  - match:
    - gateways:
      - mesh
      port: 389
    route:
    - destination:
        host: istio-egressgateway.istio-system.svc.cluster.local
        subset: cnn
        port:
          number: 389
      weight: 100
  - match:
    - gateways:
      - istio-egressgateway
      port: 389
    route:
    - destination:
        host: ldap.host
        port:
          number: 636
      weight: 100
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: originate-tls-for-edition-cnn-com
spec:
  host: ldap.host
  trafficPolicy:
    loadBalancer:
      simple: ROUND_ROBIN
    portLevelSettings:
    - port:
        number: 636
      tls:
        mode: SIMPLE # initiates HTTPS for connections to edition.cnn.com

我感觉问题出在 VirtualService 上,但是我尝试了很多方法但都没有成功,如果您有任何提示可能是问题所在,我们将不胜感激。

1 个答案:

答案 0 :(得分:1)

查看这篇博文和之前的博文:您似乎对支持 LDAP 集成的外部 custom authentication 提供商感兴趣。例如,您可以使用 keycloakAuth0Google Auth

本文档显示了一个外部身份验证,它可以是 integrated with istio。请注意,文档可能已过时 (02/2018)。


在这里您可以找到similar problem

<块引用>

就我而言,LDAP 在 istio 中不起作用。 此处的解决方法是 keycloakauth0 您可以将它们都与 istio 集成,但它仅用于身份验证,它本身不能作为 LDAP 工作,至少据我所知。


您还可以使用 JSON 网络令牌 (JWT) 验证来启用身份验证。 Istio 负责验证传入用户请求中的 JWT 令牌。因此,如果您实现了 Istio JWT 身份验证功能,您的应用程序代码就不需要担心 JWT 令牌验证。 Istio 将为您完成。不是 JWT 令牌生成。 Istio 不会为您生成令牌。您必须拥有一个生成令牌的身份验证微服务。 Here 是关于如何使用 JWT 对最终用户进行身份验证的主题。