cert-manager

cert-manager 是一种自动化证书管理的工具。这可以与 Istio 网关集成以管理 TLS 证书。

配置

请参阅cert-manager 安装文档以开始使用。无需进行任何特殊更改即可与 Istio 协同工作。

用法

Istio 网关

cert-manager 可用于将密钥写入 Kubernetes,然后网关可以引用该密钥。

  1. 要开始使用,请配置一个Issuer资源,请遵循cert-manager 发行者文档Issuer是 Kubernetes 资源,表示能够通过遵守证书签名请求生成已签名证书的证书颁发机构 (CA)。例如:Issuer可能如下所示

    apiVersion: cert-manager.io/v1
    kind: Issuer
    metadata:
      name: ca-issuer
      namespace: istio-system
    spec:
      ca:
        secretName: ca-key-pair
    
  2. 接下来,配置一个Certificate资源,请遵循cert-manager 文档。应在与istio-ingressgateway部署相同的命名空间中创建Certificate。例如,Certificate可能如下所示

    apiVersion: cert-manager.io/v1
    kind: Certificate
    metadata:
      name: ingress-cert
      namespace: istio-system
    spec:
      secretName: ingress-cert
      commonName: my.example.com
      dnsNames:
      - my.example.com
      ...
    
  3. 创建证书后,我们应该会看到在istio-system命名空间中创建的密钥。然后可以在网关下credentialNametls配置中引用它

    apiVersion: networking.istio.io/v1
    kind: Gateway
    metadata:
      name: gateway
    spec:
      selector:
        istio: ingressgateway
      servers:
      - port:
          number: 443
          name: https
          protocol: HTTPS
        tls:
          mode: SIMPLE
          credentialName: ingress-cert # This should match the Certificate secretName
        hosts:
        - my.example.com # This should match a DNS name in the Certificate
    

Kubernetes 入口

cert-manager 通过在入口对象上配置注释来提供与 Kubernetes 入口的直接集成。如果使用此方法,则入口必须位于与istio-ingressgateway部署相同的命名空间中,因为密钥仅在同一命名空间内读取。

或者,可以按照Istio 网关中所述创建Certificate,然后在Ingress对象中引用它

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress
  annotations:
    kubernetes.io/ingress.class: istio
spec:
  rules:
  - host: my.example.com
    http: ...
  tls:
  - hosts:
    - my.example.com # This should match a DNS name in the Certificate
    secretName: ingress-cert # This should match the Certificate secretName
这些信息是否有用?
您对改进有什么建议?

感谢您的反馈!