在 K8S 中使用 cert-manager 签发腾讯云 DnsPort 免费 HTTPS 证书
cert-manager 本身是不支持国内 DNS解析服务商的,但官方给出了一些社区的提供方案:cert-manager Webhook
准备条件
- cert-manager 已部署在 K8S 集群内
- 腾讯云账号管理员权限
获取 API 密钥
腾讯云API密钥 -> DNSPort Token -> 创建密钥
得到 ID 和 Token
Helm 安装 cert-manager-webhook-dnspod
使用 HELM 来安装 ,需准备 HELM 配置文件。dnspod-webhook-values.yaml
示例如下:
groupName: example.your.domain # 写一个标识 group 的名称,可以任意写
secrets: # 将前面生成的 id 和 token 粘贴到下面
apiID: "<ID>"
apiToken: "<Token>"
clusterIssuer:
enabled: true # 自动创建出一个 ClusterIssuer
email: your@email.com # 填写您的邮箱地址
完整配置请参见 values.yaml
使用 HELM 进行安装:
# 获取 chart,路径在 ./cert-manager-webhook-dnspod/deploy/cert-manager-webhook-dnspod
git clone --depth 1 https://github.com/qqshfox/cert-manager-webhook-dnspod.git
helm upgrade --install -n cert-manager -f dnspod-webhook-values.yaml cert-manager-webhook-dnspod ./cert-manager-webhook-dnspod/deploy/cert-manager-webhook-dnspod
创建 SSL 证书
使用如下所示 YAML 文件创建 Certificate
对象来签发免费证书:文件名就以域名来命名 cert-star-example-com.yaml
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: cert-star-example-com
namespace: default
spec:
secretName: cert-star-example-com
issuerRef:
name: cert-manager-webhook-dnspod-cluster-issuer
kind: ClusterIssuer
group: cert-manager.io
dnsNames:
- example.com
- "*.example.com"
等待状态变成 Ready 表示签发成功:
$ kubectl get certificates
NAME READY SECRET AGE
cert-star-example-com True cert-star-example-com 108s
生产环境 SSL 证书
免费的 DV 类型 SSL 有效期3个月,多用于用户个人开发环境。
生产环境推荐使用权威 SSL 品牌提供的企业型 OV 证书,有效期为1年及以上。