Skip to content

RustyCoderX/k8s-lite

Repository files navigation

Mini Kubernetes Dashboard 🚀

A modern, industry-ready Docker container job management dashboard built with Next.js, TypeScript, and PostgreSQL. Submit Docker jobs, monitor their status in real-time, and manage containerized workloads from a sleek web interface.

Next.js React TypeScript Tailwind CSS PostgreSQL License


✨ Features

🎯 User-Friendly Interface

  • Modern Dashboard - Clean, responsive design that works on desktop, tablet, and mobile
  • Real-Time Updates - Job status automatically refreshes every 5 seconds
  • Visual Status Indicators - Color-coded badges for job states (pending, running, completed, failed)
  • Toast Notifications - Non-intrusive success and error alerts

🔒 Security & Validation

  • Official Images Only - Submit jobs using only verified Docker official images (nginx, postgres, ubuntu, etc.)
  • Input Validation - Real-time validation with visual feedback (✓ or ✕)
  • Error Handling - Comprehensive error messages help users understand what went wrong

📊 Job Management

  • Submit Jobs - Easily submit Docker container jobs with just an image name
  • Monitor Status - Track job lifecycle: pending → running → completed/failed
  • Job History - View all submitted jobs with timestamps and details
  • Quick Stats - See total jobs, running, completed, and failed counts at a glance

📱 Responsive Design

  • Mobile-First - Optimized for all screen sizes
  • Touch-Friendly - Easy to use on smartphones and tablets
  • Dark/Light Mode Ready - Built with modern CSS that supports theme switching

🚀 Quick Start

Prerequisites

  • Node.js 18+
  • PostgreSQL 14+ (local or remote)
  • Git

Installation (2 minutes)

# Clone the repository
git clone https://github.com/RustyCoderX/k8s-lite.git
cd k8s-lite

# Install dependencies
npm install

# Create .env.local with your database connection
echo 'DATABASE_URL=postgresql://postgres@localhost:5432/k8s' > .env.local

# Start the development server
npm run dev

Open http://localhost:3000 in your browser and start submitting jobs! 🎉


📋 Usage

Submit a Job

  1. Enter Docker Image - Type an official image name (e.g., nginx:latest, ubuntu:22.04)
  2. Click Submit - The form validates in real-time
  3. See Success - Toast notification confirms submission
  4. Monitor - Job appears in the list with auto-updating status

Allowed Docker Images

The system only accepts official Docker images for security:

Popular Images:

  • nginx - Web server
  • postgres - Database
  • mongodb - NoSQL database
  • python - Python runtime
  • node - Node.js runtime
  • ubuntu - Operating system
  • redis - In-memory cache
  • mysql - MySQL database
  • And 30+ more...

See the form for the complete list! 📋

Understanding Job Status

Status Meaning
🟡 Pending Job created, waiting to run
🔵 Running Container is executing
🟢 Completed Successfully finished
🔴 Failed Execution error occurred

🏗️ Architecture

┌─────────────────────────────────────────┐
│   Frontend (Next.js + React)            │
│  ├─ Dashboard (Real-time UI)            │
│  ├─ Job Form (Validation)               │
│  ├─ Job Cards (Status display)          │
│  └─ Toast Notifications                 │
└──────────────┬──────────────────────────┘
               │
               │ (API)
               ▼
┌─────────────────────────────────────────┐
│   Backend (Next.js API Routes)          │
│  ├─ POST /api/jobs (Submit)             │
│  ├─ GET /api/jobs (List)                │
│  └─ Security validation                 │
└──────────────┬──────────────────────────┘
               │
               ▼
┌─────────────────────────────────────────┐
│   Database (PostgreSQL)                 │
│  └─ jobs table (id, image, status...)   │
└─────────────────────────────────────────┘

🛠️ Technology Stack

Component Technology
Frontend Next.js 16.2, React 19.2, TypeScript 5
Styling Tailwind CSS 4
Backend Next.js API Routes
Database PostgreSQL 14+
Authentication Environment-based (for production)

📦 Project Structure

