rdev/docs/operations/database-connections.md
jordan c59d348040 chore: prepare for composable monorepo template implementation
This commit captures the current state before implementing the composable
monorepo template system. Key changes included:

Infrastructure:
- Add CockroachDB provisioner adapter for database provisioning
- Add Redis provisioner adapter for cache provisioning
- Add build events system with PostgreSQL storage
- Add WebSocket endpoint for real-time build progress

Code agent improvements:
- Fix Claude Code adapter to use default allowed tools instead of dangerously-skip-permissions
- Add context-aware stream closing for cancellation support
- Improve parser tests for edge cases

Build system:
- Add build event constants and metrics
- Remove deprecated git_operations.go (replaced by pod_git_operations.go)
- Add rollback logic for multi-step provisioning operations

Documentation:
- Add composable-monorepo feature documentation
- Add DNS/Cloudflare service documentation
- Update deployment and troubleshooting guides

Cookbooks:
- Add fullstack-app cookbook
- Refactor landing-test with shared library

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 11:39:28 -07:00

3.9 KiB

Database Connections

Quick reference for connecting to rdev infrastructure databases.

Prerequisites

# REQUIRED: Set kubeconfig before any kubectl command
export KUBECONFIG=~/.kube/orchard9-k3sf.yaml

CockroachDB

CockroachDB is the distributed SQL database for threesix.ai project databases.

Property Value
Service cockroachdb-public.databases.svc:26257
Version v25.1.3
Nodes 2-3 (StatefulSet)
Console https://cockroachdb.threesix.ai

Interactive SQL Shell

kubectl exec -it -n databases cockroachdb-0 -- \
  /cockroach/cockroach sql --insecure --host=localhost:26257

Run a Query

kubectl exec -n databases cockroachdb-0 -- \
  /cockroach/cockroach sql --insecure --host=localhost:26257 \
  -e "SHOW DATABASES;"

Check Cluster Status

kubectl exec -n databases cockroachdb-0 -- \
  /cockroach/cockroach node status --insecure --host=localhost:26257

Check Ranges Distribution

kubectl exec -n databases cockroachdb-0 -- \
  /cockroach/cockroach sql --insecure --host=localhost:26257 \
  -e "SHOW RANGES FROM DATABASE rdev;"

Internal Connection URL

For apps running inside the cluster:

postgresql://root@cockroachdb-public.databases.svc:26257/defaultdb?sslmode=disable

Redis

Redis provides caching and session storage for threesix.ai projects.

Property Value
Service redis.threesix.svc:6379
Version 7-alpine
Replicas 1 (StatefulSet)
Auth Password required

Get Password

REDIS_PASS=$(kubectl get secret -n threesix redis-credentials -o jsonpath="{.data.REDIS_PASSWORD}" | base64 -d)

Interactive CLI

kubectl exec -it -n threesix redis-0 -- redis-cli -a "$REDIS_PASS"

Ping Test

kubectl exec -n threesix redis-0 -- redis-cli -a "$REDIS_PASS" ping

Check Memory Usage

kubectl exec -n threesix redis-0 -- redis-cli -a "$REDIS_PASS" info memory

List Keys for a Project

kubectl exec -n threesix redis-0 -- redis-cli -a "$REDIS_PASS" keys "project:myapp:*"

Internal Connection URL

For apps running inside the cluster:

redis://:password@redis.threesix.svc:6379

PostgreSQL (rdev metadata)

PostgreSQL stores rdev API metadata (API keys, audit logs, work queue, credentials).

Property Value
Service postgres.databases.svc:5432
Database rdev

Connect to rdev Database

kubectl exec -it -n databases postgres-0 -- \
  psql -U rdev -d rdev

Check Recent API Keys

SELECT id, name, created_at FROM api_keys ORDER BY created_at DESC LIMIT 10;

Check Work Queue

SELECT id, project_id, status, created_at FROM work_items ORDER BY created_at DESC LIMIT 10;

Credentials Storage

Infrastructure credentials (Cloudflare, Gitea, Woodpecker tokens) are stored in PostgreSQL with encryption.

Source file: .secrets at repo root (gitignored)

Load credentials:

./scripts/load-credentials.sh $RDEV_API_URL

Verify credentials loaded:

curl -H "X-API-Key: $RDEV_API_KEY" $RDEV_API_URL/credentials | jq

See Credentials Management for full documentation.

Troubleshooting

CockroachDB: "Connection Refused"

  1. Check pods are running:

    kubectl get pods -n databases -l app=cockroachdb
    
  2. Check service exists:

    kubectl get svc -n databases cockroachdb-public
    

Redis: "NOAUTH Authentication Required"

Get the password first:

REDIS_PASS=$(kubectl get secret -n threesix redis-credentials -o jsonpath="{.data.REDIS_PASSWORD}" | base64 -d)

PostgreSQL: "Role does not exist"

Check the correct user/database:

kubectl exec -n databases postgres-0 -- psql -U postgres -c "\l"
kubectl exec -n databases postgres-0 -- psql -U postgres -c "\du"