cert-manager
cert-manager 是一种自动化证书管理的工具。这可以与 Istio 网关集成以管理 TLS 证书。
配置
请参阅cert-manager 安装文档以开始使用。无需进行任何特殊更改即可与 Istio 协同工作。
用法
Istio 网关
cert-manager 可用于将密钥写入 Kubernetes,然后网关可以引用该密钥。
要开始使用,请配置一个
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
接下来,配置一个
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 ...
创建证书后,我们应该会看到在
istio-system
命名空间中创建的密钥。然后可以在网关下credentialName
的tls
配置中引用它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