Letsencrypt/Cert 通过 Istio 提供的应用程序管理器工作流 VirtualService/Gateway

Letsencrypt/Cert Manager workflow for apps served through Istio VirtualService/Gateway

是否有通用(或任何)工作流来为 Istio VirtualService & Gateway 中配置的应用颁发和更新 LE 证书? Istio 文档仅涵盖 Ingress 用例,我认为它不涵盖处理续订。

My real world use case is about making this work with a wildcard cert and custom applications, but for the sake of simplicity, I want to figure this out using the Prometheus service installed with the Istio demo. The VirtualService and Gateway are necessary for my real world use case.

以下是我目前使用自签名证书通过 https 为 Prometheus 提供服务的方式。我在 GKE K8s 版本 1.15.11 上 运行 Istio 版本 1.5.2。证书管理器也已安装。

那么我将如何调整它以使用证书管理器为 prom.example.com 颁发和更新 LE 证书?

---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: prometheus-gateway
  #namespace: istio-system
spec:
  selector:
    istio: ingressgateway
  servers:
    - port:
        number: 443
        name: http-prom
        protocol: HTTPS
      hosts:
        - "prom.example.com"
      tls:
        mode: SIMPLE # enables HTTPS on this port
        serverCertificate: /etc/istio/ingressgateway-certs/tls.crt
        privateKey: /etc/istio/ingressgateway-certs/tls.key
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: prometheus-vs
spec:
  hosts:
    - "prom.example.com"
  gateways:
    - prometheus-gateway
  http:
    - match:
        - port: 443
      route:
        - destination:
            host: prometheus
            port:
              number: 9090

有一个example for this in istio documentation:

This example demonstrates the use of Istio as a secure Kubernetes Ingress controller with TLS certificates issued by Let’s Encrypt.

You will start with a clean Istio installation, create an example service, expose it using the Kubernetes Ingress resource and get it secured by instructing cert-manager (bundled with Istio) to manage issuance and renewal of TLS certificates that will be further delivered to the Istio ingress gateway and hot-swapped as necessary via the means of Secrets Discovery Service (SDS).

希望对您有所帮助。

TL;DR

配置cert-manager 使用 DNS 域验证来颁发证书,更新是自动处理的。

Istio 文档中关于示例的一些注释,希望能阐明工作流程:

  • cert-manager 对 Istio 一无所知,它的关键作用是颁发和更新证书,然后将它们保存到 kubernetes 中的一个秘密对象中。

    • LE ACME 验证通常使用 DNS 完成,例如AWS Route53

    • 颁发的证书秘密将在一个特定的 k8s 命名空间中,并且在该命名空间之外不可见。

  • Istio 对证书管理器一无所知,它所需要的只是在带有 SDS 的网关中配置的颁发的证书秘密。这意味着两件事:

    • SDS 密钥的名称必须与证书管理器生成的名称匹配(这是它们之间唯一的 link)

    • 密钥必须与 Istio 网关位于同一命名空间中。

  • 最后,您的 VirtualServices 只需要一个如上所述正确配置的网关。好消息是,如果您使用全限定名,VirtualService 可以 link 到任何命名空间中的网关。

因此,您可以将网关置于颁发证书对象的同一名称空间中,以避免复制机密,然后您的 VirtualServices 可以位于任何名称空间中,只需使用完整的网关名称即可。