FeaturesBlogDocs GitHub Get Started

Deploying flashQ with Docker and Kubernetes

Deploying flashQ in production requires careful consideration of persistence, scaling, and monitoring. This guide covers everything from basic Docker setups to full Kubernetes deployments with high availability.

Docker Deployment

Basic Docker Run

# Simple deployment
docker run -d \
  --name flashq \
  -p 6789:6789 \
  -p 6790:6790 \
  -e HTTP=1 \
  flashq/flashq

# With PostgreSQL persistence
docker run -d \
  --name flashq \
  -p 6789:6789 \
  -p 6790:6790 \
  -e HTTP=1 \
  -e DATABASE_URL=postgres://user:pass@host:5432/flashq \
  flashq/flashq

Docker Compose

# docker-compose.yml
version: '3.8'

services:
  flashq:
    image: flashq/flashq:latest
    ports:
      - "6789:6789"   # TCP
      - "6790:6790"   # HTTP
    environment:
      - HTTP=1
      - DATABASE_URL=postgres://flashq:flashq@postgres:5432/flashq
      - AUTH_TOKENS=your-secret-token
    depends_on:
      postgres:
        condition: service_healthy
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:6790/health"]
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  postgres:
    image: postgres:16-alpine
    environment:
      POSTGRES_USER: flashq
      POSTGRES_PASSWORD: flashq
      POSTGRES_DB: flashq
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U flashq"]
      interval: 5s
      timeout: 5s
      retries: 5

  worker:
    build: ./worker
    environment:
      - FLASHQ_HOST=flashq
      - FLASHQ_PORT=6789
      - FLASHQ_TOKEN=your-secret-token
    depends_on:
      - flashq
    restart: unless-stopped
    deploy:
      replicas: 3

volumes:
  postgres_data:

Kubernetes Deployment

Namespace and ConfigMap

# k8s/namespace.yaml
apiVersion: v1
kind: Namespace
metadata:
  name: flashq

---
# k8s/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: flashq-config
  namespace: flashq
data:
  HTTP: "1"
  GRPC: "0"
  LOG_LEVEL: "info"

Secret

# k8s/secret.yaml
apiVersion: v1
kind: Secret
metadata:
  name: flashq-secrets
  namespace: flashq
type: Opaque
stringData:
  DATABASE_URL: postgres://flashq:password@postgres:5432/flashq
  AUTH_TOKENS: your-secret-token-here

Deployment

# k8s/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: flashq
  namespace: flashq
spec:
  replicas: 3
  selector:
    matchLabels:
      app: flashq
  template:
    metadata:
      labels:
        app: flashq
    spec:
      containers:
        - name: flashq
          image: flashq/flashq:latest
          ports:
            - containerPort: 6789
              name: tcp
            - containerPort: 6790
              name: http
          envFrom:
            - configMapRef:
                name: flashq-config
            - secretRef:
                name: flashq-secrets
          resources:
            requests:
              memory: "256Mi"
              cpu: "250m"
            limits:
              memory: "1Gi"
              cpu: "1000m"
          livenessProbe:
            httpGet:
              path: /health
              port: http
            initialDelaySeconds: 10
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /health
              port: http
            initialDelaySeconds: 5
            periodSeconds: 5
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 100
              podAffinityTerm:
                labelSelector:
                  matchLabels:
                    app: flashq
                topologyKey: kubernetes.io/hostname

Service

# k8s/service.yaml
apiVersion: v1
kind: Service
metadata:
  name: flashq
  namespace: flashq
spec:
  selector:
    app: flashq
  ports:
    - name: tcp
      port: 6789
      targetPort: 6789
    - name: http
      port: 6790
      targetPort: 6790
  type: ClusterIP

---
# External access via Ingress
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: flashq-ingress
  namespace: flashq
  annotations:
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
spec:
  ingressClassName: nginx
  tls:
    - hosts:
        - flashq.example.com
      secretName: flashq-tls
  rules:
    - host: flashq.example.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: flashq
                port:
                  number: 6790

Scaling Strategies

Horizontal Pod Autoscaler

# k8s/hpa.yaml
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: flashq-hpa
  namespace: flashq
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: flashq
  minReplicas: 2
  maxReplicas: 10
  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 70
    - type: Resource
      resource:
        name: memory
        target:
          type: Utilization
          averageUtilization: 80

Monitoring

Prometheus ServiceMonitor

# k8s/servicemonitor.yaml
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: flashq
  namespace: flashq
spec:
  selector:
    matchLabels:
      app: flashq
  endpoints:
    - port: http
      path: /metrics/prometheus
      interval: 15s

Grafana Dashboard

Import the flashQ Grafana dashboard from our repository for pre-built visualizations of:

  • Jobs processed per second
  • Queue depths
  • Processing latency
  • Error rates
  • Memory usage
🚀 Production Checklist

✓ Enable PostgreSQL persistence
✓ Set up health checks
✓ Configure resource limits
✓ Enable authentication tokens
✓ Set up monitoring and alerting
✓ Use pod anti-affinity for HA

Conclusion

flashQ is designed to be cloud-native and easy to deploy. Whether you're running a simple Docker setup or a full Kubernetes cluster, flashQ scales with your needs.

Deploy flashQ Today

Get production-ready in minutes with our deployment guides.

Get Started →
ESC