flux-orchestrator

Database Support

Configure PostgreSQL or MySQL for Flux Orchestrator.

Table of contents

  1. Database Support
    1. Database Drivers
    2. PostgreSQL (Default)
      1. Local Development
      2. Docker Compose
      3. Kubernetes
    3. MySQL
      1. Local Development
      2. Docker Compose
      3. Kubernetes
    4. Schema Differences
      1. PostgreSQL
      2. MySQL
    5. External Databases
      1. PostgreSQL Services
      2. MySQL Services
      3. Configuration
    6. Performance Considerations
    7. Migration Between Databases

Database Support

Flux Orchestrator supports both PostgreSQL and MySQL as database backends.

Database Drivers

The application uses the DB_DRIVER environment variable to determine which database to use:

PostgreSQL (Default)

Local Development

# 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

docker-compose up -d

Kubernetes

The default deploy/kubernetes/manifests.yaml includes a PostgreSQL StatefulSet.

MySQL

Local Development

# 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

docker-compose -f docker-compose-mysql.yml up -d

Kubernetes

To use MySQL in Kubernetes:

  1. Remove the PostgreSQL StatefulSet from deploy/kubernetes/manifests.yaml
  2. Add a MySQL StatefulSet or use an external MySQL instance
  3. Update the ConfigMap:
apiVersion: 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"

Schema Differences

The application automatically handles schema differences between PostgreSQL and MySQL:

PostgreSQL

MySQL

External Databases

For production deployments, it’s recommended to use managed database services:

PostgreSQL Services

MySQL Services

Configuration

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

Performance Considerations

Both PostgreSQL and MySQL perform well for the Flux Orchestrator use case:

For most deployments, the choice between PostgreSQL and MySQL will depend on:

Migration Between Databases

To migrate from PostgreSQL to MySQL (or vice versa):

  1. Export data from the source database
  2. Set up the target database
  3. Update the DB_DRIVER environment variable
  4. Restart the application (schema will be auto-created)
  5. Re-add clusters via the UI or API

Note: 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.