目前腾讯云 EKS 安装 cert-manager 和 alidns webhook 过程中会报错,只能使用 TKE
0. 准备工作
1. 安装 cert-manager
1
| kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.3.0/cert-manager.yaml
|
如果不能访问 github,则可以先下载文件到本地
2. 安装 alidns-webhook
1
| kubectl apply -f https://raw.githubusercontent.com/pragkent/alidns-webhook/master/deploy/bundle.yaml
|
如果不能访问 github,则可以先下载文件到本地,此步不能太快,需确保第1步安装 cert-manager 时,所有的 pod 都已经正常运行后,再安装 webhook,不然无法成功;当出现失败时,可删除整个 webhook deployment,再重新创建
3. 创建访问 AliDNS 解析用的账号密码
1 2 3 4 5 6 7 8
| apiVersion: v1 kind: Secret metadata: name: alidns-secret namespace: cert-manager data: access-key: YOUR_ID secret-key: YOUR_KEY
|
注:此处的 ID 和 KEY 需要先进行 base64 转码,除非将 data 字段改成 stringData
4. 创建 ClusterIssuer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| apiVersion: cert-manager.io/v1alpha2 kind: ClusterIssuer metadata: name: letsencrypt spec: acme: email: YOUR_EMAIL server: https://acme-v02.api.letsencrypt.org/directory privateKeySecretRef: name: letsencrypt-account-key solvers: - dns01: webhook: groupName: acme.yourcompany.com solverName: alidns config: region: "" accessKeySecretRef: name: alidns-secret key: access-key secretKeySecretRef: name: alidns-secret key: secret-key
|
5. 创建证书
1 2 3 4 5 6 7 8 9 10 11
| apiVersion: cert-manager.io/v1alpha2 kind: Certificate metadata: name: YOUR_CERT_NAME spec: secretName: www-example-com-tls dnsNames: - www.example.com issuerRef: name: letsencrypt kind: ClusterIssuer
|
如果创建过程中出现错误,可以使用 kubectl describe <资源类型> < 资源名称> ,根据显示的消息,进行错误排查,例如:
kubectl desribe certificate example
kubectl describe ClusterIssuer example
详细排查办法查看以下链接:https://cert-manager.io/docs/faq/acme/