Skip to content

Its Hypervisor Service, where user can create a cluster and deploy.

Notifications You must be signed in to change notification settings

subhamyadav580/hypervisor-service

Repository files navigation

Hypervisor-like Service for MLOps Platform

This project implements user authentication, organization management, cluster creation, and deployment management using FastAPI, SQLite3, and JWT authentication. It also includes Docker support for easy deployment.

Features

  1. User Authentication
  • Register & login users securely with JWT.
  • Passwords are hashed using bcrypt.
  • Users have a specific role (admin, developer, viewer)
  1. Organization Management
  • Users can join organizations using an invite code.
  1. Cluster Management
  • Users can create clusters with fixed resources (RAM, CPU, GPU).
  • Only users with admin role can create new clusters.
  1. Deployment Management
  • Deployments are created with resource allocation.
  • Only users having admin anddeveloper role can create deployment.
  • Automatic resource allocation
  • Queue management for pending deployments
  • Priority-based deployment scheduling
  • Preemption support for high-priority workloads
  • Includes a priority-based queuing system.
  1. JWT-Based Security
  • Protect API routes with authentication.

Getting Started

Step: 1 Clone the Repository

git clone https://github.com/subhamyadav580/hypervisor-service
cd hypervisor-service

Step: 2 Build Image

docker-compose build

Step: 3 Start the service

docker-compose up -d

Authentication Workflow

Create a Organization

Sample Request

curl --location --request GET 'http://localhost:8000/create_organization' \
--header 'Content-Type: application/json' \
--data '{
    "name": "dev-team"
}'

Sample Response

{"message":"organization created successfully","invite_code":"4wfvuKqjhZ"}

Register a User

Sample Request

curl --location 'http://localhost:8000/register' \
--header 'Content-Type: application/json' \
--data-raw '{
   "username" : "shubham",
   "password": "test@12345",
   "role": "admin"
}'

Sample Response

{"message":"user successfully created","username":"shubham"}

Join Organization by invite_code

Sample Request

invite_code: It will be recived when you will create a organization.

curl --location 'http://localhost:8000/join_organization' \
--header 'Content-Type: application/json' \
--data '{
    "invite_code": "4wfvuKqjhZ",
    "username": "shubham"
}'

Sample Response

{"message":"you have successfully joined the organization"}

Login and Get JWT Token

Sample Request

curl --location 'http://localhost:8000/login' \
--header 'Content-Type: application/json' \
--data-raw '{
   "username" : "shubham",
   "password": "test@12345"
}'

Sample Response

{"access_token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiNGZjYzEzODctYmM5Ni00YTg5LTk3ODQtNGNkNDFlMjNjNDUxIiwib3JnYW5pemF0aW9uX2lkIjoiNTk3ODU3NDItMzk3OS00Y2I2LTgyYmEtMTVmODdjMGVkYTczIiwicm9sZSI6ImFkbWluIiwiZXhwIjoxNzQwMzE0ODcxfQ.QdQ5tu7njYdKVd3EVv8jAb63EjT91kjril6FBt7CTNU","token_type":"bearer","is_authorized":true}

Create a Cluster (Authenticated API)

Sample Request

curl --location 'http://localhost:8000/create_cluster' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiNGZjYzEzODctYmM5Ni00YTg5LTk3ODQtNGNkNDFlMjNjNDUxIiwib3JnYW5pemF0aW9uX2lkIjoiNTk3ODU3NDItMzk3OS00Y2I2LTgyYmEtMTVmODdjMGVkYTczIiwicm9sZSI6ImFkbWluIiwiZXhwIjoxNzQwMzE0ODcxfQ.QdQ5tu7njYdKVd3EVv8jAb63EjT91kjril6FBt7CTNU' \
--header 'Content-Type: application/json' \
--data '{
    "cluster_name": "cluster-1",
    "total_cpu": 32,
    "total_ram":  64,
    "total_gpu": 2
}'

Sample Response

{"message":"cluster has been created successfully","cluster_id":"28ba2722-a17c-4dca-a46a-5925384aef16"}

Create a Deployment (Authenticated API)

Sample Request

curl --location 'http://localhost:8000/create_deployment' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiNGZjYzEzODctYmM5Ni00YTg5LTk3ODQtNGNkNDFlMjNjNDUxIiwib3JnYW5pemF0aW9uX2lkIjoiNTk3ODU3NDItMzk3OS00Y2I2LTgyYmEtMTVmODdjMGVkYTczIiwicm9sZSI6ImFkbWluIiwiZXhwIjoxNzQwMzE0ODcxfQ.QdQ5tu7njYdKVd3EVv8jAb63EjT91kjril6FBt7CTNU' \
--header 'Content-Type: application/json' \
--data '{
    "cluster_id": "28ba2722-a17c-4dca-a46a-5925384aef16",
    "image_path": "tinyllama:latest",
    "required_cpu": 32,
    "required_ram": 48,
    "required_gpu": 0,
    "priority": 3
}'

Sample Response

{"message":"Deployment added to queue","deployment_id":"2ef2dbaf-b443-48bc-a577-5e9436c69522"}

UML Diagram of DB

UML Diagram of the service

About

Its Hypervisor Service, where user can create a cluster and deploy.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published