使用云 DNS 在 GKE 上配置证书管理器

cert-mananger configuration on GKE with clouddns

所以我希望使用 google clouddns 在 GKE 上设置证书管理器。似乎很多关于 SO 的旧问题都在使用 http01 而不是 dns01。我想确保一切正确,这样我就不会受到速率限制。

这是我的 issuer.yaml

apiVersion: cert-manager.io/v1alpha2
kind: Issuer
metadata:
  name: letsencrypt-staging
spec:
  acme:
    server: https://acme-staging-v02.api.letsencrypt.org/directory
    email: engineering@company.com 
    privateKeySecretRef:
      name: letsencrypt-staging
    solvers:
    - dns01:
        clouddns:
          project: MY-GCP_PROJECT
          # This is the secret used to access the service account
          serviceAccountSecretRef:
            name: clouddns-dns01-solver-svc-acct
            key: key.json

这是我的 certificate.yaml

apiVersion: cert-manager.io/v1alpha2
kind: Certificate
metadata:
  name: my-website
  namespace: default
spec:
  secretName: my-website-tls
  issuerRef:
    # The issuer created previously
    name: letsencrypt-staging
  dnsNames:
  - my.website.com 

我运行这些命令来配置所有内容:

kubectx my-cluster
kubectl apply --validate=false -f https://github.com/jetstack/cert-manager/releases/download/v0.15.1/cert-manager.yaml
kubectl get pods --namespace cert-manager
gcloud iam service-accounts create dns01-solver --display-name "dns01-solver"
gcloud projects add-iam-policy-binding $PROJECT_ID --member serviceAccount:dns01-solver@$PROJECT_ID.iam.gserviceaccount.com --role roles/dns.admin
gcloud iam service-accounts keys create key.json --iam-account dns01-solver@$PROJECT_ID.iam.gserviceaccount.com
kubectl create secret generic clouddns-dns01-solver-svc-acct --from-file=key.json
kubectl apply -f issuer.yaml
kubectl apply -f certificate.yaml

这是 kubectl describe certificaterequests

的输出
Name:         my-certificaterequests
Namespace:    default
Labels:       <none>
Annotations:  cert-manager.io/certificate-name: my-website
              cert-manager.io/private-key-secret-name: my-website-tls
              kubectl.kubernetes.io/last-applied-configuration:
                {"apiVersion":"cert-manager.io/v1alpha2","kind":"Certificate","metadata":{"annotations":{},"name":"my-cluster","namespace":"default...
API Version:  cert-manager.io/v1alpha3
Kind:         CertificateRequest
Metadata:
  Creation Timestamp:  2020-06-28T00:05:55Z
  Generation:          1
  Owner References:
    API Version:           cert-manager.io/v1alpha2
    Block Owner Deletion:  true
    Controller:            true
    Kind:                  Certificate
    Name:                  my-cluster
    UID:                   81efe2fd-5f58-4c84-ba25-dd9bc63b032a
  Resource Version:        192470614
  Self Link:               /apis/cert-manager.io/v1alpha3/namespaces/default/certificaterequests/my-certificaterequests
  UID:                     8a0c3e2d-c48e-4cda-9c70-b8dcfe94f14c
Spec:
  Csr:  ...
  Issuer Ref:
    Name:  letsencrypt-staging
Status:
  Certificate: ...
  Conditions:
    Last Transition Time:  2020-06-28T00:07:51Z
    Message:               Certificate fetched from issuer successfully
    Reason:                Issued
    Status:                True
    Type:                  Ready
Events:
  Type    Reason             Age   From          Message
  ----    ------             ----  ----          -------
  Normal  OrderCreated       16m   cert-manager  Created Order resource default/my-certificaterequests-484284207
  Normal  CertificateIssued  14m   cert-manager  Certificate fetched from issuer successfully

我看到了秘密kubectl get secret my-website-tls

NAME                    TYPE                DATA   AGE
my-website-tls   kubernetes.io/tls   3      18m

这是否意味着一切正常,我应该在产品中尝试一下?让我担心的是,我在我的云控制台中没有看到任何 DNS 记录发生变化。

另外我想确认一下:

如有任何见解,我们将不胜感激。谢谢

我已经在 Slack 上回答了你。如果使用 ingress-shim,您可以通过更改证书的 dnsNames 部分或 spec.tls.*.hosts 部分中的值来更改名称,您只需完全按照您显示的那样包含通配符名称。