#90daysofdevops-Day-83: Project-4

#90daysofdevops-Day-83: Project-4

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-requisites

  1. Spin-up three servers in the AWS management console.

    Two servers are worker nodes and one server is manager mode.

  2. Install docker on all three servers.

Project steps

  1. 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-19irxu8l190i6iofpj4qnhj600y8h2pqyqybp3pdgga5xp8y70-a1be6hvg29pkj28oax3vox6gv 172.31.92.104:2377"

  2. Open port 2377 in the security group for all the servers.

  3. Now join both worker nodes o the manager node.

  4. We can check the docker swarm status to check the connected worker nodes o manager nodes.

    "docker node ls"

  5. Let's take an image from my repository to deploy the application on the docker swarm servers.

  6. Create a service in the docker manager node server to install the application through the docker image from the docker hub.

    sudo docker service create --name flask-calculator --replicas 3 --publish 3000:3000 bandank/flask-calculator:latest

  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.

  8. Open the port 3000 which is required to run the application.

  9. Let's check the web-app in both the swarm node servers.