「cert-manager」- DNSPod

如果域名使用腾讯云 DNSPod 管理,并期望在 Kubernetes 上为域名自动签发免费证书,可以使用 cert-manager 来实现。

cert-manager 支持许多 DNS provider,但不支持国内的 DNSPod 提供商。

不过 cert-manager 提供了 Webhook 机制来扩展 provider,社区也有 DNSPod 的 provider 实现。

cert-manager-webhook-dnspod | by imroc

https://github.com/imroc/cert-manager-webhook-dnspod

helm repo add cert-manager-webhook-dnspod https://imroc.github.io/cert-manager-webhook-dnspod
helm pull cert-manager-webhook-dnspod/cert-manager-webhook-dnspod

helm show values cert-manager-webhook-dnspod-1.5.2.tgz > cert-manager-webhook-dnspod-1.5.2.tgz.helm-values.yaml
vim cert-manager-webhook-dnspod-1.5.2.tgz.helm-values.yaml
... nameOverride:
... fullnameOverride:
... groupName:
... image.repository:
... image.tag:
... clusterIssuer.enabled: true
... clusterIssuer.secretId:
... clusterIssuer.secretKey:
... clusterIssuer.email:

helm upgrade --install --namespace cert-manager --create-namespace             \
    cert-manager-webhook-dnspod ./cert-manager-webhook-dnspod-1.5.2.tgz        \
    -f cert-manager-webhook-dnspod-1.5.2.tgz.helm-values.yaml

废弃 | cert-manager-webhook-dnspod | by qqshfox

使用 cert-manager 为 DNSPod 的域名签发免费证书

注意事项

我们找到其他的替代方案,所以暂时不再使用该组件。

该组件存在如下问题:

  • 该项目目前(04/23/2025)不太活跃,最后 df7a5bd 4 years ago 提交;
  • 该项目未提供 Chart 包,需要克隆仓库来完成安装。针对我们的场景,刚方式不便于管理;
  • 该组件需要 DNSPod 的 apiID、apiToken 参数,而该信息需要登陆主账号获取;

方案概述

方案

根据如下相对权威的官方文档指引,我们使用 qqshfox/cert-manager-webhook-dnspod 开源项目。

部署的大致过程如下:

  1. 腾讯云 / 公共 DNS / <右上角,我的帐号> / API 密钥 / DNSPod Token / 创建密钥,复制自动生成的 ID 和 Token 并保存。
  2. 在集群中,部署安装 Cert Manager 组件。
  3. 安装 DNSPod Webhook 组件,然后便可使用。

补充说明:
1)官方并未直接提供 Chart 包,所以使用仓库进行部署;
2)镜像:https://hub.docker.com/r/qqshfox/cert-manager-webhook-dnspod

安装过程

获取 apiID、apiToken 参数

  • 腾讯云 / 公共 DNS / <右上角> 我的帐号 / API 密钥;
  • DNSPod Token / 创建密钥,复制自动生成的 ID 和 Token 并保存。

获取 Chart 内容:

  • 我们直接下载 git clone master 分支代码。
  • 现在(04/10/2025)我们使用 Kubernetes 1.30 版本,如果使用 tag/0.3.3 则会因为 apiVersion 的原因导致部署失败,所以我们使用 Master 分支。

准备 Helm 配置:

groupName: example.your.domain                              # 写一个标识 group 的名称,可以任意写

secrets:                                                    # 将前面生成的 id 和 token 粘贴到下面
  apiID: "<ID>"
  apiToken: "<Token>"

clusterIssuer:
  enabled: true                                             # 自动创建出 ClusterIssuer 资源
  email: your@email.com                                     # 填写您的邮箱地址

部署 Chart 服务:

helm upgrade --install --namespace cert-manager --create-namespace    \
    cert-manager-webhook-dnspod                                       \
    ./cert-manager-webhook-dnspod-master/deploy/cert-manager-webhook-dnspod/ \
    -f dnspod-webhook-values.yaml

创建 clusterIssuer 资源(可选):

# 在 values.yaml 中,以配置 clusterIssuer.enabled: true 参数,所以已自动创建 ClusterIssuer 资源。
# 如下 Yaml 为其导出。

apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
  name: letsencrypt
spec:
  acme:
    email: '<email>'
    privateKeySecretRef:
      name: webhook-dnspod-letsencrypt
    server: https://acme-v02.api.letsencrypt.org/directory
    solvers:
    - dns01:
        webhook:
          config:
            apiID: '<apiID>'
            apiTokenSecretRef:                              # 通过 Secret 来引用 ApiToken 参数
              key: '<secret-key>'
              name: '<secret-name>'
          groupName: '<groupName>'
          solverName: dnspod

已知问题 | … main.go:103] Failed to get domain id com.cn.: strconv.ParseInt: parsing “”: invalid syntax …

# 09/19/2024

环境信息

https://github.com/qqshfox/cert-manager-webhook-dnspod/blob/master/main.go#L103

qqshfox/cert-manager-webhook-dnspod

git log => df7a5bda057e7bb7e384a2b2f3433284c909bfbe

问题描述

仅针对某个域名出现该问题,而其他域名并不存在该问题。

根据 Failed to get domain id com.cn. 日志,我们猜测是 dnspod webhook 通过 com.cn 来查询记录,而我们的是 example.com.cn 形式。但是我们并不拥有 com.cn 域名,进而导致错误。

我们并未直接解决该问题,转而使用 HTTP 01 完成 TLS 证书申请。

# 09/27/2024

部分域名,仍旧存在该问题。通过增加 GODEBUG=http2debug=1 环境变量,我们发现是 resolvedZone 参数的问题。

正常 … http2: server read frame DATA flags=END_STREAM stream=49 len=395 data=”{\”request\”:{\”uid\”:\”\”,\”action\”:\”Present\”,\”type\”:\”dns-01\”,\”dnsName\”:\”foo-h5.example.com.cn\”,\”key\”:\”YRgOZd9ogA0TvZ_NIYesogZvUIlpyuUkMfgub2Rw0wQ\”,\”resourceNamespace\”:\”cert-manager\”,\”resolvedFQDN\”:\”_acme-challenge.foo-h5.example.com.cn.\”,\”resolvedZone\”:\”example.” (139 bytes omitted) …

异常 … http2: server read frame DATA flags=END_STREAM stream=11 len=386 data=”{\”request\”:{\”uid\”:\”\”,\”action\”:\”Present\”,\”type\”:\”dns-01\”,\”dnsName\”:\”office.example.com.cn\”,\”key\”:\”dmwwLgIdvIQI5aSIOqNEkojV6cnivXZ3FYt3h4_xBvM\”,\”resourceNamespace\”:\”cert-manager\”,\”resolvedFQDN\”:\”_acme-challenge.office.example.com.cn.\”,\”resolvedZone\”:\”com.cn.\”,” (130 bytes omitted)

根据代码:

该文档描述 cert manager 是如何判断域名的。所以,我们感觉是 DNS Server 的问题。

进而,根据
Setting Nameservers for DNS01 Self Check 文档,我们修改 cert-manager 参数:

–dns01-recursive-nameservers=223.5.5.5:53,223.6.6.6:53

若通过 Helm Chart 部署,根据版本,可能需要修改 dns01RecursiveNameservers 参数。

至此,先前 DNS-01 Challenge 失败域名能够成功申请证书。