KEMBAR78
Devops with Docker and K8S + django example | PDF
DEVOPS WITH
DOCKER AND
KUBERNETES
SOA presentation
1
2024-2025
Deploying a Django Application
Introduction to DevOps
01
Understanding Docker
02
Introduction to Kubernetes
03
Benefits of Docker and Kubernetes in
DevOps
Conclusion
04
05
06
Table of
Table of
contents
contents
2
INTRODUCTION
TO
3
Introduction to DevOps
Introduction to DevOps
4
Why DevOps is revolutionizing software development ?
Introduction to DevOps
Introduction to DevOps
5
Why DevOps is revolutionizing software development ?
Introduction to DevOps
Introduction to DevOps
6
Why DevOps is revolutionizing software development ?
Introduction to DevOps
Introduction to DevOps
7
Why DevOps is revolutionizing software development ?
8
Introduction to DevOps
Introduction to DevOps
Who Introduced DevOps and When?
Patrick Debois DevOpsDays conference
the "Father of DevOps” 2009
Introduction to DevOps
Introduction to DevOps
9
Why DevOps is revolutionizing software development ?
Devops is not a technology, tool or framework .
DevOps is a cultural movement, mindset, philosophy to coordiante produce better, more reliable products.
by automating infrastructure, workflow, and continuously measuring application performance
for which they use a lot of tools.
Introduction to DevOps
Introduction to DevOps
10
Why DevOps is revolutionizing software development ?
The DEVOPS lifecycle :
You can visualize a Devops process as an infinite
loop, comprising the illustrated steps through
feedback --plan , which resets the loop.
Understanding
11
Understanding Docker
Understanding Docker
12
What is Docker ?
1.
Docker is a powerful platform that
simplifies the process of building,
shipping, and running applications.
Understanding Docker
Understanding Docker
13
Solomon Hykes
1.1 - History of docker :
Understanding Docker
Understanding Docker
14
1.2 - VMs Containers :
15
Understanding Docker
Understanding Docker
1.3 - Docker Architecture :
Understanding Docker
Understanding Docker
16
1.4 - The Process of Creating Containers
Definition: Scripts used to create Docker images.
Purpose: Automates and ensures repeatable, consistent
image creation.
Structure: A text file containing a series of commands
that Docker uses to assemble an image
2. DockerFile :
Understanding Docker
Understanding Docker
17
3. Docker image :
These are the blueprints of applications.
A Docker image is a lightweight, standalone, and
executable package that includes everything needed to
run a piece of software .
Images are immutable, meaning once they’re created,
they don’t change.
Understanding Docker
Understanding Docker
18
Understanding Docker
Understanding Docker
Docker image Registries
19
4. Docker container :
A Docker container is like that lunchbox
self-sufficient and portable.
Imagine you have a lunchbox that contains
everything you need for a meal.
Understanding Docker
Understanding Docker
20
Toss it, and it leaves no mess. Stop the container, and it leaves no
mess.
Multiple containers on a host
Multiple lunchboxes in your
backpack.
You can have
When you're done
Understanding Docker
Understanding Docker
21
Docker containers are runnable instances of Docker images.
They encapsulate the application and its dependencies, providing
an isolated environment for execution.
Containers can be created, started, stopped, moved, and deleted
using Docker commands.
4. Docker container :
So, what’s a docker container ?
Understanding Docker
Understanding Docker
22
5. Docker compose :
Understanding Docker
Understanding Docker
23
Docker Compose is a tool for defining and running
multi-container Docker applications.
It uses a YAML file (docker-compose.yml) to
specify services, networks, volumes, and other
configurations required for the application.
5. Docker compose :
Understanding Docker
Understanding Docker
24
25
6. Docker Volumes:
Understanding Docker
Understanding Docker
26
7. Docker Networking:
Understanding Docker
Understanding Docker
Docker Hub is a cloud-based repository service
provided by Docker for storing and sharing Docker
images.
It serves as a central hub for the Docker community,
offering access to thousands of public images and
enabling collaboration among developers and
operations teams.
Understanding Docker
Understanding Docker
8. DOCKER HUB :
27
Before Docker Hub
Lack of
Standardization
No Centralized
Storage
Collaboration
Barriers
Limited
Automation
Quality Control
Issues
8. DOCKER HUB :
Understanding Docker
Understanding Docker
28
Searching for Images:
Use the docker search command to search for images on Docker Hub:
Pulling Images:
Pull Docker images from Docker Hub using the docker pull command:
Pushing Images:
Push local Docker images to Docker Hub using the docker push command :
Understanding Docker
Understanding Docker
8. DOCKER HUB :
29
Introduction to
30
Introduction to Kubernetes
Introduction to Kubernetes
31
What is Kubernetes ?
1.
Kubernetes, or K8s, is an open-
source platform designed to
automate the deployment,
management, and scaling of
containerized applications.
32
Created by Google, now maintained by the Cloud Native Computing
Foundation (CNCF).
Kubernetes is tailored for modern, container-based environments, such as
those orchestrated with Docker
2014
2015
Introduction to Kubernetes
Introduction to Kubernetes
Key Purposes of Kubernetes
34
2.Kubernetes Architecture
Introduction to Kubernetes
Introduction to Kubernetes
Introduction to Kubernetes
Introduction to Kubernetes
35
What is a Cluster ?
A group of computers (physical or
virtual) that work together as a
system.
In Kubernetes, the cluster consists of:
A Control Plane (the brain of
Kubernetes).
Worker Nodes (the machines where
applications run).
The Control Plane is responsible for managing the
cluster, maintaining its desired state, and scheduling
workloads. It includes:
API Server:
Acts as the entry point for all administrative tasks. It
handles communication between the user (via CLI or UI)
and the cluster.
A - Kubernetes Master (Control Plane) :
Introduction to Kubernetes
Introduction to Kubernetes
36
Introduction to Kubernetes
Introduction to Kubernetes
Scheduler:
Decides which worker node will run a given pod based on
resource availability.
Controller Manager:
Ensures the desired state of the cluster by managing
controllers, like replicating pods or handling node
failures.
etcd:
A key-value store that holds the cluster's configuration
and state. It's critical for cluster consistency.
37
A - Kubernetes Master (Control Plane) :
These are the machines where your applications
actually run. Each worker node has:
Pods:
A pod is the smallest unit in Kubernetes. It runs
one or more containers.
Example: If you're running a web server, it will
be inside a pod.
B - Worker Nodes :
Introduction to Kubernetes
Introduction to Kubernetes
38
Kubelet:
The guardian of the node. It ensures that the
pod is healthy and running properly.
Kube-proxy:
Manages communication between different
parts of the cluster and the outside world.
Container Runtime (e.g., Docker):
This is the tool that runs the actual containers.
Introduction to Kubernetes
Introduction to Kubernetes
39
B - Worker Nodes :
Introduction to Kubernetes
Introduction to Kubernetes
3. Kubernetes YAML File Overview
A Kubernetes YAML file is used to
define resources and their
configurations in a Kubernetes cluster.
It is written in YAML syntax and is
structured with key-value pairs.
40
41
A - Key Sections in a Kubernetes YAML File:
apiVersion
Specifies the API version of the
Kubernetes resource.
Example: apps/v1, v1.
Introduction to Kubernetes
Introduction to Kubernetes
metadata
Contains metadata about the
resource.
spec
The main configuration of the
resource, varying by resource
type.
Introduction to Kubernetes
Introduction to Kubernetes
B - Communication Flow :
42
C - Example: Deploying a Django Web Application :
Introduction to Kubernetes
Introduction to Kubernetes
The API Server processes your deployment request via kubectl.
The Scheduler assigns your Django app to a worker node.
The Kubelet ensures the app container runs properly in a pod.
43
Liveness and readiness probes are checks that Kubernetes performs on your
pods to determine their health.
Liveness probes check if your application is still running, while readiness
probes check if your application is ready to receive traffic.
4. Kubernetes Probes ?
Introduction to Kubernetes
Introduction to Kubernetes
So you’ve built an amazing app and deployed it to
Kubernetes .
That’s where liveness and readiness probes come in.
But how do you make sure your app stays up and running as
intended?
44
45
Liveness probes check if your application is up and running.
They ensure that if a pod goes down for any reason,
Kubernetes can restart it and get your app back online.
There are three types of liveness probes:
1. HTTP probe: checks for a successful HTTP response
(status code 200–399). This is good for web apps and REST
APIs.
2. TCP probe: Checks if a TCP port is open. Use this for non-
HTTP apps.
3. Exec probe: Executes a command inside the container.
Checks the exit code to determine health.
Introduction to Kubernetes
Introduction to Kubernetes
A- Liveness Probes
46
Introduction to Kubernetes
Introduction to Kubernetes
Readiness probes check if your application pods are
ready to accept traffic.
If a readiness probe fails, Kubernetes will remove the
pod from service load balancers and endpoints.
This ensures that clients don’t access pods that are not
ready to handle requests.
Some examples of readiness probes include:
Checking if a web server returns a 200 OK response
on a certain endpoint
Seeing if a database connection can be established
B- Readiness Probes
47
Deploying a
48
A Dockerfile was created to containerize the
Django application :
Uses the Python 3.10 image.
Installs the dependencies specified in
requirements.txt.
Copies the project into the container and
exposes port 8000.
Configures the Django server startup to run
the application.
Deploying a Django Application with Docker and K8S
Deploying a Django Application with Docker and K8S
49
Dockerfile_Django
Deploying a Django Application with Docker and K8S
Deploying a Django Application with Docker and K8S
50
The docker-compose.yml file was created to orchestrate
the Django application with PostgreSQL :
Django Service : Based on the created Dockerfile, it
runs the web application, uses the volume named app
for storing necessary data, and is integrated into the
Docker network.
PostgreSQL Service : Uses the official PostgreSQL
image, with environment variables defining the
database parameters (user, password, name). It uses
the volume named db_data to ensure data
persistence.
docker-compose.yml
51
The command “docker-compose up --build” uses the Docker Compose tool to build the Docker image
specified in the Docker Compose file, then start the containers defined in it. The “--build” flag ensures
the latest changes are incorporated before starting the containers.
Deploying a Django Application with Docker and K8S
Deploying a Django Application with Docker and K8S
53
This screenshot shows the process of building a Docker image from a Dockerfile for a Django application:
The docker build command is run to build the image using a file named Dockerfile_Django.
Steps Shown:
Docker pulls the base Python image,
Copies the necessary files,
Installs dependencies using pip,
And creates the final image.
Deploying a Django Application with Docker and K8S
Deploying a Django Application with Docker and K8S
Deploying a Django Application with Docker and K8S
Deploying a Django Application with Docker and K8S
55
A namespace.yaml file was created
to define a namespace in
Kubernetes.
This namespace is named devops
and is used to organize and isolate
resources within the Kubernetes
cluster.
namespace.yaml
56
A db-deployment.yaml file was created to configure a
PostgreSQL deployment within Kubernetes :
Specification Details:
Replicas: Configured with a single replica.
Selector: Applies a selector with the label app:
postgres to match the deployment.
Pod Template: The template specifies a
PostgreSQL container.
Container Configuration:
Image: Uses the postgres:latest Docker image for
the container.
Port: Exposes port 5432 for database connections.
Environment Variables:
POSTGRES_USER: Set to "postgres".
POSTGRES_PASSWORD: Set to "postgres".
POSTGRES_DB: Set to "django_db".
Deploying a Django Application with Docker and K8S
Deploying a Django Application with Docker and K8S
db-deployement.yaml
57
A db-service.yaml file was created to configure a
Kubernetes service for a PostgreSQL database
Port Configuration:
Exposes Port: Exposes port 5432.
Redirects Port: Redirects port 5432 to the
target container port.
Selector: Matches pods labeled with app: postgres.
Deploying a Django Application with Docker and K8S
Deploying a Django Application with Docker and K8S
db-service.yaml
A File “django-deployment.yaml” was created to deploy a
Django application on Kubernetes :
Container Configuration:
Image: Uses ‘rami2708/devops-web’ image.
Port: Exposes port ‘8000’.
Environment Variables:
Configurations for PostgreSQL database
(username, password, database name, and host).
Deploying a Django Application with Docker and K8S
Deploying a Django Application with Docker and K8S
django-deployment.yaml
58
59
A django-service.yaml file was created to configure
a LoadBalancer service for the Django application :
Port Configuration:
Exposes Port: Exposes port 8000.
Redirects Port: Redirects port 8000 to the
target container port.
Selector: Matches pods labeled with app:
django.
Deploying a Django Application with Docker and K8S
Deploying a Django Application with Docker and K8S
django-service.yaml
Deploying a Django Application with Docker and K8S
Deploying a Django Application with Docker and K8S
60
Two pods are running:
pod/django-74cbf6cbbd-zg7xh
pod/postgres-7c77f684d7c-pm9j.
Two services are created:
service/db with a
ClusterIP
service/django with a
LoadBalancer.
Two deployments are running:
deployment.apps/django
deployment.apps/postgres
Two ReplicaSets are running:
replicaset.apps/django-74cbf6cbbd
replicaset.apps/postgres-7c77f684d7c.
Benefits of using
63
In
&
Benefits of using Docker
Benefits of using Docker
64
Benefits of using Kubernetes
Benefits of using Kubernetes
65
CONCLUSION
66
Conclusion
Conclusion
67
Using Docker and Kubernetes for Django app
deployment ensures scalability, consistency, and
efficiency. These tools modernize workflows,
making applications reliable and adaptable to
change.
Refrences
Refrences
68
https://devopscube.com/build-docker-image/
https://www.linkedin.com/posts/hasibulislamnirob_what-is-devops-pdf-activity-7132398073485410304-jDb1?
utm_source=share&utm_medium=member_desktop
https://cloud.google.com/blog/products/containers-kubernetes/kubernetes-best-practices-setting-
up-health-checks-with-readiness-and-liveness-probes?hl=entext
www.clickittech.com
https://www.clickittech.com/devops/kubernetes-architecture-diagram/
69
THANK YOU FOR YOUR
ATTENTION
Introduction to Kubernetes
Introduction to Kubernetes
70
User Interface (UI) or CLI (kubectl) is used to send commands to the API Server.
The Scheduler allocates pods to specific nodes.
The Controller Manager maintains the cluster’s state.
Pods are created on worker nodes, and Kubelet ensures they run smoothly.
Kube-proxy manages network traffic between pods and services.
B - Communication Flow :

