Certificate construct creates cert-manager Certificate resources for automatic TLS certificate provisioning and renewal using Let’s Encrypt.
Constructor
Parameters
The parent construct (typically
this in your chart).The application name, used for naming the certificate resource.
Host configuration containing:
host: The domain name (e.g.,"example.com")paths: Array of paths (not used by Certificate, but part of HostRules)isSubdomain: Whether this is a subdomain for certificate naming purposes
Behavior
TheCertificate construct:
- Generates certificate name: Uses
domainToCertName()to create a dash-separated name - Determines domain: Uses
removeSubdomain()ifisSubdomainis true - Creates wildcard certificate: Generates a certificate for both the domain and
*.domain - Stores in secret: Creates a Kubernetes secret named
{certName}-tls - Uses ClusterIssuer: References the
wildcard-letsencrypt-prodClusterIssuer - Removes extra labels: Strips
app.kubernetes.io/part-ofandapp.kubernetes.io/versionlabels
Certificate Naming
The certificate name and domain are determined by theisSubdomain flag:
When isSubdomain: false (default)
When isSubdomain: true
Usage Examples
Basic Certificate
example.com and *.example.com.
Subdomain Certificate
example.com and *.example.com (parent domain), which covers api.example.com.
Multiple Subdomains Sharing a Certificate
Certificate for Different Domains
Generated Kubernetes Resource
The construct generates a cert-manager Certificate resource:How It Works with Ingress
The Certificate construct works with the Ingress construct:- Certificate creates secret: The Certificate creates a secret (e.g.,
example-com-tls) - Ingress references secret: The Ingress uses the same secret name in its TLS configuration
- cert-manager manages renewal: cert-manager automatically renews certificates before expiration
ClusterIssuer
The Certificate uses thewildcard-letsencrypt-prod ClusterIssuer, which:
- Uses Let’s Encrypt production environment
- Configured for wildcard certificate issuance
- Handles ACME DNS-01 challenges
- Must be set up in your cluster before using this construct
Common Patterns
Pattern 1: Application with Single Domain
Pattern 2: Application with Multiple Subdomains
Pattern 3: Handled Automatically by Applications
In most cases, you don’t need to create Certificate resources manually. TheDjangoApplication and ReactApplication constructs handle certificate creation internally:
Troubleshooting
Certificate Not Issuing
Check the Certificate status:Verify ClusterIssuer Exists
Check cert-manager Logs
Related
- Ingress - Uses certificates for TLS
- DjangoApplication - Automatically creates certificates
- ReactApplication - Automatically creates certificates