DocsEmissary-ingressUsing cert-manager
Using cert-manager
Ambassador Edge Stack has simple and easy built-in support for automatically using ACME with the
http-01
challenge to create and renew TLS certificates. However, this support is not available
in Emissary-ingress, and it is limited to the ACME http-01
challenge type. If you're running
Emissary-ingress, or if you require more flexible certificate management (such as using ACME's
dns-01
challenge, or using a non-ACME certificate source), external certificate management
tools are also supported.
One such tool is Jetstack's cert-manager, which is a general-purpose tool for managing certificates in Kubernetes. Cert-manager will automatically create and renew TLS certificates and store them as Kubernetes secrets for easy use in a cluster. Emissary-ingress will automatically watch for secret changes and reload certificates upon renewal.
Note: This document assumes cert-manager v0.15 or greater. This document has been updated to use CRD standards specified in v0.15. Legacy CRD support was removed in cert-manager v0.15, see their upgrading document for more info.
Install cert-manager
There are many different ways to install cert-manager. For simplicity, we will use Helm.
Create the cert-manager CRDs.
Add the
jetstack
Helm repository.Install cert-manager.
Issuing certificates
cert-manager issues certificates from a CA such as Let's Encrypt. It does this using the ACME protocol which supports various challenge mechanisms for verifying ownership of the domain.
Issuer
An Issuer
or ClusterIssuer
identifies which Certificate Authority cert-manager will use to issue a certificate. Issuer
is a namespaced resource allowing you to use different CAs in each namespace, a ClusterIssuer
is used to issue certificates in any namespace. Configuration depends on which ACME challenge you are using.
Certificate
A Certificate is a namespaced resource that references an Issuer
or ClusterIssuer
for issuing certificates. Certificate
s define the DNS name(s) a key and certificate should be issued for, as well as the secret to store those files (e.g. ambassador-certs
). Configuration depends on which ACME challenge you are using.
By duplicating issuers, certificates, and secrets one can support multiple domains with SNI.
Challenge
cert-manager supports two kinds of ACME challenges that verify domain ownership in different ways: HTTP-01 and DNS-01.
DNS-01 challenge
The DNS-01 challenge verifies domain ownership by proving you have control over its DNS records. Issuer configuration will depend on your DNS provider. This example uses AWS Route53.
Create the IAM policy specified in the cert-manager AWS Route53 documentation.
Note the
accessKeyID
and create asecret
namedprod-route53-credentials-secret
in the cert-manager namespace that has a key value:secret-access-key
from your AWS IaM credentials.Create and apply a
ClusterIssuer
.Create and apply a
Certificate
.Verify the secret is created.
HTTP-01 challenge
The HTTP-01 challenge verifies ownership of the domain by sending a request for a specific file on that domain. cert-manager accomplishes this by sending a request to a temporary pod with the prefix /.well-known/acme-challenge/
. To perform this challenge:
Create and apply a
ClusterIssuer
.Create and apply a
Certificate
.Apply both the
ClusterIssuer
andCertificate
After applying both of these YAML manifests, you will notice that cert-manager has spun up a temporary pod named
cm-acme-http-solver-xxxx
but no certificate has been issued. Check the cert-manager logs and you will see a log message that looks like this:Create a Mapping for the
/.well-known/acme-challenge/
route.cert-manager uses an
Ingress
to issue the challenge to/.well-known/acme-challenge/
that is incompatible with Ambassador. We will need to create aMapping
so the cert-manager can reach the temporary pod.Apply the YAML and wait a couple of minutes. cert-manager will retry the challenge and issue the certificate.
Verify the secret is created: