Istio + Kubernetes:网关多个TLS证书

时间:2020-01-02 21:23:40

标签: ssl kubernetes istio gateway

我有一个Kubernetes集群,其中有多个租户(在不同的命名空间中)。我想在每个租户中部署一个独立的Istio Gateway对象,这似乎可以做到。但是,设置TLS需要包含TLS密钥/证书的K8s机密。该文档指出“秘密必须在istio-system名称空间中命名为istio-ingressgateway-certs”。这似乎表明每个群集只能有一个TLS秘密。也许我没有正确阅读。有没有办法在自己的名称空间中使用自己的TLS秘密配置独立的Istio网关?我该怎么做呢?

这是我要参考的文档。
https://istio.io/docs/tasks/traffic-management/ingress/secure-ingress-mount/

任何想法都值得赞赏。

1 个答案:

答案 0 :(得分:1)

有可能在istio documentation上提供。

在本部分中,您将为多个主机httpbin.example.com和bookinfo.com配置入口网关。

因此,在此示例中,您需要为bookinfohttbin创建私钥,并更新istio-ingressgateway。

我同时创建了它们和它们。

bookinfo证书和网关

kubectl exec -it -n istio-system $(kubectl -n istio-system get pods -l istio=ingressgateway -o jsonpath='{.items[0].metadata.name}') -- ls -al /etc/istio/ingressgateway-bookinfo-certs

lrwxrwxrwx 1 root root   14 Jan  3 10:12 tls.crt -> ..data/tls.crt
lrwxrwxrwx 1 root root   14 Jan  3 10:12 tls.key -> ..data/tls.key

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: bookinfo-gateway
spec:
  selector:
    istio: ingressgateway # use istio default ingress gateway
  servers:
  - port:
      number: 443
      name: https-bookinfo
      protocol: HTTPS
    tls:
      mode: SIMPLE
      serverCertificate: /etc/istio/ingressgateway-bookinfo-certs/tls.crt
      privateKey: /etc/istio/ingressgateway-bookinfo-certs/tls.key
    hosts:
    - "bookinfo.com"

httpbin证书和网关

kubectl exec -it -n istio-system $(kubectl -n istio-system get pods -l istio=ingressgateway -o jsonpath='{.items[0].metadata.name}') -- ls -al /etc/istio/ingressgateway-certs


lrwxrwxrwx 1 root root   14 Jan  3 10:07 tls.crt -> ..data/tls.crt
lrwxrwxrwx 1 root root   14 Jan  3 10:07 tls.key -> ..data/tls.key


apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: httpbin-gateway
spec:
  selector:
    istio: ingressgateway # use istio default ingress gateway
  servers:
  - port:
      number: 443
      name: https
      protocol: HTTPS
    tls:
      mode: SIMPLE
      serverCertificate: /etc/istio/ingressgateway-certs/tls.crt
      privateKey: /etc/istio/ingressgateway-certs/tls.key
    hosts:
    - "httpbin.example.com"

还没有进行完整的复制以检查它们是否都有效,但是如果这对您不起作用,我将尝试使其完整并更新问题。

link可能会有所帮助。