Prerequisites
Before installing Unkey, ensure you have the following requirements:Infrastructure Requirements
- Kubernetes
- Docker Compose
Minimum Requirements:
- Kubernetes 1.28 or later
- 8 CPU cores and 16GB RAM across nodes
- 100GB persistent storage
- LoadBalancer support (for external access)
- Container runtime: containerd or Docker
- Multi-zone cluster (3+ availability zones)
- 16+ CPU cores and 32GB+ RAM
- 500GB persistent storage with backup
- Monitoring stack (Prometheus, Grafana)
- cert-manager (for automatic TLS certificates)
- External Secrets Operator (for secret management)
- gVisor runtime (for workload isolation)
- Cilium CNI (for network policies)
External Dependencies
Unkey requires the following external services:MySQL 8.0+
MySQL 8.0+
Purpose: Primary data storage for keys, APIs, identities, permissionsRequirements:
- MySQL 8.0 or later
- InnoDB storage engine
- UTF-8 character set
- Primary/replica configuration recommended
max_connections=1000or higher
- AWS RDS MySQL
- Google Cloud SQL
- Azure Database for MySQL
- PlanetScale (MySQL-compatible)
Redis 7.0+ (or Dragonfly)
Redis 7.0+ (or Dragonfly)
Purpose: Cache and rate limiting countersRequirements:
- Redis 7.0+ or Dragonfly 1.0+
- No persistence required (cache only)
- Cluster or Sentinel mode for HA
- AWS ElastiCache Redis
- Google Cloud Memorystore
- Azure Cache for Redis
- Upstash (serverless Redis)
S3-Compatible Object Storage
S3-Compatible Object Storage
Purpose: Vault encryption key storageRequirements:
- S3-compatible API
- Versioning enabled
- Bucket with read/write access
- AWS S3
- MinIO (self-hosted)
- Google Cloud Storage (S3 compatibility mode)
- DigitalOcean Spaces
- Cloudflare R2
ClickHouse 23.0+ (Optional)
ClickHouse 23.0+ (Optional)
Purpose: Analytics and verification event storageRequirements:
- ClickHouse 23.0 or later
- Optional but recommended for production
- If not configured, analytics writes are disabled
- ClickHouse Cloud
- AWS-hosted ClickHouse
- Self-hosted cluster
Restate (Optional)
Restate (Optional)
Purpose: Workflow orchestration for control planeRequirements:
- Restate 1.6 or later
- Required only for control plane workflows
- Not needed for API-only deployments
- Restate Cloud (managed)
- Self-hosted Restate server
Installation Methods
Docker Compose (Development)
Quickest way to get started for development or testing:Configure Environment
Start Services
- MySQL (port 3306)
- Redis (port 6379)
- MinIO/S3 (port 3902)
- ClickHouse (port 8123)
- Vault (port 8060)
- API Service (port 7070)
- Control API (port 7091)
- Dashboard (port 3000)
The Docker Compose setup includes all dependencies and is pre-configured for local development. See
dev/docker-compose.yaml for the complete stack.Kubernetes with Helm (Production)
For production deployments, use Helm charts:Prepare Configuration
Each service requires configuration and secrets. Helm charts are located in the source repository:Available charts:
api/- API servicefrontline/- Edge ingresssentinel/- Environment gatewayvault/- Encryption servicekrane/- Kubernetes control agentcontrol-api/- Control plane APIcontrol-worker/- Control plane workerpreflight/- Admission webhook
Configure Secrets
Create Kubernetes secrets or configure External Secrets:See Configuration for all required secrets per service.
Configuration
Each Unkey service is configured via a TOML file and environment variables. Configuration files are typically mounted at/etc/unkey/<service>.toml.
API Service Configuration
- api.toml
- Required Secrets
- Environment Variables
Vault Service Configuration
- vault.toml
- Required Secrets
Control Plane Configuration
- ctrl-api.toml
- ctrl-worker.toml
Minimal API-Only Deployment
For a minimal setup without control plane features:Required Services
Required Services
Core Services:
- API Service
- Vault Service
- MySQL
- Redis
- S3-compatible storage
- ClickHouse (optional)
Docker Compose Minimal
Docker Compose Minimal
Database Setup
Schema Migration
Unkey uses database migrations to set up the schema:Migrations are idempotent and safe to run multiple times. They automatically detect the current schema version and apply only necessary changes.
Creating Initial Data
After schema setup, create an initial workspace and API key:Verification
After installation, verify your deployment:Health Checks
API Verification
Monitoring
Check metrics endpoints:Troubleshooting
Service Won't Start
Service Won't Start
Check logs:Common issues:
- Missing required secrets → Check secret configuration
- Database connection failed → Verify MySQL is accessible
- Port already in use → Change port in configuration
- Invalid TOML syntax → Validate configuration file
Database Connection Errors
Database Connection Errors
Verify connectivity:Check permissions:
Vault Encryption Errors
Vault Encryption Errors
Verify Vault health:Test S3 connectivity:Common issues:
- Invalid master key (must be 64 hex characters)
- S3 bucket doesn’t exist or wrong permissions
- S3 endpoint not reachable from Vault pod
High Latency
High Latency
Check cache hit rates:Verify Redis connection:Potential causes:
- Redis not configured or unreachable
- Database replica lag (check replication status)
- Network latency between services
- Insufficient resources (CPU/memory)
Authentication Failures
Authentication Failures
Verify tokens match:Test authentication:
- UNKEY_VAULT_TOKEN must match between API and Vault
- UNKEY_CTRL_TOKEN must match between API and Control API
Upgrading
To upgrade your Unkey deployment:Security Best Practices
Secret Management
- Use External Secrets Operator or HashiCorp Vault
- Rotate tokens every 90 days
- Never commit secrets to version control
- Use strong random tokens (32+ bytes)
Network Security
- Use network policies to restrict pod-to-pod traffic
- Enable TLS for all external connections
- Use private networks for database access
- Implement IP allowlisting where possible
Database Security
- Use strong passwords and rotate regularly
- Enable encryption at rest and in transit
- Restrict database user permissions
- Enable audit logging
Access Control
- Use RBAC for Kubernetes access
- Implement least-privilege service accounts
- Enable audit logging for all API calls
- Regular security audits
Production Checklist
Before going to production:- Multi-zone Kubernetes cluster configured
- MySQL primary/replica setup with automated backups
- Redis in HA mode (Sentinel or Cluster)
- S3 bucket with versioning and backup
- All secrets managed via External Secrets Operator
- TLS certificates configured (cert-manager)
- Monitoring stack deployed (Prometheus/Grafana)
- Alerting configured for critical issues
- Resource requests/limits set on all pods
- HPA (Horizontal Pod Autoscaler) configured
- PodDisruptionBudgets configured
- Network policies applied
- Backup and restore procedures tested
- Disaster recovery plan documented
- Load testing completed
Getting Help
If you encounter issues:- Check Documentation: Review Architecture and Deployments
- Search Issues: Look for similar issues on GitHub
- Community Support: Join the Discord community
- Create Issue: Open a detailed issue on GitHub with:
- Unkey version
- Deployment method (Docker/Kubernetes)
- Error logs
- Configuration (sanitized, no secrets)
Related Documentation
- Architecture Overview - Understand system architecture
- Deployments - Regional deployment model
- API Reference - API endpoint documentation