DevOps (Day-83): Project-4 Web Application Deployment with Docker Swarm
Day 83: #90DaysOfDevOpsChallenge
Dear Learners, In my previous lecture Day-82 Project-4 I have explain the how to Hosting a static website on S3 bucket. In today Article we will how Explain how to deploy a web Application using Docker Swarm container Orchestration tool.
Project Description:-
The Project aims to deploy a web application using Docker Swarm, a container orchestration tool that allows for easy management and scaling of Containerized applications. The project will utilize Docker Swarm's production-ready features such as load balancing,rolling updates and service discovery to ensure high availability and reliability of the web application. The project will involve creating a Dockerfile to package the application into a container and then deploying it onto a Swarm cluster. The Swarm cluster will be configured to provide automated failover, load balancing and horizontal scaling to the application. The goal of the Project is to demonstrate the benefits of Docker Swarm for Deploying and managing containerized applications in production environments.
Pre-requisities:-
- Spin-up 3 servers in the AWS management console. 2 Servers are worker nodes and one server is manager node.
Spin-up 3 servers in the AWS management console. 2 Servers are worker nodes and one server is manager node Diagram.
Install docker on all the 3 Servers.
You can follow my previous blog for server spin-up and installing docker.
https://lnkd.in/duH5hukR(Click on here)
Project Steps:-
- Initialise the docker swarm in the manager node.
To add a worker to this swarm, run the following command as displayed after the "docker swarm init" :
docker swarm join --token SWMTKN-1-0q2f805uddyoduy5oq5pcz6nw8d79setsv0hs211h34s5811o0-2xdt1s8ye7yqonj0jns7gdgxz 172.31.84.86:2377
To add a worker to this swarm,run the following command as displayed after the "docker swarm init Diagram.
2. Open port 2377 in the Security group for all the Servers.
Open port 2377 in the Security group for all the Servers Diagram.
- Now Join both Network nodes o the manager node.
Now Join both Network nodes o the Swarm1 node Diagram
Now Join both Network nodes o the Swarm2 node Diagram
- We can check the docker swarm status to check the connected worker nodes 0 manager nodes.
"docker node ls "
We can check the docker swarm status to check the connected worker nodes 0 manager nodes Diagram.
5. Let's take an image form my repository to deploy the application on the docker swarm servers.
The link to my DockerHub image as follows:-
https://hub.docker.com/repository/docker/bandank/flask-calculator/general
Let's take an image form my repository to deploy the application on the docker swarm servers Diagram.
6. Create a Service in the docker manager node server to install the application through the docker image form the docker hub.
sudo docker service create --name flask-calculator --replicas 3 --publish 3000:3000 bandank/flask-calculator:latest
sudo docker service create --name flask-calculator --replicas 3 --publish 3000:3000 bandank/flask-calculator:latest Diagram.
7. We can check the service that is created in the manager node server.
Also check the docker logs in the worker node servers for running docker containers.
Also check the docker logs in the worker node servers for running docker containers. Diagram.
Also check the docker logs in the worker node servers for running docker containers Diagram
Also check the docker logs in the worker node servers for running docker containers Diagram
8.Open the port 3000 which is required to run the application.
Open the port 3000 which is required to run the application Diagram.
9. Let's check the web-app in both the Swarm node-Servers.
Swarm Node 1 With IP/4 Address (44.202.29.32:3000)
Swarm Node 1 With IP/4 Address (44.202.29.32:3000) Diagram
Swarm Node 1 With IP/4 Address (44.202.29.32:3000) Diagram
Swarm Node 2 With IP/4 Address (http://18.206.64.26:3000/)
Swarm Node 2 With IP/4 Address (http://18.206.64.26:3000/) Digram.
Swarm Node 2 With IP/4 Address (http://18.206.64.26:3000/) Digram.
10. The Application is running on both servers now.
Thank you for reading!! Hope you find this helpful.
#day83challenge#90daysofdevops
Always open to suggestions..!!
~ Manoj Bhamidipati ๐