Skip to content

Latest commit

 

History

History
180 lines (135 loc) · 3.97 KB

File metadata and controls

180 lines (135 loc) · 3.97 KB

Deployment Guide for Mini Kubernetes Dashboard

🚀 Environment Setup

Local Development

  1. Install PostgreSQL locally

    # macOS
    brew install postgresql
    
    # Ubuntu/Debian
    sudo apt-get install postgresql postgresql-contrib
    
    # Windows - Download from https://www.postgresql.org/download/windows/
  2. Create database

    createdb k8s
  3. Configure .env.local

    DATABASE_URL="postgresql://postgres:ayush@2004@localhost:5432/k8s"
  4. Start development server

    npm run dev

🌐 Cloud Deployment Options

Option 1: AWS RDS (Recommended for Production)

  1. Create RDS PostgreSQL instance

    • Engine: PostgreSQL 14+
    • Instance: db.t3.micro (free tier eligible)
    • Storage: 20GB
    • Backup retention: 7 days
  2. Configure security group

    • Inbound rules: Allow port 5432 from your app's IP
  3. Update .env.local for production

    DATABASE_URL="postgresql://admin:your_strong_password@mini-kub.xxxxxxxxxxxx.us-east-1.rds.amazonaws.com:5432/k8s?sslmode=require"

Option 2: Railway.app (Easiest)

  1. Connect GitHub repository

    git push origin main
  2. Create PostgreSQL service in Railway

    • Automatically provides DATABASE_URL
  3. Deploy Next.js app

    • Railway automatically reads .env.local

Option 3: Vercel + Neon PostgreSQL

  1. Create Neon accounthttps://neon.tech
  2. Get connection string → Automatically set as DATABASE_URL
  3. Deploy on Vercel
    npm install -g vercel
    vercel

Option 4: Docker + Docker Compose

Create docker-compose.yml:

version: '3.8'
services:
  postgres:
    image: postgres:15
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: ayush@2004
      POSTGRES_DB: k8s
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data

  app:
    build: .
    ports:
      - "3000:3000"
    environment:
      DATABASE_URL: "postgresql://postgres:ayush@2004@postgres:5432/k8s"
    depends_on:
      - postgres
    command: npm run dev

volumes:
  postgres_data:

Run:

docker-compose up

📋 Environment Variables

Required

  • DATABASE_URL - PostgreSQL connection string

Optional

  • NODE_ENV - Set to "production" for optimal performance
  • NEXT_PUBLIC_API_URL - API base URL (defaults to current origin)

✅ Deployment Checklist

  • Database is accessible from your deployment environment
  • Connection string is set in environment variables
  • SSL mode is configured for remote databases (?sslmode=require)
  • Database user has minimal required permissions
  • Firewall/Security groups allow app to reach database
  • .env.local is in .gitignore (NEVER commit secrets!)
  • Test connection before full deployment

🔒 Security Best Practices

  1. Never commit .env.local → Already in .gitignore
  2. Use strong passwords for database users
  3. Enable SSL for remote databases
  4. Restrict database access with security groups/firewall
  5. Use read-only replicas for analytics (if needed)
  6. Enable automated backups for production

🐛 Troubleshooting

Connection Timeout

  • Check database is running
  • Verify firewall allows port 5432
  • Confirm correct hostname/IP address
  • Check security group rules (AWS RDS)

Authentication Failed

  • Verify username and password
  • Check database name exists
  • Ensure user has correct privileges

SSL Error

  • For local: Remove ?sslmode=require
  • For AWS RDS: Keep ?sslmode=require
  • Certificate issues: Use ?sslmode=prefer

🚀 Next Steps

  1. Choose your deployment platform
  2. Create a PostgreSQL database
  3. Get the connection string
  4. Add to .env.local
  5. Test locally: npm run dev
  6. Deploy to your platform

For questions, refer to: