Skip to main content
Unkey can be self-hosted in your own infrastructure, giving you complete control over data, deployment, and scaling. This guide covers requirements, installation, and configuration for running Unkey on-premises or in your cloud environment.

Prerequisites

Before installing Unkey, ensure you have the following requirements:

Infrastructure Requirements

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
Recommended for Production:
  • Multi-zone cluster (3+ availability zones)
  • 16+ CPU cores and 32GB+ RAM
  • 500GB persistent storage with backup
  • Monitoring stack (Prometheus, Grafana)
Optional but Recommended:
  • 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:
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=1000 or higher
Managed Options:
  • AWS RDS MySQL
  • Google Cloud SQL
  • Azure Database for MySQL
  • PlanetScale (MySQL-compatible)
Purpose: Cache and rate limiting countersRequirements:
  • Redis 7.0+ or Dragonfly 1.0+
  • No persistence required (cache only)
  • Cluster or Sentinel mode for HA
Managed Options:
  • AWS ElastiCache Redis
  • Google Cloud Memorystore
  • Azure Cache for Redis
  • Upstash (serverless Redis)
Purpose: Vault encryption key storageRequirements:
  • S3-compatible API
  • Versioning enabled
  • Bucket with read/write access
Compatible Services:
  • AWS S3
  • MinIO (self-hosted)
  • Google Cloud Storage (S3 compatibility mode)
  • DigitalOcean Spaces
  • Cloudflare R2
Purpose: Analytics and verification event storageRequirements:
  • ClickHouse 23.0 or later
  • Optional but recommended for production
  • If not configured, analytics writes are disabled
Managed Options:
  • ClickHouse Cloud
  • AWS-hosted ClickHouse
  • Self-hosted cluster
Purpose: Workflow orchestration for control planeRequirements:
  • Restate 1.6 or later
  • Required only for control plane workflows
  • Not needed for API-only deployments
Options:
  • Restate Cloud (managed)
  • Self-hosted Restate server

Installation Methods

Docker Compose (Development)

Quickest way to get started for development or testing:
1

Clone Repository

2

Configure Environment

Create configuration files in dev/config/:
See Configuration section below for detailed settings.
3

Start Services

This starts all required 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)
4

Verify Installation

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:
1

Prerequisites

Install required tools:
2

Prepare Configuration

Each service requires configuration and secrets. Helm charts are located in the source repository:
Available charts:
  • api/ - API service
  • frontline/ - Edge ingress
  • sentinel/ - Environment gateway
  • vault/ - Encryption service
  • krane/ - Kubernetes control agent
  • control-api/ - Control plane API
  • control-worker/ - Control plane worker
  • preflight/ - Admission webhook
3

Configure Secrets

Create Kubernetes secrets or configure External Secrets:
See Configuration for all required secrets per service.
4

Install Core Services

Install services in order:
5

Verify Deployment

Production deployments should use External Secrets Operator or a similar solution to manage secrets securely. Never commit secrets to values.yaml files.

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

Vault Service Configuration

Control Plane Configuration

Minimal API-Only Deployment

For a minimal setup without control plane features:
Core Services:
  • API Service
  • Vault Service
Dependencies:
  • MySQL
  • Redis
  • S3-compatible storage
  • ClickHouse (optional)

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:
For production use, generate secure random IDs and use the API or dashboard to create resources instead of direct database manipulation.

Verification

After installation, verify your deployment:

Health Checks

API Verification

Monitoring

Check metrics endpoints:

Troubleshooting

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
Verify connectivity:
Check permissions:
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
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)
Verify tokens match:
  • UNKEY_VAULT_TOKEN must match between API and Vault
  • UNKEY_CTRL_TOKEN must match between API and Control API
Check token format:
Test authentication:

Upgrading

To upgrade your Unkey deployment:
1

Backup Database

2

Review Changelog

Check the release notes for breaking changes:
3

Update Images

Docker Compose:
Kubernetes:
4

Run Migrations

5

Verify Upgrade

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:
  1. Check Documentation: Review Architecture and Deployments
  2. Search Issues: Look for similar issues on GitHub
  3. Community Support: Join the Discord community
  4. Create Issue: Open a detailed issue on GitHub with:
    • Unkey version
    • Deployment method (Docker/Kubernetes)
    • Error logs
    • Configuration (sanitized, no secrets)