
cert-manager is a Kubernetes-native certificate management controller that automates the issuance and renewal of SSL/TLS certificates. It integrates with multiple Certificate Authorities (CAs), including Let's Encrypt, HashiCorp Vault, and private Public Key Infrastructure (PKI) systems. cert-manager stores issued certificates as Kubernetes secrets, enabling seamless integration with Ingress controllers and other cluster workloads for secure TLS connections.
This article explains how to deploy cert-manager in a Kubernetes cluster and manage SSL certificates for securing applications. It covers installation using kubectl or Helm, configuring Issuers and ClusterIssuers, deploying a sample application with Traefik as the Ingress controller, and generating trusted Let's Encrypt SSL certificates.
Before you begin, you need to:
certman.example.com).cert-manager requires Custom Resource Definitions (CRDs) to define its certificate-related resources in the cluster. Install the CRDs first, then install cert-manager using either kubectl or Helm.
Apply the cert-manager CRDs. Replace v1.20.2 with the latest stable version from the cert-manager releases page.
Verify the CRDs are registered.
The output lists all cert-manager CRDs including certificates.cert-manager.io, issuers.cert-manager.io, and clusterissuers.cert-manager.io.
Install the cert-manager controller using either of the following methods.
Apply the cert-manager manifest. Replace v1.20.2 with the latest stable version from the releases page.
Wait for the cert-manager pods to be ready.
The output shows all pods with Running status. Press Ctrl+C to exit the watch.
Verify that the cert-manager API is available.
cert-manager uses Issuers to sign and generate SSL certificates using a Certificate Authority (CA). A ClusterIssuer can sign certificates in any namespace, while an Issuer can only sign certificates within its own namespace.
A ClusterIssuer is a cluster-wide resource that can issue certificates to any namespace.
Create a cluster-issuer.yaml file.
Add the following configuration.
Save and close the file.
The above configuration creates a ClusterIssuer that references a CA keypair stored in the example-ca-secret secret. The secret must exist in the cert-manager namespace before the ClusterIssuer can issue certificates.
Apply the configuration.
Verify the ClusterIssuer is created.
The output shows example-issuer with False in the READY column until the referenced secret is created.
An Issuer is a namespace-scoped resource that can only issue certificates within its namespace.
Create an issuer.yaml file.
Add the following configuration. Replace default with your target namespace if different.
Save and close the file.
The above configuration creates an Issuer in the default namespace that references the ca-key-pair secret for signing certificates.
Apply the configuration.
Verify the Issuer is created.
The output shows ca-issuer with False in the READY column until the referenced secret is created.
Use a ClusterIssuer when you need to issue certificates across multiple namespaces. Use an Issuer when certificates should be scoped to a single namespace for isolation.
Deploy a sample application with an Ingress controller to demonstrate SSL certificate usage. Traefik serves as the Ingress controller to handle incoming HTTPS traffic.
Add the Traefik Helm repository.
Update the local Helm repository index.
Install Traefik.
Wait at least 3 minutes for the LoadBalancer to provision, then retrieve the external IP address.
The output displays the EXTERNAL-IP column with your public IP address. If it shows <pending>, wait a few more minutes.
Log in to your DNS provider (such as Vultr DNS) and create a DNS A record pointing your domain (for example, certman.example.com) to the LoadBalancer's external IP address.
Create a sample-app.yaml file to define the application deployment and service.
Add the following configuration.
Save and close the file.
The above configuration deploys a simple HTTP echo application that displays "Greetings from Vultr!" when accessed.
Apply the configuration.
Verify the deployment is running.
The output shows sample-app with 1/1 in the READY column.
cert-manager supports Automated Certificate Management Environment (ACME) providers like Let's Encrypt for issuing trusted SSL certificates. The HTTP-01 challenge verifies domain ownership by responding to requests on a well-known path.
Create a letsencrypt-issuer.yaml file.
Add the following configuration. Replace admin@example.com with your active email address.
Save and close the file.
The above configuration creates a ClusterIssuer that:
letsencrypt-prod-key.Apply the configuration.
Verify the ClusterIssuer is ready.
The output shows True in the READY column.
Create a certificate.yaml file to request an SSL certificate. Replace certman.example.com with your domain.
Add the following configuration.
Save and close the file.
Apply the configuration.
Certificate generation may take up to 3-5 minutes while cert-manager completes the ACME challenge. Wait for the certificate to be ready before proceeding.
Verify the certificate is issued.
The output shows certman-example-cert with True in the READY column.
Create a sample-app-ingress.yaml file to route traffic to the application with TLS.
Add the following configuration. Replace certman.example.com with your actual domain.
Save and close the file.
The above configuration routes HTTPS traffic for your domain to the sample application using the generated TLS certificate.
Apply the configuration.
Open a web browser and navigate to https://certman.example.com. Replace certman.example.com with your configured domain.
The browser displays "Greetings from Vultr!" with a valid SSL certificate indicated by the lock icon.
Validate the cert-manager deployment by testing certificate operations.
Check the certificate status using cmctl.
The output displays detailed certificate information including the issuer, expiration date, and secret name.
Inspect the certificate details.
The output shows the certificate events including issuance and any renewal activity.
Test manual certificate renewal.
Verify the certificate secret contains the TLS data.
The following sections cover common cert-manager issues and their solutions.
Check the certificate request status and events.
Common causes include:
dig certman.example.com.Check the ClusterIssuer status and events.
Common causes include:
acme-v02.api.letsencrypt.org.Check the pod logs for errors.
Common causes include:
--set crds.enabled=true.cert-manager automatically renews certificates 30 days before expiration. Check renewal status.
Force a renewal if needed.
You have deployed cert-manager in a Kubernetes cluster and configured it to issue SSL certificates using Let's Encrypt. The setup includes a ClusterIssuer for ACME certificate management, a sample application secured with TLS, and Traefik as the Ingress controller for routing HTTPS traffic. cert-manager automatically renews certificates before expiration, ensuring continuous TLS protection for your applications. For advanced configurations including DNS01 challenges, Vault integration, and certificate policies, refer to the official cert-manager documentation.
0 Comments
Be the first to comment and share your perspective with the community.