Skip to content

ima110/pythonapp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Web Application with Kubernetes Deployment

📘 Project Description

A simple Python web application with login functionality, containerized and deployed on Kubernetes. The application serves a login page and handles authentication with hardcoded credentials for demonstration purposes.


📁 Project Structure

├── server.py          # Python HTTP server implementation
├── index.html         # Login page HTML file
├── deployment.yaml    # Kubernetes deployment configuration
├── service.yaml       # Kubernetes service configuration
└── README.md          # Project documentation

⚙️ Application Components

Backend (server.py)

  • Built with Python’s http.server module

  • Handles GET requests for serving the login page

  • Processes POST requests for login authentication

  • Hardcoded credentials:

    • Username: admin
    • Password: 1234
  • Server runs on port 8001

Frontend (index.html)

  • Clean, responsive login form
  • CSS styling for modern appearance
  • Form submission to /login endpoint

☸️ Kubernetes Configuration

Deployment (deployment.yaml)

  • Deployment name: pythonapp-deployment
  • Replicas: 2 (for high availability)
  • Container image: ima110/pythonapp:latest
  • Container port: 8001

Service (service.yaml)

  • Service name: python-app-service
  • Type: LoadBalancer
  • External port: 80
  • Target port: 8001
  • Selector: app: pythonapp

🧩 Prerequisites

  • A running Kubernetes cluster
  • kubectl configured
  • Docker image available at ima110/pythonapp:latest

🚀 Quick Start

Deploy to Kubernetes

# Apply the deployment
kubectl apply -f deployment.yaml

# Apply the service
kubectl apply -f service.yaml

Verify Deployment

# Check deployment status
kubectl get deployments

# Check service and get external IP
kubectl get services

# Monitor pods
kubectl get pods -l app=pythonapp

🌐 Access the Application

Once deployed, access the app using the external IP from the LoadBalancer service:

http://<EXTERNAL-IP>/

Default Login Credentials

Username: admin
Password: 1234

📊 Monitoring and Logs

# View application logs
kubectl logs -l app=pythonapp

# Check pod status
kubectl get pods -l app=pythonapp

# View detailed pod information
kubectl describe pod -l app=pythonapp

🔒 Security Note

This application uses hardcoded credentials for demonstration only. For production environments:

  • Implement secure credential storage
  • Use environment variables
  • Enforce HTTPS and encryption

🔁 CI/CD Integration

The deployment is compatible with Jenkins CI/CD pipelines. Jenkins dynamically updates the deployment by replacing the latest image tag with the appropriate build tag during automated deployment.

About

Devopsified python app

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •