Skip to content

PostgreSQL & Redis

helm-me has built-in support for PostgreSQL and Redis as first-class components.

PostgreSQL

components:
  db:
    type: postgresql
    version: "16"
    database: myapp
    user: appuser
    password: supersecret
    storage: "10Gi"
from helm_me import postgresql

db = postgresql(
    version="16",
    database="myapp",
    user="appuser",
    password="supersecret",
    storage="10Gi",
)

This creates:

  • A Deployment running postgres:16
  • A Service on port 5432
  • A PersistentVolumeClaim for data
  • A Secret with connection credentials

Auto-Generated Secret Keys

Key Example Value
DATABASE_URL postgresql://appuser:supersecret@myapp-db:5432/myapp
POSTGRES_DB myapp
POSTGRES_USER appuser
POSTGRES_PASSWORD supersecret

Reference from Web Components

components:
  db:
    type: postgresql
    database: myapp
    user: appuser
    password: secret123

  backend:
    type: web
    image: myapp:latest
    port: 8000
    secretEnv:
      DATABASE_URL:
        component: db
        key: DATABASE_URL

Redis

components:
  cache:
    type: redis
    version: "7"
    maxmemory: "256mb"
    password: supersecret
from helm_me import redis

cache = redis(
    version="7",
    maxmemory="256mb",
    password="supersecret",
)

Redis with Persistent Storage

components:
  cache:
    type: redis
    version: "7"
    storage: "5Gi"
    maxmemory: "512mb"

Reference Redis from Web Components

Use serviceEnv for the host and secretEnv for the password:

components:
  cache:
    type: redis
    password: secret123

  backend:
    type: web
    image: myapp:latest
    port: 8000
    env:
      REDIS_PORT: "6379"
    serviceEnv:
      REDIS_HOST:
        component: cache
    secretEnv:
      REDIS_PASSWORD:
        component: cache
        key: REDIS_PASSWORD

Full Example

See examples/with_dbs/ for a complete PostgreSQL + Redis + backend example.