SSL/TLS Module (Cert-Manager)
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
Complete guide to deploying and managing SSL/TLS certificates with automatic renewal, Let’s Encrypt integration, and certificate lifecycle management.
🏗️ Overview
Section titled “🏗️ Overview”The Cert-Manager module provides automated certificate management for Kubernetes clusters. It handles the issuance, renewal, and lifecycle management of SSL/TLS certificates from various certificate authorities, with seamless integration to Let’s Encrypt for free certificates.
Architecture Components
Section titled “Architecture Components”Cert-Manager Deployment:├── Cert-Manager Controller├── Webhook Server├── CA Injector├── Cluster Issuers├── Certificate Resources├── HTTP-01 Challenge Solver└── DNS-01 Challenge Solver
🚀 Features
Section titled “🚀 Features”Automated Certificate Management
Section titled “Automated Certificate Management”- Automatic Issuance: Request and obtain certificates automatically
- Auto-Renewal: Proactive certificate renewal before expiration
- Lifecycle Management: Complete certificate lifecycle handling
- Multiple CAs: Support for Let’s Encrypt, self-signed, and custom CAs
Let’s Encrypt Integration
Section titled “Let’s Encrypt Integration”- Free Certificates: Zero-cost SSL/TLS certificates
- HTTP-01 Challenges: Domain validation via HTTP challenges
- DNS-01 Challenges: Domain validation via DNS challenges
- Rate Limiting: Built-in rate limit handling
Advanced Features
Section titled “Advanced Features”- Wildcard Certificates: Support for wildcard domain certificates
- Certificate Storage: Secure certificate storage in Kubernetes secrets
- Monitoring: Certificate status monitoring and alerting
- Webhook Integration: Custom validation and approval workflows
📦 Deployment Configuration
Section titled “📦 Deployment Configuration”Helmfile Configuration
Section titled “Helmfile Configuration”The Cert-Manager deployment uses Helmfile for environment management:
repositories: - name: jetstack url: "https://charts.jetstack.io"
releases: - name: cert-manager namespace: cert-manager createNamespace: true chart: jetstack/cert-manager version: v1.17.2
- name: issuer chart: ./ssl-middleware namespace: default values:
Core Configuration Values
Section titled “Core Configuration Values”
Cluster Issuer Configuration
Section titled “Cluster Issuer Configuration”apiVersion: cert-manager.io/v1kind: ClusterIssuermetadata: name: letsencrypt annotations: "helm.sh/hook": "post-install" "helm.sh/hook-weight": "0"spec: acme: email: { { .Values.email } } server: https://acme-v02.api.letsencrypt.org/directory privateKeySecretRef: name: letsencrypt-prod solvers: - http01: ingress: ingressClassName: traefik
Middleware Configuration
Section titled “Middleware Configuration”apiVersion: traefik.io/v1alpha1kind: Middlewaremetadata: name: redirect-httpsspec: redirectScheme: scheme: https permanent: true
🔧 Certificate Configuration
Section titled “🔧 Certificate Configuration”Certificate Resource
Section titled “Certificate Resource”# Example certificate requestapiVersion: cert-manager.io/v1kind: Certificatemetadata: name: myapp-cert namespace: defaultspec: secretName: myapp-tls issuerRef: name: letsencrypt kind: ClusterIssuer dnsNames: - myapp.example.com - www.myapp.example.com duration: 2160h # 90 days renewBefore: 360h # 15 days
Ingress Integration
Section titled “Ingress Integration”# Ingress with automatic certificateapiVersion: networking.k8s.io/v1kind: Ingressmetadata: name: myapp-ingress annotations: cert-manager.io/cluster-issuer: "letsencrypt" traefik.ingress.kubernetes.io/router.entrypoints: "websecure" traefik.ingress.kubernetes.io/router.tls: "true"spec: tls: - hosts: - myapp.example.com secretName: myapp-tls rules: - host: myapp.example.com http: paths: - path: / pathType: Prefix backend: service: name: myapp-service port: number: 80
Wildcard Certificate
Section titled “Wildcard Certificate”# Wildcard certificate with DNS-01 challengeapiVersion: cert-manager.io/v1kind: Certificatemetadata: name: wildcard-certspec: secretName: wildcard-tls issuerRef: name: letsencrypt-dns kind: ClusterIssuer dnsNames: - "*.example.com" - example.com
📊 Monitoring & Metrics
Section titled “📊 Monitoring & Metrics”Health Checks
Section titled “Health Checks”# Check Cert-Manager service statuskubectl get pods -n cert-manager -l app.kubernetes.io/name=cert-manager
# Check service endpointskubectl get endpoints -n cert-manager -l app.kubernetes.io/name=cert-manager
# Test Cert-Manager APIkubectl get crd | grep cert-manager
Certificate Status
Section titled “Certificate Status”# List all certificateskubectl get certificates --all-namespaces
# Check certificate statuskubectl describe certificate myapp-cert -n default
# View certificate eventskubectl get events --field-selector involvedObject.name=myapp-cert -n default
# Check certificate secretkubectl get secret myapp-tls -n default -o yaml
Cluster Issuer Status
Section titled “Cluster Issuer Status”# List cluster issuerskubectl get clusterissuer
# Check issuer statuskubectl describe clusterissuer letsencrypt
# View issuer eventskubectl get events --field-selector involvedObject.name=letsencrypt
Performance Monitoring
Section titled “Performance Monitoring”# Check resource usagekubectl top pods -n cert-manager -l app.kubernetes.io/name=cert-manager
# Monitor certificate renewalskubectl get events --field-selector reason=Renewed -n default
# Check for failed certificate requestskubectl get events --field-selector reason=Failed -n default
Log Analysis
Section titled “Log Analysis”# View Cert-Manager logskubectl logs -n cert-manager -l app.kubernetes.io/name=cert-manager
# Follow logs in real-timekubectl logs -f -n cert-manager deployment/cert-manager
# Check for errorskubectl logs -n cert-manager -l app.kubernetes.io/name=cert-manager | grep ERROR
🚀 Deployment
Section titled “🚀 Deployment”Deploy Cert-Manager Module
Section titled “Deploy Cert-Manager Module”# Navigate to module directorycd iac/modules/cert-manager
# Install CRDs firsttask install
# Deploy using Helmfilehelmfile apply
# Verify deploymentkubectl get pods -n cert-managerkubectl get pods -n default -l app.kubernetes.io/name=issuer
Verify Deployment
Section titled “Verify Deployment”# Check pod statuskubectl get pods -n cert-manager -l app.kubernetes.io/name=cert-manager
# Verify CRDs installedkubectl get crd | grep cert-manager
# Check cluster issuerkubectl get clusterissuer letsencrypt
# Test certificate issuancekubectl apply -f - <<EOFapiVersion: cert-manager.io/v1kind: Certificatemetadata: name: test-certspec: secretName: test-tls issuerRef: name: letsencrypt kind: ClusterIssuer dnsNames: - test.example.comEOF
Post-Deployment Setup
Section titled “Post-Deployment Setup”# Verify cluster issuer is readykubectl describe clusterissuer letsencrypt
# Check for any pending certificateskubectl get certificates --all-namespaces
# Monitor certificate eventskubectl get events --field-selector involvedObject.kind=Certificate
🔧 Maintenance Operations
Section titled “🔧 Maintenance Operations”Certificate Management
Section titled “Certificate Management”# List all certificateskubectl get certificates --all-namespaces
# Check certificate detailskubectl describe certificate myapp-cert -n default
# Force certificate renewalkubectl patch certificate myapp-cert -n default -p '{"spec":{"renewBefore":"720h"}}'
# Delete certificatekubectl delete certificate myapp-cert -n default
Cluster Issuer Management
Section titled “Cluster Issuer Management”# List cluster issuerskubectl get clusterissuer
# Update cluster issuer
# Check issuer statuskubectl describe clusterissuer letsencrypt
Certificate Cleanup
Section titled “Certificate Cleanup”# List all certificate secretskubectl get secrets --all-namespaces | grep tls
# Clean up expired certificateskubectl get certificates --all-namespaces -o json | \ jq '.items[] | select(.status.conditions[].status == "False") | .metadata.name'
# Delete unused certificate secretskubectl delete secret unused-tls -n default
Update Operations
Section titled “Update Operations”# Update Cert-Manager versionhelmfile apply
# Monitor update progresskubectl rollout status deployment/cert-manager -n cert-manager
# Rollback if neededkubectl rollout undo deployment/cert-manager -n cert-manager
🚨 Troubleshooting
Section titled “🚨 Troubleshooting”Common Issues
Section titled “Common Issues”1. Certificate Issuance Problems
Section titled “1. Certificate Issuance Problems”# Check certificate statuskubectl describe certificate myapp-cert -n default
# View certificate eventskubectl get events --field-selector involvedObject.name=myapp-cert -n default
# Check challenge statuskubectl get challenges --all-namespaces
# Verify ingress configurationkubectl describe ingress myapp-ingress -n default
2. HTTP-01 Challenge Issues
Section titled “2. HTTP-01 Challenge Issues”# Check challenge podkubectl get pods --all-namespaces | grep cm-acme-http-solver
# Check challenge servicekubectl get services --all-namespaces | grep cm-acme-http-solver
# Verify ingress configurationkubectl get ingress --all-namespaces -o yaml | grep -A 10 -B 10 cm-acme-http-solver
# Test challenge endpointcurl -I http://myapp.example.com/.well-known/acme-challenge/test
3. DNS-01 Challenge Issues
Section titled “3. DNS-01 Challenge Issues”# Check DNS provider configurationkubectl describe clusterissuer letsencrypt-dns
# Verify DNS recordsdig TXT _acme-challenge.example.com
# Check DNS provider credentialskubectl get secret cloudflare-api-token -n cert-manager -o yaml
4. Rate Limiting Issues
Section titled “4. Rate Limiting Issues”# Check Let's Encrypt rate limitskubectl get events --field-selector reason=RateLimited
# Monitor certificate requestskubectl get certificates --all-namespaces
# Check for duplicate requestskubectl get orders --all-namespaces
Recovery Procedures
Section titled “Recovery Procedures”Emergency Recovery
Section titled “Emergency Recovery”# Force delete stuck certificateskubectl delete certificate myapp-cert -n default --grace-period=0 --force
# Restart Cert-Managerkubectl rollout restart deployment/cert-manager -n cert-manager
# Clear challenge resourceskubectl delete challenges --all --all-namespaceskubectl delete orders --all --all-namespaces
# Verify recoverykubectl get certificates --all-namespaces
🔒 Security Configuration
Section titled “🔒 Security Configuration”Network Security
Section titled “Network Security”# Network policy for Cert-ManagernetworkPolicy: enabled: true allowExternal: true egressRules: - to: - ipBlock: cidr: 0.0.0.0/0 except: - 10.0.0.0/8 - 172.16.0.0/12 - 192.168.0.0/16
RBAC Configuration
Section titled “RBAC Configuration”# Service account permissionsserviceAccount: create: true annotations: {} automountServiceAccountToken: true
# RBAC rulesrbac: create: true rules: - apiGroups: ["cert-manager.io"] resources: ["certificates", "certificaterequests", "issuers"] verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
Certificate Security
Section titled “Certificate Security”# Certificate security settingscertificate: duration: 2160h # 90 days renewBefore: 360h # 15 days keyAlgorithm: RSA keySize: 2048 keyEncoding: PKCS1
📝 Configuration Examples
Section titled “📝 Configuration Examples”Production Configuration
Section titled “Production Configuration”# Production-ready configurationreplicaCount: 2
resources: requests: memory: 256Mi cpu: 100m limits: memory: 512Mi cpu: 200m
# High availabilitypodDisruptionBudget: enabled: true minAvailable: 1
# Monitoringmetrics: enabled: true serviceMonitor: enabled: true
Staging Configuration
Section titled “Staging Configuration”# Staging environment with Let's Encrypt stagingapiVersion: cert-manager.io/v1kind: ClusterIssuermetadata: name: letsencrypt-stagingspec: acme: server: https://acme-staging-v02.api.letsencrypt.org/directory privateKeySecretRef: name: letsencrypt-staging solvers: - http01: ingress: ingressClassName: traefik
Custom CA Configuration
Section titled “Custom CA Configuration”# Custom certificate authorityapiVersion: cert-manager.io/v1kind: ClusterIssuermetadata: name: custom-caspec: ca: secretName: custom-ca-secret
🔄 Maintenance Schedule
Section titled “🔄 Maintenance Schedule”Daily Tasks
Section titled “Daily Tasks”- Monitor certificate status
- Check for failed renewals
- Review certificate events
- Verify cluster health
Weekly Tasks
Section titled “Weekly Tasks”- Analyze certificate metrics
- Review certificate inventory
- Update issuer configurations
- Check for updates
Monthly Tasks
Section titled “Monthly Tasks”- Certificate inventory audit
- Security review
- Performance optimization
- Disaster recovery testing
📋 Operational Checklist
Section titled “📋 Operational Checklist”Pre-Deployment
Section titled “Pre-Deployment”- CRDs installed
- Namespace created
- RBAC configured
- Network policies defined
- Email address configured
Post-Deployment
Section titled “Post-Deployment”- Cert-Manager pods running
- Cluster issuer configured
- Webhook functional
- Test certificate issued
- Ingress integration verified
Regular Maintenance
Section titled “Regular Maintenance”- Certificate renewals monitored
- Rate limits respected
- Security updates applied
- Performance optimized
- Disaster recovery tested
🔗 Related Documentation
Section titled “🔗 Related Documentation”- Ingress Configuration - SSL/TLS integration
- Security Guide - Certificate security
- Monitoring Guide - Certificate monitoring
- Troubleshooting Guide - Certificate issues
The Cert-Manager SSL/TLS module provides automated certificate management with Let’s Encrypt integration and comprehensive lifecycle management.