Technique For Load Balancing with
Kubernetes and Python
A Project report submitted in partial fulfilment
of the requirements for the degree of B. Tech in Electrical Engineering
By
Name of the Students (Roll No.)
Abhro Roy (11701619034)
Deepanjan Mondal (11701619025)
Anish Chakraborty (11701619015)
Under the supervision of
Shilpi Bhattacharya, Associate Professor
Department of Electrical Engineering
Department of Electrical Engineering
RCC INSTITUTE OF INFORMATION TECHNOLOGY
CANAL SOUTH ROAD, BELIAGHATA, KOLKATA – 700015, WEST BENGAL
Maulana Abul Kalam Azad University of Technology (MAKAUT)
1
ACKNOWLEDGEMENT
It is my great fortune that I have got opportunity to carry out this project work under the supervision
of Prof. (Dr.) Shilpi Bhattacharya in the Department of Electrical Engineering, RCC Institute of
Information Technology (RCCIIT), Canal South Road, Beliaghata, Kolkata-700015, affiliated to
Maulana Abul Kalam Azad University of Technology (MAKAUT), West Bengal, India. I
express my sincere thanks and deepest sense of gratitude to my guide for his constant support,
unparalleled guidance and limitless encouragement.
I wish to convey my gratitude to Prof. (Dr.) Shilpi Bhattacharya, HOD, Department of
Electrical Engineering, RCCIIT and to the authority of RCCIIT for providing all kinds of
infrastructural facility towards the research work.
I would also like to convey my gratitude to all the faculty members and staffs of the
Department of Electrical Engineering, RCCIIT for their whole hearted cooperation to make this
work turn into reality.
-----------------------------------------------
-----------------------------------------------
-----------------------------------------------
Signature of the Students
Place:
Date:
2
Department of Electrical Engineering
RCC INSTITUTE OF INFORMATION TECHNOLOGY
CANAL SOUTH ROAD, BELIAGHATA, KOLKATA – 700015, WEST BENGAL
CERTIFICATE
To whom it may concern
This is to certify that the project work entitled Technique For Load Balancing
with Kubernetes and Python is the bona fide work carried out by Abhro Roy
(11701619034), Deepanjan Mondal (11701619025) , Anish Chakraborty
(11701619015) students of [Link] in the Dept. of Electrical Engineering, RCC
Institute of Information Technology (RCCIIT), Canal South Road, Beliaghata,
Kolkata-700015, affiliated to Maulana Abul Kalam Azad University of Technology
(MAKAUT), West Bengal, India, during the academic year 2021-22, in partial
fulfillment of the requirements for the degree of Bachelor of Technology in
Electrical Engineering and this project has not submitted previously for the
award of any other degree, diploma and fellowship.
_____________________ ________________________
Signature of the Guide Signature of the HOD, EE
Name: Name:
Designation: Designation:
___________________________
Signature of the External Examiner
Name:
Designation:
3
TABLE OF CONTENTS
1. Introduction 5
2. Literature Survey 6
3. Technologies and methodologies used in this project 6
3.1 Kubernetes 6
3.2 Python 6
3.3 Docker 6
4. Techniques used for real-life implementation and working 6
4.1 Writing the python script 6
4.2 Creating the custom image with Dockerfile 7
4.3 Setting up the Kubernetes cluster 8
4.4 Assigning nodes and pods 9
4.5 Exposing outside Kubernetes 10
5. Visual Representation 11
6. Future Work 11
7. Conclusion 11
REFERENCES 12
4
Technique For Load Balancing with Kubernetes and Python
Abhro Roy, Deepanjan Mondal, Anish Chakraborty, Shilpi Bhattacharya
Electrical Engineering
RCC Institute of Information Technology, Kolkata
e-Mail: abirabhroroy@[Link]
ABSTRACT
Often we find servers across organizations and institutes having servers which have minimal to no load on
normal days but peak during certain times of the year and are slow and overload rendering the site to little
use. Kubernetes enables versatile deployment of applications which are auto-scaled, auto-maintained, and
auto-managed depending on variety of parameters including peak load.
Keywords: Kubernetes, Python, Docker, Linux
1. INTRODUCTION
Kubernetes is a portable, extensible, open source platform for managing containerized workloads and
services, that facilitates both declarative configuration and automation. It has a large, rapidly growing
ecosystem. Kubernetes services, support, and tools are widely available.
Kubernetes is an open-source platform renowned for its versatility in managing containerized workloads and
services. It offers portability, enabling seamless deployment and management across various cloud
environments, including public, private, and hybrid setups. With its extensible architecture, Kubernetes
allows users to incorporate additional functionalities through a wide range of plugins and extensions
available in its thriving ecosystem.
At the heart of Kubernetes lies the concept of declarative configuration, empowering users to define the
desired state of their applications and infrastructure. Through automated orchestration, Kubernetes handles
the complexities of deploying, scaling, and updating applications, freeing developers and operators to focus
on higher-level tasks.
The name "Kubernetes" derives its significance from Greek, meaning "helmsman" or "pilot." This metaphor
aptly represents Kubernetes' role as a guiding force, steering applications and services towards smooth
operation and optimal performance. The abbreviation "K8s" simplifies pronunciation while emphasizing the
eight letters between "K" and "s."
In 2014, Google's decision to open-source Kubernetes marked a pivotal moment in container orchestration.
Leveraging Google's extensive experience in managing production workloads at scale, Kubernetes
incorporates industry best practices and community-driven innovations. Today, it has become the industry
standard for container orchestration due to its robust architecture and feature set.
Kubernetes owes its success and popularity to its vibrant ecosystem. An active community of developers,
operators, and vendors contribute to its development, offering a wealth of tools, frameworks, and services
that complement and enhance Kubernetes' capabilities. This extensive ecosystem ensures comprehensive
support, documentation, and resources, simplifying adoption and utilization of Kubernetes for various use
cases.
In conclusion, Kubernetes is a dynamic and evolving platform that empowers organizations to efficiently
manage and scale their containerized workloads and services. Its portability, extensibility, and declarative
nature, along with its thriving ecosystem, make it the preferred choice for modern application deployment
and orchestration.[1]
5
2. LITERATURE SURVEY
Deploying a Kubernetes cluster is cost-effective as it leverages open-source code freely available to
everyone. The software itself is open source and does not require any licensing fees. However, it is important
to note that while the software is free, there are associated costs for hardware and infrastructure.
To host a Kubernetes architecture, a relatively modest bare-metal system is typically sufficient. It does not
necessarily require high-end or expensive hardware. A moderately capable system can effectively run a
Kubernetes cluster without significant issues. The hardware requirements may vary depending on the scale
and complexity of the workload and the number of nodes in the cluster.
It is worth mentioning that although the software cost is minimal, there may still be expenses related to
networking, storage, and other infrastructure components required to support the Kubernetes cluster.
Additionally, there might be costs associated with maintenance, monitoring, and ongoing operational
support.
Overall, while the software itself is open source and freely available, the cost of deploying a Kubernetes
cluster includes considerations for hardware and infrastructure, as well as potential ongoing operational
expenses.[2]
3. TECHNOLOGIES AND METHODOLOGIES USED IN THIS PROJECT
The resources used to deploy this entire architecture are less in number, but implemented in depth. They are
as follows:
1. KUBERNETES
The actual platform which hosts our code, application and all the bells and whistles required to seamlessly
expose the application as a service outside Kubernetes.
2. PYTHON
The application is developed using a specific programming language, and it is complemented by a Python-
Flask server to facilitate hosting the application within a containerized environment. The choice of
programming language depends on various factors, including the requirements, preferences, and expertise of
the development team. Python-Flask, a popular web framework, is utilized as the server to provide a
lightweight and flexible platform for running the application. By combining the chosen programming
language with the Python-Flask server, the application can be effectively encapsulated and deployed within a
container, ensuring portability, scalability, and ease of management.
3. DOCKER
Docker is a containerization platform used to deploy containers, which are nothing but a shell of a base
image of an OS, on which one can install all the resources one installs on a normal bare-metal OS.
Containers are surprisingly light and fast and are used during mass deployment of similar applications for
milking out the most of the resources available at hand.
4. TECHNIQUES USED FOR REAL-LIFE IMPLEMENTATION AND WORKING
1. Writing the python script
Write a python code with Flask web server to print a basic html page with ip of the host it is running on and
push the image to DockerHub.
6
7
8
4. Assigning Node and Pods
To deploy our application on Kubernetes, we begin by pulling our custom Docker image from DockerHub.
This image contains all the necessary dependencies and configurations for our application.
Next, we set up a pod, which is a single instance of a Docker container, using the pulled image. Kubernetes
then assigns an IP address to the pod and determines the node where the pod will run. We can access this IP
address from within the Kubernetes cluster to verify the pod's availability.
9
10
11
REFERENCES
[1] D. Ashley, “Using Flask and Jinja,” Foundation Dynamic Web Pages with Python, pp. 159–181, 2020, doi: 10.1007/978-1-
4842-6339-6_5.
[2] D. Ashley, “Introduction to Web Servers,” Foundation Dynamic Web Pages with Python, pp. 1–27, 2020, doi: 10.1007/978-1-
4842-6339-6_1.
[3] O. Yilmaz, “Introduction,” Extending Kubernetes, pp. 1–19, 2021, doi: 10.1007/978-1-4842-7095-0_1.
[4] M. Lukša, “Kubernetes erweitern,” Kubernetes in Action, pp. 553–578, Jul. 2018, doi: 10.3139/9783446456020.018
[5] Q. Li and B. Moon, “Distributed cooperative Apache web server,” Proceedings of the tenth international conference on World
Wide Web
[6] M. Shahinpoor, Y. Bar-Cohen, T. Xue, J.O. Simpson and J. Smith, “Ionic Polymer-Metal Composites (IPMCs) as Biomimetic
Sensors, Actuators and Artificial Muscles: A Review”, Proceedings of SPIE's 5th Annual International Symposium on Smart
Structures and Materials, 1-5 March, 1998, San Diego, CA DOI: 10.1088/0964-1726/7/6/001
[7] Zheng Chen, Yantao Shen, Jason Malinak, Ning Xi, Xiaobo Tan,“Hybrid IPMC/PVDF Structure for Simultaneous Actuation
and Sensing”, Proceedings of SPIE Vol. 6168, Smart Structures and Materials, pp. 61681L 1 – 61681L9, 2006. DOI:
10.1109/ICIEV.2014.6850840
[8] R.K. Jain, S. Datta and S. Majumder, “Design and Control of an EMG Driven IPMC Based Artificial Muscle Finger”
[9] S. Bhat, “Introduction to Containerization,” Practical Docker with Python, pp. 1–8, 2018, doi: 10.1007/978-1-4842-3784-7_1.
[10] K. Jangla, “Docker Compose,” Accelerating Development Velocity Using Docker, pp. 77–98, 2018, doi: 10.1007/978-1-4842-
3936-0_6.
12