cheslijones
cheslijones

Reputation: 9194

Can't get a TLS certificate in cert-manager

So that is what I have and what I've done... pretty much following the latest documentation and some tutorials I came across:

  1. Install the cert-manager namespace:
   kubectl create namespace cert-manager
  1. Install cert-manager:
   kubectl apply --validate=false -f https://github.com/jetstack/cert-manager/releases/download/v0.13.0/cert-manager.yaml
  1. Verify installation... should be three running Pods and there are:
   kubectl get pods --namespace cert-manager
  1. Run test to make sure it is able to issue certificate types... passes.

  2. Make an issuer.yaml:

apiVersion: cert-manager.io/v1alpha2
kind: ClusterIssuer
metadata:
  name: letsencrypt-staging
spec:
  acme:
    server: https://acme-staging-v02.api.letsencrypt.org/directory
    email: '[email protected]'
    privateKeySecretRef:
      name: letsencrypt-staging
    solvers:
      - http01:
          ingress:
            class: nginx
  1. Make a certificate.yaml:
apiVersion: cert-manager.io/v1alpha2
kind: Certificate
metadata:
  name: examplewebsite-com-tls
spec:
  secretName: examplewebsite-com
  issuerRef:
    name: letsencrypt-staging
    kind: ClusterIssuer
  commonName: examplewebsite.com
  dnsNames:
    - test.examplewebsite.com
  acme:
    config:
      - http01:
          ingressClass: nginx
        domains:
          - test.examplewebsite.com
  1. Update ingress.yaml to reflect this:
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/add-base-url: "true"
    nginx.ingress.kubernetes.io/rewrite-target: /$1
    cert-manager.io/cluster-issuer: "letsencrypt-staging"
    nginx.ingress.kubernetes.io/ssl-redirect: 'false'
  name: ingress-service
  namespace: default
spec:
  tls:
    - hosts:
        - test.examplewebsite.com"
      secretName: examplewebsite-com
  rules:
    - host: test.examplewebsite.com
      http:
        paths:
          - path: /?(.*)
            backend:
              serviceName: client-cluster-ip-service
              servicePort: 3000
          - path: /api/?(.*)
            backend:
              serviceName: api-cluster-ip-service
              servicePort: 5000

Apply all of these and run into the following issues.

$ kubectl describe certificate examplewebsite-com-tls

Status:
  Conditions:
    Last Transition Time:  2020-01-28T23:52:45Z
    Message:               Waiting for CertificateRequest "examplewebsite-com-tls-2527238951" to complete
    Reason:                InProgress
    Status:                False
    Type:                  Ready
Events:
  Type    Reason     Age   From          Message
  ----    ------     ----  ----          -------
  Normal  Requested  117s  cert-manager  Created new CertificateRequest resource "examplewebsite-com-tls-2527238951"

And it just sits there indefinitely.

$ kubectl describe secret examplewebsite-com`

Type:  kubernetes.io/tls

Data
====
ca.crt:   0 bytes
tls.crt:  0 bytes
tls.key:  1675 bytes

DNS is setup properly because I can navigate to the website and see the application, HTTPS:// just doesn't work.

What am I doing wrong here?

Upvotes: 1

Views: 3095

Answers (1)

cheslijones
cheslijones

Reputation: 9194

The certification.yaml is not necessary at all.

Really, only needed this after following the installation instructions:

apiVersion: cert-manager.io/v1alpha2
kind: ClusterIssuer
metadata:
  name: letsencrypt-prod
  namespace: cert-manager
spec:
  acme:
    server: https://acme-v02.api.letsencrypt.org/directory
    email: <email>
    privateKeySecretRef:
      name: letsencrypt-prod
    solvers:
      - http01:
          ingress:
            class: nginx

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/add-base-url: "true"
    nginx.ingress.kubernetes.io/rewrite-target: /$1
    cert-manager.io/cluster-issuer: "letsencrypt-prod"
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
  name: ingress
  namespace: default
spec:
  tls:
    - hosts:
        - test.domain.com
      secretName: test-domain-com
  rules:
    - host: test.domain.com
      http:
        paths:
          - path: /?(.*)
            backend:
              serviceName: client-cluster-ip-service
              servicePort: 3000
          - path: /api/?(.*)
            backend:
              serviceName: api-cluster-ip-service
              servicePort: 5000

Very well written and current (as of 1/30/20) tutorial here:

https://www.digitalocean.com/community/tutorials/how-to-set-up-an-nginx-ingress-with-cert-manager-on-digitalocean-kubernetes

Upvotes: 1

Related Questions