我有 Cloudflare DNS 来管理我的域。我在 Cloudflare 中创建了一个 A-record *.play.mydomain.com。
在 Kubernetes (GKE) 中,我创建了 Issuer
apiVersion: certmanager.k8s.io/v1alpha1
kind: Issuer
metadata:
name: letsencrypt-prod-wildcard
namespace: default
spec:
acme:
server: https://acme-staging-v02.api.letsencrypt.org/directory
#server: https://acme-v02.api.letsencrypt.org/directory
email: myemain@gmail.com
# Name of a secret used to store the ACME account private key
privateKeySecretRef:
name: letsencrypt-prod-wildcard
# ACME DNS-01 provider configurations
dns01:
challenges
providers:
- name: cf-dns
cloudflare:
email: myimail@gmail.com
# A secretKeyRef to a cloudflare api key
apiKeySecretRef:
name: cloudflare-api-key
key: api-key.txt
我为 cloudflare 创建了秘密(cloudflare-api-key)
我还创建了通配符证书:
apiVersion: certmanager.k8s.io/v1alpha1
kind: Certificate
metadata:
name: wildcard-mydomain-com
namespace: default
spec:
secretName: wildcard-mydomain-com
issuerRef:
#name: letsencrypt-staging-wildcard
name: letsencrypt-prod-wildcard
commonName: '*.play.mydomain.com'
dnsNames:
- play.mydomain.com
acme:
config:
- dns01:
provider: cf-dns
domains:
- '*.play.mydomain.com'
- play.mydomain.com
证书生成成功。
Status:
Conditions:
Last Transition Time: 2019-04-13T00:49:00Z
Message: Certificate is up to date and has not expired
Reason: Ready
Status: True
Type: Ready
Not After: 2019-07-11T23:48:57Z
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Generated 4m5s cert-manager Generated new private key
Normal GenerateSelfSigned 4m5s cert-manager Generated temporary self signed certificate
Normal OrderCreated 4m5s cert-manager Created Order resource "wildcard-mydomain-com-880037411"
Normal OrderComplete 84s cert-manager Order "wildcard-mydomain-com-880037411" completed successfully
Normal CertIssued 84s cert-manager Certificate issued successfully
但在日志 cert-manager 我看到一个错误:
2019-04-13 04:49:00.078 GET
orders controller: Re-queuing item "default/wildcard-mydomain-com-880037411" due to error processing: challenges.certmanager.k8s.io "wildcard-mydomain-com-880037411-1" not found
我也有一个入口:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress-mydomain-com
annotations:
kubernetes.io/ingress.class: nginx
certmanager.k8s.io/issuer: letsencrypt-prod-wildcard
certmanager.k8s.io/acme-challenge-type: "dns01"
kubernetes.io/tls-acme: "true"
spec:
tls:
- secretName: letsencrypt-prod-secret-playground
hosts:
- '*.play.mydomain.com'
rules:
- host: '*.play.mydomain.com'
http:
paths:
- backend:
serviceName: playground
servicePort: 83
日志中出现错误(运行入口后):
2019-04-13 04:51:17.225 GET
orders controller: Re-queuing item "default/letsencrypt-prod-secret-playground-2579012660" due to error processing: Error constructing Challenge resource for Authorization: ACME server does not allow selected challenge type or no provider is configured for domain "play.mydomain.com"
如何在 kubernetes 中使用通配符证书 Let's Encrypt with cert-manager、nginx ingress、cloudflare?
我想要入口并启动许多子域([randomstring].play.mydomain.com)。