cert-manager

cert-manager 是一個自動化憑證管理的工具。它可以與 Istio 閘道整合以管理 TLS 憑證。

設定

請參閱 cert-manager 安裝文件 以開始使用。與 Istio 搭配使用無需任何特殊變更。

用法

Istio 閘道

cert-manager 可以用來將密碼寫入 Kubernetes,然後由閘道參考。

  1. 要開始使用,請按照 cert-manager 發行者文件 配置 `Issuer` 資源。`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. 接下來,按照 cert-manager 文件 配置 `Certificate` 資源。 `Certificate` 應在與 `istio-ingressgateway` 部署相同的命名空間中建立。例如, `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` 命名空間中看到建立的密碼。然後可以在閘道的 `tls` 設定中的 `credentialName` 下引用該密碼

    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 透過在 Ingress 物件上配置註解,提供與 Kubernetes Ingress 的直接整合。如果使用此方法,Ingress 必須與 `istio-ingressgateway` 部署位於相同的命名空間中,因為密碼只會在相同的命名空間內讀取。

或者,可以如Istio Gateway中所述建立一個 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
這些資訊是否有用?
您有任何改進建議嗎?

感謝您的回饋!