# Certctl Helm Deployment Guide Complete guide for deploying certctl on Kubernetes with Helm. ## Table of Contents 1. [Prerequisites](#prerequisites) 2. [Installation Methods](#installation-methods) 3. [Production Deployment](#production-deployment) 4. [Configuration Examples](#configuration-examples) 5. [Post-Deployment Setup](#post-deployment-setup) 6. [Monitoring and Logging](#monitoring-and-logging) 7. [Maintenance](#maintenance) ## Prerequisites ### Required Tools ```bash # Verify Kubernetes cluster access kubectl cluster-info kubectl get nodes # Install Helm (if not already installed) curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash helm version # Verify Helm installation helm repo list ``` ### Kubernetes Requirements - Kubernetes 1.19 or later - At least 2GB available memory - At least 10GB available storage (for PostgreSQL) - Network policies support (optional, for security) - Ingress controller (nginx, istio, etc.) - optional ### Create Namespace ```bash # Create isolated namespace kubectl create namespace certctl # Set as default namespace kubectl config set-context --current --namespace=certctl # Label for network policies (optional) kubectl label namespace certctl certctl-ns=true ``` ## Installation Methods ### Method 1: Minimal Development Setup Perfect for testing and development: ```bash # Install with minimal configuration helm install certctl certctl/certctl \ --namespace certctl \ --set server.auth.apiKey="dev-key-change-in-production" \ --set postgresql.auth.password="dev-password-change-in-production" # Wait for deployment kubectl rollout status deployment/certctl-server kubectl rollout status statefulset/certctl-postgres ``` ### Method 2: Production HA Setup For production workloads: ```bash # Generate secure credentials API_KEY=$(openssl rand -base64 32) DB_PASSWORD=$(openssl rand -base64 32) # Install with HA configuration helm install certctl certctl/certctl \ --namespace certctl \ --values deploy/helm/examples/values-prod-ha.yaml \ --set server.auth.apiKey="$API_KEY" \ --set postgresql.auth.password="$DB_PASSWORD" ``` ### Method 3: External PostgreSQL Using managed database service: ```bash # Install with external database helm install certctl certctl/certctl \ --namespace certctl \ --values deploy/helm/examples/values-external-db.yaml \ --set server.auth.apiKey="$API_KEY" \ --set 'server.env.CERTCTL_DATABASE_URL=postgres://user:pass@db.example.com:5432/certctl?sslmode=require' ``` ### Method 4: Using Custom values.yaml Recommended for GitOps workflows: ```bash # Create values file with secrets management cat > /tmp/certctl-values.yaml < 0 for: 1h annotations: summary: "{{ \$value }} certificates expiring soon" EOF ``` ## Maintenance ### Scaling ```bash # Scale server replicas helm upgrade certctl certctl/ \ --set server.replicas=5 # Scale agents (Deployment kind only) helm upgrade certctl certctl/ \ --set agent.kind=Deployment \ --set agent.replicas=10 ``` ### Updating ```bash # Update chart version helm repo update helm upgrade certctl certctl/certctl \ --namespace certctl \ -f values.yaml # Verify update kubectl rollout status deployment/certctl-server kubectl rollout status statefulset/certctl-postgres ``` ### Backup and Restore ```bash # Backup PostgreSQL data kubectl exec -i $(kubectl get pods -l app.kubernetes.io/component=postgres -o jsonpath='{.items[0].metadata.name}') \ pg_dump -U certctl certctl | gzip > certctl-backup.sql.gz # Restore from backup zcat certctl-backup.sql.gz | kubectl exec -i $(kubectl get pods -l app.kubernetes.io/component=postgres -o jsonpath='{.items[0].metadata.name}') \ psql -U certctl certctl # Backup PVC data kubectl get pvc kubectl exec -i $(kubectl get pods -l app.kubernetes.io/component=postgres -o jsonpath='{.items[0].metadata.name}') \ tar czf - /var/lib/postgresql/data | gzip > certctl-data-backup.tar.gz ``` ### Uninstall ```bash # Remove Helm release (keeps PVCs by default) helm uninstall certctl --namespace certctl # Delete PVCs if needed kubectl delete pvc --all -n certctl # Delete namespace kubectl delete namespace certctl ``` ## Troubleshooting See [README.md](README.md#troubleshooting) for detailed troubleshooting steps. Common commands: ```bash # Get all resources kubectl get all -n certctl # Describe pod for events kubectl describe pod -n certctl # Stream logs kubectl logs -f -n certctl # Execute commands in pod kubectl exec -it -n certctl -- /bin/sh # Check events kubectl get events -n certctl --sort-by='.lastTimestamp' ```