Skip to content

Dolt SQL Server Design

Date: 2026-02-07 Status: Draft Author: Sean + Claude Opus 4.6

Deploy a Dolt SQL server on the self-hosted cluster to provide a version-controlled database backend for Beads, Gastown, and AI agent workflows. Dolt’s Git-like branching, diffing, and merging semantics make it a natural fit for agent-driven data operations that benefit from full audit trails and rollback.

┌──────────────────────────────────────────────────┐
│ K8s Cluster │
│ │
│ ┌──────────────┐ ┌──────────────────┐ │
│ │ In-cluster │────▶│ dolt-server │ │
│ │ agents/svcs │ │ (StatefulSet) │ │
│ └──────────────┘ │ Port 3306 │ │
│ │ Longhorn PVC │ │
│ ┌──────────────┐ └────────┬─────────┘ │
│ │ ExternalSecret│ │ │
│ │ → Vault │─────────────┘ (credentials) │
│ └──────────────┘ │
│ ┌──────────────────┐ │
│ │ Service: │ │
│ │ ClusterIP:3306 │ │
│ │ LoadBalancer: │ │
│ │ 3306 (MetalLB) │ │
│ └──────────────────┘ │
└──────────────────────────────────────────────────┘
│ MetalLB IP
│ doltdb.fzymgc.house
│ (router-hosts DNS)
┌─────────────────────┼─────────────────────┐
│ │ │
┌─────┴──────┐ ┌─────────┴───┐ ┌────────────┴┐
│ Beads CLI │ │ Gastown │ │ AI Agents │
│ (dev local)│ │ (anywhere) │ │ (anywhere) │
└────────────┘ └─────────────┘ └─────────────┘

Clients may be inside or outside the Kubernetes cluster. In-cluster pods connect via dolt.dolt.svc.cluster.local:3306. External clients (dev machines, remote agents) connect via doltdb.fzymgc.house:3306, which resolves to a MetalLB LoadBalancer IP reachable over the local network and Tailscale.

DecisionChoiceRationale
Access modeSQL server (MySQL wire protocol)Multi-agent concurrency, standard MySQL drivers
StorageLonghorn PVC, 20Gi, 3 replicasConsistent with CNPG and other stateful workloads
DeploymentStatefulSet, raw kustomize manifestsNo official Helm chart; matches existing app-configs pattern
CredentialsVault-managed via ExternalSecretConsistent with cluster secret management pattern
ExposureLoadBalancer (MetalLB) + router-hosts DNSCovers both in-cluster and external clients
Imagedolthub/dolt-sql-server:1.81.6Latest GA release at time of design
Replicas1Dolt has no native replication; Longhorn provides storage redundancy

Dedicated dolt namespace.

Single-replica StatefulSet running dolthub/dolt-sql-server:1.81.6.

  • Volume: 20Gi Longhorn PVC at /var/lib/dolt
  • Config: Mounted from ConfigMap at /etc/dolt
  • Credentials: Injected as environment variables from ExternalSecret-created Secret dolt-credentials
  • Port: 3306 (MySQL)

The Dolt Docker entrypoint supports /docker-entrypoint-initdb.d/ scripts that run once on first boot (after DOLT_USER creation). A shell script mounted from the ConfigMap handles:

  1. Creates beads and agent databases
  2. Grants the agent user (created by entrypoint) scoped privileges on both databases
  3. Creates the beads user and grants database-scoped privileges

The script runs only once (entrypoint uses a marker file). IF NOT EXISTS guards provide additional safety.

Dolt server configuration and init script:

log_level: info
behavior:
read_only: false
autocommit: true
listener:
host: "0.0.0.0"
port: 3306
max_connections: 100

LoadBalancer service with MetalLB IP allocation and router-hosts DNS registration:

annotations:
router-hosts.fzymgc.house/enabled: "true"
router-hosts.fzymgc.house/hostname: "doltdb.fzymgc.house"

No IngressRoute or Traefik involvement — this is raw TCP, not HTTP.

Both probes use TCP socket checks on port 3306. No credentials required, no root login for health checks.

livenessProbe:
tcpSocket:
port: 3306
initialDelaySeconds: 30
periodSeconds: 10
readinessProbe:
tcpSocket:
port: 3306
initialDelaySeconds: 15
periodSeconds: 10

secret/fzymgc-house/cluster/dolt

KeyPurpose
root_passwordDolt root user password
agent_userUsername for general agent connections
agent_passwordPassword for general agent connections
beads_userUsername for Beads clients
beads_passwordPassword for Beads clients

Syncs all credentials from Vault to a Kubernetes Secret named dolt-credentials in the dolt namespace. Refresh interval: 15 minutes.

New Terraform resource in tf/vault/policy-dolt.tf granting the ESO service account read access to secret/data/fzymgc-house/cluster/dolt.

LayerMechanismCoverage
ApplicationDolt built-in commit logEvery data change versioned (branch, diff, revert)
StorageLonghorn snapshots via VeleroPVC-level snapshots (daily 30d, weekly 90d)

Dolt’s own versioning provides logical data protection (time-travel, rollback). Velero provides infrastructure-level protection against PVC loss. No additional backup CronJob needed at this time.

Client LocationConnection String
In-cluster podmysql://agent_user:***@dolt.dolt.svc.cluster.local:3306/<db>
Local networkmysql://beads_user:***@doltdb.fzymgc.house:3306/<db>
Tailscale remotemysql://beads_user:***@doltdb.fzymgc.house:3306/<db>
FilePurpose
argocd/app-configs/dolt/kustomization.yamlKustomize entry point
argocd/app-configs/dolt/namespace.yamlNamespace definition
argocd/app-configs/dolt/statefulset.yamlDolt server StatefulSet
argocd/app-configs/dolt/service.yamlLoadBalancer + router-hosts
argocd/app-configs/dolt/configmap.yamlDolt server config
argocd/app-configs/dolt/external-secret.yamlVault credential sync
argocd/cluster-app/templates/dolt.yamlArgoCD Application
tf/vault/policy-dolt.tfVault policy for ESO
  • Per-agent credentials: Add individual Vault paths per agent for granular audit trails via Dolt’s MySQL GRANT system.
  • Prometheus metrics: Add mysqld_exporter sidecar for Grafana dashboards if query performance monitoring is needed.
  • SQL dump export: Add CronJob for dolt dump to object storage for cross-site disaster recovery.
  • Dolt remotes: Configure Dolt to push to DoltHub or another Dolt remote for off-cluster replication.