mini-kub/
├── 📁 app/
│   ├── 📁 api/jobs/
│   │   └── route.ts              # API endpoints
│   ├── 📁 components/
│   │   ├── JobForm.tsx           # Input form for jobs
│   │   ├── JobCard.tsx           # Job display card
│   │   ├── JobList.tsx           # Jobs grid
│   │   ├── Toast.tsx             # Notifications
│   │   ├── AllowedImagesInfo.tsx # Image list
│   │   └── ui.tsx                # Header, Stats, UI
│   ├── layout.tsx                # Root layout
│   ├── page.tsx                  # Main dashboard
│   └── globals.css               # Global styles
│
├── 📁 lib/
│   ├── api.ts                    # API client
│   ├── types.ts                  # TypeScript types
│   ├── db.ts                     # Database connection
│   ├── constants.ts              # App constants
│   ├── utils.ts                  # Utility functions
│   ├── hooks.ts                  # Custom React hooks
│   └── imageValidation.ts        # Image verification
│
├── 📁 public/                    # Static assets
├── 📄 package.json
├── 📄 tsconfig.json
├── 📄 .env.local.example
└── 📄 README.md

🔧 Configuration

Environment Variables

Create .env.local in the project root:

# Database Connection
DATABASE_URL=postgresql://username:password@host:port/database

# Optional
NODE_ENV=development

Database URL Examples:

  • Local: postgresql://postgres@localhost:5432/k8s
  • Neon: postgresql://user:password@host.neon.tech/db?sslmode=require
  • AWS RDS: postgresql://admin:password@mini-kub.xxxxx.rds.amazonaws.com/k8s

🚀 Deployment

This application is ready to deploy on:

♡ Vercel (⭐ Recommended)

npm install -g vercel
vercel
  • Zero-config deployment for Next.js
  • Auto-scaling
  • Free tier available

Railway

# Push to GitHub, then connect your repo to Railway
# Railway auto-detects and deploys Next.js apps

Docker

docker build -t mini-kub .
docker run -e DATABASE_URL="..." -p 3000:3000 mini-kub

AWS, Google Cloud, Heroku

See DEPLOYMENT.md for detailed instructions.


📖 Documentation


🧪 Development

Available Scripts

# Start development server with hot-reload
npm run dev

# Build for production
npm run build

# Start production server
npm start

# Run ESLint
npm run lint

Development Tools

  • Hot Reloading - Changes reflect instantly
  • TypeScript - Full type safety
  • Tailwind CSS - Utility-first styling
  • ESLint - Code quality

🔐 Security Features

Official Images Only - No arbitrary Docker images
Input Validation - Real-time validation on frontend and backend
SQL Injection Prevention - Parameterized queries
Error Handling - Safe error messages (no sensitive data leaks)
Environment Variables - Secrets never committed to git
HTTPS Ready - Built for secure deployments


🐛 Troubleshooting

Connection Timeout

# Check if PostgreSQL is running
psql -U postgres -c "SELECT 1"

# Verify DATABASE_URL is correct
echo $DATABASE_URL

Form Not Validating

  • Clear browser cache (Ctrl+Shift+Delete)
  • Check browser console for errors (F12)
  • Ensure JavaScript is enabled

Jobs Not Showing

  • Check database connection
  • Verify jobs table exists
  • Check database logs for errors

See DATABASE_HELP.md for more troubleshooting.


📊 API Reference

POST /api/jobs

Submit a new job

Request:

[{"image": "nginx:latest"}]

Response:

{
  "success": true,
  "data": {
    "id": "uuid",
    "image": "nginx:latest",
    "status": "pending",
    "createdAt": "2024-03-26T10:30:00Z",
    "updatedAt": "2024-03-26T10:30:00Z"
  }
}

GET /api/jobs

Fetch all jobs

Response:

{
  "success": true,
  "data": [
    {"id": "uuid", "image": "nginx", "status": "running", ...},
    {"id": "uuid", "image": "postgres", "status": "pending", ...}
  ]
}

🤝 Contributing

Contributions are welcome! To contribute:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Before Contributing

  • Follow TypeScript conventions
  • Keep components focused and reusable
  • Handle loading and error states
  • Test on multiple devices
  • Update relevant documentation

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.


🎯 Roadmap

  • Delete job functionality
  • View job logs/output
  • Job filtering and search
  • Custom memory/CPU limits
  • Job scheduling
  • Webhook notifications
  • Multi-user support
  • Admin dashboard

💬 Support


🌟 Show Your Support

If you find this project helpful, please give it a ⭐ on GitHub!


👨‍💻 Author

Ayush - Mini Kub Developer


Made with ❤️ using Next.js & TypeScript

Live DemoDocsReport BugRequest Feature

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.

About

A lightweight Kubernetes-inspired container orchestrator

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors