Skip to content

Anantha018/Mini_Deployer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Mini Deployment Platform πŸš€

A lightweight Platform-as-a-Service (PaaS) that automatically deploys applications from GitHub repositories using Docker and Kubernetes (K3s).

πŸŽ₯ Platform Demo

Watch the Demo

Users submit a GitHub repository, and the platform automatically:

  • Clones the repository

  • Builds a Docker image

  • Pushes the image to Docker Hub

  • Deploys the container to Kubernetes

  • Exposes the application publicly

This project demonstrates DevOps, container orchestration, and platform engineering concepts.

Author

Anantha Sridhar

DevOps β€’ Platform Engineering β€’ Cloud Infrastructure

Prerequisites

Before setting up the platform, ensure you have:

  • AWS account
  • Docker Hub account
  • A purchased domain
  • SSH client
  • Git installed

Basic knowledge of:

  • Docker
  • Kubernetes
  • Linux commands

Architecture

                                User
                                β”‚
                                β”‚ Submit GitHub Repo
                                β–Ό
                                FastAPI Deployment API
                                β”‚
                                β–Ό
                                GitHub Repository
                                β”‚
                                β–Ό
                                Docker Build
                                β”‚
                                β–Ό
                                Docker Hub Registry
                                β”‚
                                β–Ό
                                Kubernetes (K3s)
                                β”‚
                                β–Ό
                                Traefik Ingress
                                β”‚
                                β–Ό
                                Public URL

Tech Stack

Component Usage
FastAPI Backend deployment API
Docker Containerization
Docker Hub Image registry
Kubernetes (K3s) Container orchestration
Traefik Ingress controller
AWS EC2 Infrastructure

Step 0

  • Before deploying the platform, you must update the configuration variables in the code.

  • Open the configuration file (usually in the backend where deployments are handled) and replace the placeholder values:

DOCKER_USERNAME = "DOCKER_USERNAME" 
DOMAIN = "YOUR_DOMAIN"               
DOCKER_REPO = "YOUR_DOCKER_HUB_REPO" 

Example:

DOCKER_USERNAME = "Anantha Sridhar"
DOMAIN = "deploywithanantha.xyz"
DOCKER_REPO = "mini-platform"

These values are required for the platform to correctly build, push, and expose deployed applications.

1️⃣ Create a Docker Hub Repository

Go to:

https://hub.docker.com

Create a new repository.

Example:

Repository Name: mini-platform-images

Why this is required:

  • Kubernetes does not build images.
  • It pulls images from a container registry.

Without a Docker repository, Kubernetes cannot deploy the application containers.

2️⃣ Buy a Domain

You must purchase a domain for exposing deployed applications.

Recommended providers:

Namecheap
Cloudflare
Google Domains

Example domain:

deploywithanantha.xyz

This domain will be used to route traffic to applications deployed in Kubernetes.

3️⃣ Configure DNS

Add an A record pointing to your Elastic IP.

Example:

Type Name Value
A @ EC2 Elastic IP

Example result:

deploywithanantha.xyz β†’ 54.xx.xx.xx

Step 1 β€” Create an AWS EC2 Instance

Go to AWS Console β†’ EC2 β†’ Launch Instance

Configuration:

Setting Value
OS Ubuntu 22.04
Instance Type t2.micro / t3.micro
Storage 20GB
Key Pair Create .pem key

Download the key file.

Example:

Demo_Docker.pem

Step 2 β€” Configure Security Group

Add the following inbound rules.

Type Port
SSH 22
HTTP 80
HTTPS 443
Custom TCP 8000

Why these ports?

Port Purpose
22 SSH access
80 HTTP traffic
443 HTTPS
8000 FastAPI server

Step 3 β€” Allocate Elastic IP

AWS public IPs change when the instance restarts.

  • Elastic IP ensures:

  • Stable domain mapping

  • Stable HTTPS certificates

  • Permanent public endpoint

Go to:

EC2 β†’ Elastic IPs β†’ Allocate

Then associate it with your instance.

Step 4 β€” Connect to EC2

ssh -i "<your_pem_file.pem>" ubuntu@<elastic-ip>

Example:

ssh -i "<your_pem_file.pem>" ubuntu@54.210.xx.xx

Step 5 β€” Install Docker

sudo apt update
sudo apt install docker.io -y

sudo systemctl enable docker
sudo systemctl start docker

sudo usermod -aG docker ubuntu

logout
docker ps

Step 6 β€” Install Kubernetes (K3s)

K3s is a lightweight Kubernetes distribution.

Install it:

curl -sfL https://get.k3s.io | sh -

Check installation:

sudo kubectl get nodes

Expected output:

Ready control-plane

Step 7 β€” Configure kubectl

Copy kubeconfig to your user.

sudo mkdir -p ~/.kube
sudo cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
sudo chown ubuntu:ubuntu ~/.kube/config

Set environment variable:

export KUBECONFIG=/home/ubuntu/.kube/config

Verify:

kubectl get nodes

Step 8 β€” Install Python Environment

sudo apt install python3 python3-pip python3-venv -y

Clone the project.

git clone https://github.com/YOUR_USERNAME/mini_deployment_platform
cd mini_deployment_platform

Create virtual environment.

python3 -m venv env
source env/bin/activate

Install dependencies.

pip install -r requirements.

Step 9 β€” Docker Hub Login

Login to Docker Hub.

docker login

Why is a Docker registry needed?

- Kubernetes does not build images.

- It only pulls images from registries.

Deployment flow:

Code β†’ Docker Build β†’ Docker Hub β†’ Kubernetes pulls image

Without a registry Kubernetes cannot deploy containers.

Step 10 β€” Run the Deployment API

Start the backend.

uvicorn app.main:app --host 0.0.0.0 --port 8000

Access the API documentation.

http://<elastic-ip>:8000/

Step 13 β€” HTTPS Setup

If Kubernetes commands fail because of config issues:

export KUBECONFIG=/home/ubuntu/.kube/config

Traefik can automatically generate HTTPS certificates using Let's Encrypt.

Repository Structure Required for Deployment

Applications must contain a Dockerfile.

Example structure:

my-app
β”‚
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ main.py
β”‚
β”œβ”€β”€ app
β”‚   └── main.py
β”‚
└── README.md

Example Dockerfile

FROM python:3.10-slim

WORKDIR /app

COPY requirements.txt .

RUN pip install -r requirements.txt

COPY . .

CMD ["uvicorn","main:app","--host","0.0.0.0","--port","8000"]

Important Deployment Rules

Applications must:

  • Include a Dockerfile

  • Expose port 8000

  • Bind to 0.0.0.0

Example:

uvicorn main:app --host 0.0.0.0 --port 8000

Deployment Flow

When a user submits a repository:

POST /deploy

Example request:

{
 "github_url": "https://github.com/user/app"
}

Internal process:

1. Clone repository
2. Build Docker image
3. Push image to Docker Hub
4. Generate Kubernetes YAML
5. Deploy container
6. Create service
7. Expose application

Debugging Errors

No Server Available Error

Sometimes old deployments consume resources.

Delete previous deployments.

kubectl get deployments

Then remove unused apps.

kubectl delete deployment <deployment-name>

Example:

kubectl delete deployment testapp

Kubernetes Commands Not Working

Run:

export KUBECONFIG=/home/ubuntu/.kube/config

Docker Permission Error

Fix permissions.

sudo usermod -aG docker ubuntu

Then reconnect to the server.

SSH Host Key Changed

Run:

ssh-keygen -R <ec2-host>

Future Improvements

  • Dynamic subdomains for deployed apps

  • GitHub webhook auto-deploy

  • Horizontal Pod Autoscaling

  • Multi-node Kubernetes cluster

  • Deployment Dashboard

  • Auto-detect project type

About

A mini Platform-as-a-Service that deploys GitHub applications automatically using Docker and Kubernetes (K3s), builds images, pushes to Docker Hub, and exposes apps publicly via a simple API.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages