Kubernetes Project: Create Multiple Pods

K8S Deployment | Flask Applications | Model Inference

This project demonstrates Kubernetes deployment strategies for multiple applications which include Deployments and Services at scale. It covers deployment of recruitment ranking application and Flask applications with multiple versions, implementing rolling updates, service exposure, and accessing machine learning models through web applications using tunnel methods.

Docker Image: rajesharigala/placementapp:v1-arm64 Docker Image: rajesharigala/placement-app-flask-ui:v1-arm64
Docker Image: rajesharigala/placement-app-flask-ui:v2-arm64 GitHub: minikube-K8S-multicontainer

Project Summary

Comprehensive Project Overview

Project Category

Multi-POD K8S deployment on Minikube.

Environment

Multi-POD K8S deployment on Minikube.

Applications

Flask Apps & ML Model Inference

Key Technologies & Concepts

Core Technologies Used

Kubernetes Keywords

Kubernetes Deployments Multi-POD K8S deployment on Minikube. Multi-Pod Architecture YAML Configuration Rolling Updates Services (ClusterIP, LoadBalancer) Pod Management ReplicaSets & Scaling Minikube Local Development kubectl Commands

Objectives & Use Case

Project Goals and Implementation

Primary Objectives

  • Create multiple pods using Kubernetes Deployments
  • Implement multi-version application deployment (v1 & v2)
  • Configure services for internal and external access
  • Implement rolling update strategy for zero-downtime deployments
  • Access machine learning model through Flask application
  • Monitor and manage application versions with rollout history

Use Case

  • Deploy recruitment ranking application with 2 replicas
  • Deploy Flask application versions v1 and v2
  • Expose applications via ClusterIP and LoadBalancer services
  • Access ML model inference through web interface
  • Implement version rollback capabilities

Solution & Architecture

Architectural Overview

Solution Overview

The project implements a Kubernetes-based deployment architecture with multiple applications running in pods. Two main applications are deployed:

1. Recruitment Rank App - Machine learning model for recruitment ranking with resource limits (CPU: 500m, Memory: 128Mi)

2. Flask App - Web application with multiple versions (v1 and v2) for ML model access

Services are configured for internal communication (ClusterIP) and external access (LoadBalancer). The architecture supports rolling updates with zero downtime and provides rollback capabilities.

Kubernetes Multi-Pod Deployment Architecture
1
Application Source
2
K8S Deployment
3
Pods Creation
4
Services Exposure
5
User Access

Key Components

  • Deployments: recruitment-rank-app, flask-app (v1 & v2)
  • Services: ClusterIP for internal, LoadBalancer for external access
  • Pods: Multiple replicas for high availability
  • ReplicaSets: Automatic pod management and scaling
  • Rolling Update Strategy: 25% max unavailable, 25% max surge

Deployment Configuration

YAML Configurations and Commands

Deployment YAML

apiVersion: apps/v1
kind: Deployment
metadata:
  name: recruitment-rank-app
spec:
  replicas: 2
  selector:
    matchLabels:
      app: recruitment-rank-app
  template:
    metadata:
      labels:
        app: recruitment-rank-app
    spec:
      containers:
      - name: placement-app
        image: rajesharigala/placementapp:v1-arm64
        resources:
          limits:
            memory: "128Mi"
            cpu: "500m"
        ports:
        - containerPort: 9696

Service YAML

apiVersion: v1
kind: Service
metadata:
  name: recruitment-rank-app
spec:
  type: ClusterIP
  selector:
    app: recruitment-rank-app
  ports:
  - protocol: "TCP"
    port: 80
    targetPort: 9696

Deployment Commands

Commands used to create and manage deployments:

kubectl create -f deployment.yaml
kubectl create -f service.yaml
kubectl get all

Deployment Results:

(base) jhonny001@rajeshs-MacBook-Pro ml-model % kubectl create -f deployment.yaml deployment.apps/recruitment-rank-app created (base) jhonny001@rajeshs-MacBook-Pro ml-model % kubectl create -f service.yaml service/recruitment-rank-app created (base) jhonny001@rajeshs-MacBook-Pro ml-model % kubectl get all NAME READY STATUS RESTARTS AGE pod/recruitment-rank-app-8889b6678-5r2rv 1/1 Running 0 67s pod/recruitment-rank-app-8889b6678-r6km9 1/1 Running 0 67s NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 8d service/recruitment-rank-app ClusterIP 10.98.93.66 <none> 80/TCP 6s NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/recruitment-rank-app 2/2 2 2 67s NAME DESIRED CURRENT READY AGE replicaset.apps/recruitment-rank-app-8889b6678 2 2 2 67s

Flask Application Deployment

Web Application with ML Model Access

Flask App Configuration

apiVersion: apps/v1
kind: Deployment
metadata:
  name: flask-app
  annotations:
    kubernetes.io/change-cause: "Version 1 deployment of Flask app"
spec:
  replicas: 2
  selector:
    matchLabels:
      app: flask-app
  template:
    metadata:
      labels:
        app: flask-app
    spec:
      containers:
      - name: flask-app
        image: rajesharigala/placement-app-flask-ui:v1-arm64
        ports:
        - containerPort: 5000
        env:
        - name: PORT
          value: "5000" # Flask's default port

Flask App Service (LoadBalancer):

apiVersion: v1
kind: Service
metadata:
  name: flask-app-service
spec:
  type: LoadBalancer # Use ClusterIP if only internal access is needed
  selector:
    app: flask-app
  ports:
  - protocol: TCP
    port: 5000 # Flask app's container port
    targetPort: 5000 # Container listening on port 5000

Deployment Results

(base) jhonny001@rajeshs-MacBook-Pro ml-model % kubectl get all NAME READY STATUS RESTARTS AGE pod/flask-app-559c7bd58f-ljdbx 1/1 Running 0 2m30s pod/flask-app-559c7bd58f-q9qkf 1/1 Running 0 2m30s pod/recruitment-rank-app-7b4647ddf4-2x4ff 1/1 Running 0 21m pod/recruitment-rank-app-7b4647ddf4-fg2gr 1/1 Running 0 21m NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/flask-app-service LoadBalancer 10.98.214.241 <pending> 5000:31996/TCP 12s service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 69d service/recruitment-rank-app ClusterIP 10.111.184.129 <none> 80/TCP 20m NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/flask-app 2/2 2 2 2m30s deployment.apps/recruitment-rank-app 2/2 2 2 21m NAME DESIRED CURRENT READY AGE replicaset.apps/flask-app-559c7bd58f 2 2 2 2m30s replicaset.apps/recruitment-rank-app-7b4647ddf4 2 2 2 21m

Rolling Updates & Version Management

Implementing Zero-Downtime Deployments

Rolling Update Strategy

Kubernetes implements rolling updates by default when updating a deployment. The strategy:

  • Old pods are replaced one by one
  • New pods are created before old pods are terminated
  • One old pod at a time is replaced
  • Strategy configuration: 25% max unavailable, 25% max surge

Strategy: Rolling Update strategy ensures zero downtime during application updates.

Version 2 Update

Updating to Flask App Version 2:

apiVersion: apps/v1
# Version 2 Deployment
metadata:
  name: flask-app
  annotations:
    kubernetes.io/change-cause: "Version 2 deployment of Flask app"
spec:
  containers:
    - name: flask-app
      image: 03asarath/placement-flask-app:v2
kubectl apply -f placement-flask-deployment.yaml

Rollout History & Rollback

View rollout history and manage versions:

kubectl rollout history deployment flask-app
deployment.apps/flask-app REVISION CHANGE-CAUSE 1 Version 1 deployment of Flask app 2 Version 2 deployment of Flask app
kubectl rollout undo deployment flask-app --to-revision=1
kubectl rollout status deployment flask-app

Access ML Model through Flask App

Tunnel Method to access the application:

minikube service flask-app-service

The service provides access to the Model Inference Dashboard where users can input:

  • Port Number
  • Gender
  • SSC Percentage & Board
  • HSC Percentage, Board & Stream

Starting tunnel for service flask-app-service. Opening service default/flask-app-service in default browser...

URL: http://192.168.49.2:31404

Skills & Technologies Used

Technical Proficiency Demonstrated

Primary Skills

  • Kubernetes Deployment Configuration with YAML
  • Multi-Pod Architecture Design and Implementation
  • Service Configuration (ClusterIP, LoadBalancer)
  • Rolling Update Strategy Implementation
  • Application Version Management
  • kubectl Command Line Proficiency

Secondary Tools / Platforms

  • Minikube for Local Development
  • Docker Container Images
  • Flask Web Framework
  • Machine Learning Model Integration

Programming & Configuration

YAML Configuration Kubernetes Deployments Flask Applications Docker Images Python Bash Scripting

Assets & References

Code, diagrams, study material

Kubernetes YAML Files

Complete set of YAML configuration files for deployments, services, and updates.

View Files

Study Material Resources

Click the button below to open the study materials

Request Study Material

Study Material - Kubernetes Multi-Pod Deployment

Kubernetes Multi-Pod Deployment Guide
Complete guide to deploying multiple applications with pods in Kubernetes
Download
YAML Configuration Reference
Complete reference for Kubernetes YAML configuration files
Download
Minikube Deployment Guide
Step-by-step guide to Multi-POD K8S deployment on Minikube.
Download
Rolling Update Strategies
Comprehensive guide to implementing zero-downtime deployments
Download
Flask App Kubernetes Deployment
Guide to deploying Flask applications with ML model integration
Download
kubectl Command Reference
Complete reference for kubectl commands and usage patterns
Download
Production Kubernetes Architecture
Enterprise patterns for scalable Kubernetes deployments
Download
Minikube Development Guide
Complete guide to local Kubernetes development with Minikube
Download