Configure PostgreSQL or MySQL for Flux Orchestrator.
Flux Orchestrator supports both PostgreSQL and MySQL as database backends.
The application uses the DB_DRIVER environment variable to determine which database to use:
postgres - PostgreSQL (default)mysql - MySQL/MariaDB# Start PostgreSQL
docker run -d \
--name flux-orchestrator-postgres \
-e POSTGRES_DB=flux_orchestrator \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-p 5432:5432 \
postgres:15-alpine
# Configure backend
export DB_DRIVER=postgres
export DB_HOST=localhost
export DB_PORT=5432
export DB_USER=postgres
export DB_PASSWORD=postgres
export DB_NAME=flux_orchestrator
export DB_SSLMODE=disable
export PORT=8080
# Start backend
go run backend/cmd/server/main.go
docker-compose up -d
The default deploy/kubernetes/manifests.yaml includes a PostgreSQL StatefulSet.
# Start MySQL
docker run -d \
--name flux-orchestrator-mysql \
-e MYSQL_DATABASE=flux_orchestrator \
-e MYSQL_USER=flux \
-e MYSQL_PASSWORD=flux \
-e MYSQL_ROOT_PASSWORD=rootpass \
-p 3306:3306 \
mysql:8
# Configure backend
export DB_DRIVER=mysql
export DB_HOST=localhost
export DB_PORT=3306
export DB_USER=flux
export DB_PASSWORD=flux
export DB_NAME=flux_orchestrator
export PORT=8080
# Start backend
go run backend/cmd/server/main.go
docker-compose -f docker-compose-mysql.yml up -d
To use MySQL in Kubernetes:
deploy/kubernetes/manifests.yamlapiVersion: v1
kind: ConfigMap
metadata:
name: flux-orchestrator-config
namespace: flux-orchestrator
data:
DB_DRIVER: "mysql"
DB_HOST: "mysql"
DB_PORT: "3306"
DB_USER: "flux"
DB_NAME: "flux_orchestrator"
PORT: "8080"
The application automatically handles schema differences between PostgreSQL and MySQL:
JSONB for metadata storageTIMESTAMP DEFAULT CURRENT_TIMESTAMP for timestampsJSON for metadata storageTIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMPNULL timestamp columns explicitly declaredFor production deployments, it’s recommended to use managed database services:
Set the connection parameters via environment variables:
env:
- name: DB_DRIVER
value: "postgres" # or "mysql"
- name: DB_HOST
value: "your-db-host.region.provider.com"
- name: DB_PORT
value: "5432" # or "3306" for MySQL
- name: DB_USER
valueFrom:
secretKeyRef:
name: db-credentials
key: username
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: db-credentials
key: password
- name: DB_NAME
value: "flux_orchestrator"
- name: DB_SSLMODE
value: "require" # for PostgreSQL only
Both PostgreSQL and MySQL perform well for the Flux Orchestrator use case:
For most deployments, the choice between PostgreSQL and MySQL will depend on:
To migrate from PostgreSQL to MySQL (or vice versa):
DB_DRIVER environment variableNote: Direct database migration tools may not preserve all data types correctly due to differences in JSON storage. It’s recommended to re-register clusters rather than migrate data.