Devops with Docker and K8S + django example

  • 1.
    DEVOPS WITH DOCKER AND KUBERNETES SOApresentation 1 2024-2025
  • 2.
    Deploying a DjangoApplication Introduction to DevOps 01 Understanding Docker 02 Introduction to Kubernetes 03 Benefits of Docker and Kubernetes in DevOps Conclusion 04 05 06 Table of Table of contents contents 2
  • 3.
  • 4.
    Introduction to DevOps Introductionto DevOps 4 Why DevOps is revolutionizing software development ?
  • 5.
    Introduction to DevOps Introductionto DevOps 5 Why DevOps is revolutionizing software development ?
  • 6.
    Introduction to DevOps Introductionto DevOps 6 Why DevOps is revolutionizing software development ?
  • 7.
    Introduction to DevOps Introductionto DevOps 7 Why DevOps is revolutionizing software development ?
  • 8.
    8 Introduction to DevOps Introductionto DevOps Who Introduced DevOps and When? Patrick Debois DevOpsDays conference the "Father of DevOps” 2009
  • 9.
    Introduction to DevOps Introductionto DevOps 9 Why DevOps is revolutionizing software development ? Devops is not a technology, tool or framework . DevOps is a cultural movement, mindset, philosophy to coordiante produce better, more reliable products. by automating infrastructure, workflow, and continuously measuring application performance for which they use a lot of tools.
  • 10.
    Introduction to DevOps Introductionto DevOps 10 Why DevOps is revolutionizing software development ? The DEVOPS lifecycle : You can visualize a Devops process as an infinite loop, comprising the illustrated steps through feedback --plan , which resets the loop.
  • 11.
  • 12.
    Understanding Docker Understanding Docker 12 Whatis Docker ? 1. Docker is a powerful platform that simplifies the process of building, shipping, and running applications.
  • 13.
  • 14.
  • 15.
  • 16.
    Understanding Docker Understanding Docker 16 1.4- The Process of Creating Containers
  • 17.
    Definition: Scripts usedto create Docker images. Purpose: Automates and ensures repeatable, consistent image creation. Structure: A text file containing a series of commands that Docker uses to assemble an image 2. DockerFile : Understanding Docker Understanding Docker 17
  • 18.
    3. Docker image: These are the blueprints of applications. A Docker image is a lightweight, standalone, and executable package that includes everything needed to run a piece of software . Images are immutable, meaning once they’re created, they don’t change. Understanding Docker Understanding Docker 18
  • 19.
  • 20.
    4. Docker container: A Docker container is like that lunchbox self-sufficient and portable. Imagine you have a lunchbox that contains everything you need for a meal. Understanding Docker Understanding Docker 20
  • 21.
    Toss it, andit leaves no mess. Stop the container, and it leaves no mess. Multiple containers on a host Multiple lunchboxes in your backpack. You can have When you're done Understanding Docker Understanding Docker 21
  • 22.
    Docker containers arerunnable instances of Docker images. They encapsulate the application and its dependencies, providing an isolated environment for execution. Containers can be created, started, stopped, moved, and deleted using Docker commands. 4. Docker container : So, what’s a docker container ? Understanding Docker Understanding Docker 22
  • 23.
    5. Docker compose: Understanding Docker Understanding Docker 23
  • 24.
    Docker Compose isa tool for defining and running multi-container Docker applications. It uses a YAML file (docker-compose.yml) to specify services, networks, volumes, and other configurations required for the application. 5. Docker compose : Understanding Docker Understanding Docker 24
  • 25.
    25 6. Docker Volumes: UnderstandingDocker Understanding Docker
  • 26.
    26 7. Docker Networking: UnderstandingDocker Understanding Docker
  • 27.
    Docker Hub isa cloud-based repository service provided by Docker for storing and sharing Docker images. It serves as a central hub for the Docker community, offering access to thousands of public images and enabling collaboration among developers and operations teams. Understanding Docker Understanding Docker 8. DOCKER HUB : 27
  • 28.
    Before Docker Hub Lackof Standardization No Centralized Storage Collaboration Barriers Limited Automation Quality Control Issues 8. DOCKER HUB : Understanding Docker Understanding Docker 28
  • 29.
    Searching for Images: Usethe docker search command to search for images on Docker Hub: Pulling Images: Pull Docker images from Docker Hub using the docker pull command: Pushing Images: Push local Docker images to Docker Hub using the docker push command : Understanding Docker Understanding Docker 8. DOCKER HUB : 29
  • 30.
  • 31.
    Introduction to Kubernetes Introductionto Kubernetes 31 What is Kubernetes ? 1. Kubernetes, or K8s, is an open- source platform designed to automate the deployment, management, and scaling of containerized applications.
  • 32.
    32 Created by Google,now maintained by the Cloud Native Computing Foundation (CNCF). Kubernetes is tailored for modern, container-based environments, such as those orchestrated with Docker 2014 2015 Introduction to Kubernetes Introduction to Kubernetes
  • 33.
    Key Purposes ofKubernetes
  • 34.
    34 2.Kubernetes Architecture Introduction toKubernetes Introduction to Kubernetes
  • 35.
    Introduction to Kubernetes Introductionto Kubernetes 35 What is a Cluster ? A group of computers (physical or virtual) that work together as a system. In Kubernetes, the cluster consists of: A Control Plane (the brain of Kubernetes). Worker Nodes (the machines where applications run).
  • 36.
    The Control Planeis responsible for managing the cluster, maintaining its desired state, and scheduling workloads. It includes: API Server: Acts as the entry point for all administrative tasks. It handles communication between the user (via CLI or UI) and the cluster. A - Kubernetes Master (Control Plane) : Introduction to Kubernetes Introduction to Kubernetes 36
  • 37.
    Introduction to Kubernetes Introductionto Kubernetes Scheduler: Decides which worker node will run a given pod based on resource availability. Controller Manager: Ensures the desired state of the cluster by managing controllers, like replicating pods or handling node failures. etcd: A key-value store that holds the cluster's configuration and state. It's critical for cluster consistency. 37 A - Kubernetes Master (Control Plane) :
  • 38.
    These are themachines where your applications actually run. Each worker node has: Pods: A pod is the smallest unit in Kubernetes. It runs one or more containers. Example: If you're running a web server, it will be inside a pod. B - Worker Nodes : Introduction to Kubernetes Introduction to Kubernetes 38
  • 39.
    Kubelet: The guardian ofthe node. It ensures that the pod is healthy and running properly. Kube-proxy: Manages communication between different parts of the cluster and the outside world. Container Runtime (e.g., Docker): This is the tool that runs the actual containers. Introduction to Kubernetes Introduction to Kubernetes 39 B - Worker Nodes :
  • 40.
    Introduction to Kubernetes Introductionto Kubernetes 3. Kubernetes YAML File Overview A Kubernetes YAML file is used to define resources and their configurations in a Kubernetes cluster. It is written in YAML syntax and is structured with key-value pairs. 40
  • 41.
    41 A - KeySections in a Kubernetes YAML File: apiVersion Specifies the API version of the Kubernetes resource. Example: apps/v1, v1. Introduction to Kubernetes Introduction to Kubernetes metadata Contains metadata about the resource. spec The main configuration of the resource, varying by resource type.
  • 42.
    Introduction to Kubernetes Introductionto Kubernetes B - Communication Flow : 42
  • 43.
    C - Example:Deploying a Django Web Application : Introduction to Kubernetes Introduction to Kubernetes The API Server processes your deployment request via kubectl. The Scheduler assigns your Django app to a worker node. The Kubelet ensures the app container runs properly in a pod. 43
  • 44.
    Liveness and readinessprobes are checks that Kubernetes performs on your pods to determine their health. Liveness probes check if your application is still running, while readiness probes check if your application is ready to receive traffic. 4. Kubernetes Probes ? Introduction to Kubernetes Introduction to Kubernetes So you’ve built an amazing app and deployed it to Kubernetes . That’s where liveness and readiness probes come in. But how do you make sure your app stays up and running as intended? 44
  • 45.
  • 46.
    Liveness probes checkif your application is up and running. They ensure that if a pod goes down for any reason, Kubernetes can restart it and get your app back online. There are three types of liveness probes: 1. HTTP probe: checks for a successful HTTP response (status code 200–399). This is good for web apps and REST APIs. 2. TCP probe: Checks if a TCP port is open. Use this for non- HTTP apps. 3. Exec probe: Executes a command inside the container. Checks the exit code to determine health. Introduction to Kubernetes Introduction to Kubernetes A- Liveness Probes 46
  • 47.
    Introduction to Kubernetes Introductionto Kubernetes Readiness probes check if your application pods are ready to accept traffic. If a readiness probe fails, Kubernetes will remove the pod from service load balancers and endpoints. This ensures that clients don’t access pods that are not ready to handle requests. Some examples of readiness probes include: Checking if a web server returns a 200 OK response on a certain endpoint Seeing if a database connection can be established B- Readiness Probes 47
  • 48.
  • 49.
    A Dockerfile wascreated to containerize the Django application : Uses the Python 3.10 image. Installs the dependencies specified in requirements.txt. Copies the project into the container and exposes port 8000. Configures the Django server startup to run the application. Deploying a Django Application with Docker and K8S Deploying a Django Application with Docker and K8S 49 Dockerfile_Django
  • 50.
    Deploying a DjangoApplication with Docker and K8S Deploying a Django Application with Docker and K8S 50 The docker-compose.yml file was created to orchestrate the Django application with PostgreSQL : Django Service : Based on the created Dockerfile, it runs the web application, uses the volume named app for storing necessary data, and is integrated into the Docker network. PostgreSQL Service : Uses the official PostgreSQL image, with environment variables defining the database parameters (user, password, name). It uses the volume named db_data to ensure data persistence. docker-compose.yml
  • 51.
    51 The command “docker-composeup --build” uses the Docker Compose tool to build the Docker image specified in the Docker Compose file, then start the containers defined in it. The “--build” flag ensures the latest changes are incorporated before starting the containers. Deploying a Django Application with Docker and K8S Deploying a Django Application with Docker and K8S
  • 53.
    53 This screenshot showsthe process of building a Docker image from a Dockerfile for a Django application: The docker build command is run to build the image using a file named Dockerfile_Django. Steps Shown: Docker pulls the base Python image, Copies the necessary files, Installs dependencies using pip, And creates the final image. Deploying a Django Application with Docker and K8S Deploying a Django Application with Docker and K8S
  • 55.
    Deploying a DjangoApplication with Docker and K8S Deploying a Django Application with Docker and K8S 55 A namespace.yaml file was created to define a namespace in Kubernetes. This namespace is named devops and is used to organize and isolate resources within the Kubernetes cluster. namespace.yaml
  • 56.
    56 A db-deployment.yaml filewas created to configure a PostgreSQL deployment within Kubernetes : Specification Details: Replicas: Configured with a single replica. Selector: Applies a selector with the label app: postgres to match the deployment. Pod Template: The template specifies a PostgreSQL container. Container Configuration: Image: Uses the postgres:latest Docker image for the container. Port: Exposes port 5432 for database connections. Environment Variables: POSTGRES_USER: Set to "postgres". POSTGRES_PASSWORD: Set to "postgres". POSTGRES_DB: Set to "django_db". Deploying a Django Application with Docker and K8S Deploying a Django Application with Docker and K8S db-deployement.yaml
  • 57.
    57 A db-service.yaml filewas created to configure a Kubernetes service for a PostgreSQL database Port Configuration: Exposes Port: Exposes port 5432. Redirects Port: Redirects port 5432 to the target container port. Selector: Matches pods labeled with app: postgres. Deploying a Django Application with Docker and K8S Deploying a Django Application with Docker and K8S db-service.yaml
  • 58.
    A File “django-deployment.yaml”was created to deploy a Django application on Kubernetes : Container Configuration: Image: Uses ‘rami2708/devops-web’ image. Port: Exposes port ‘8000’. Environment Variables: Configurations for PostgreSQL database (username, password, database name, and host). Deploying a Django Application with Docker and K8S Deploying a Django Application with Docker and K8S django-deployment.yaml 58
  • 59.
    59 A django-service.yaml filewas created to configure a LoadBalancer service for the Django application : Port Configuration: Exposes Port: Exposes port 8000. Redirects Port: Redirects port 8000 to the target container port. Selector: Matches pods labeled with app: django. Deploying a Django Application with Docker and K8S Deploying a Django Application with Docker and K8S django-service.yaml
  • 60.
    Deploying a DjangoApplication with Docker and K8S Deploying a Django Application with Docker and K8S 60 Two pods are running: pod/django-74cbf6cbbd-zg7xh pod/postgres-7c77f684d7c-pm9j. Two services are created: service/db with a ClusterIP service/django with a LoadBalancer. Two deployments are running: deployment.apps/django deployment.apps/postgres Two ReplicaSets are running: replicaset.apps/django-74cbf6cbbd replicaset.apps/postgres-7c77f684d7c.
  • 63.
  • 64.
    Benefits of usingDocker Benefits of using Docker 64
  • 65.
    Benefits of usingKubernetes Benefits of using Kubernetes 65
  • 66.
  • 67.
    Conclusion Conclusion 67 Using Docker andKubernetes for Django app deployment ensures scalability, consistency, and efficiency. These tools modernize workflows, making applications reliable and adaptable to change.
  • 68.
  • 69.
    69 THANK YOU FORYOUR ATTENTION
  • 70.
    Introduction to Kubernetes Introductionto Kubernetes 70 User Interface (UI) or CLI (kubectl) is used to send commands to the API Server. The Scheduler allocates pods to specific nodes. The Controller Manager maintains the cluster’s state. Pods are created on worker nodes, and Kubelet ensures they run smoothly. Kube-proxy manages network traffic between pods and services. B - Communication Flow :