Managing Virtual Machines with Docker Swarm in a High Availability Cluster using the Concept of Kubernetes (HA Proxy)

Managing Virtual Machines with Docker Swarm in a High Availability Cluster using the Concept of Kubernetes (HA Proxy)

In recent years, containerization has become the go-to method for packaging and deploying applications. However, there are still many cases where virtual machines (VMs) are preferred over containers, such as running legacy applications or hosting operating systems. Docker Swarm, a container orchestration platform, can also be used to manage VMs in addition to containers. In this blog post, we’ll explore how to manage VMs with Docker Swarm in a high-availability cluster using Kubernetes.

configure HA cluster, configure Linux ha cluster, configure HA cluster on Docker, Docker image configuration on ubuntu, setup high availability cluster and based on that we balance the load to slave.

Cluster :

A Kubernetes cluster is a set of nodes that run containerized applications. Containerizing applications package an app with its dependencies and some necessary services. They are more lightweight and flexible than virtual machines.

Deploying Virtual Machines with Docker Swarm:

we can use Docker Swarm to deploy virtual machines. Docker Swarm allows us to treat VMs as first-class citizens, just like containers. In this section, we’ll cover how to deploy VMs using Docker Swarm and how to scale them up or down as needed.

HA Cluster Architecture Lab Setup:

Web Servers — 2 Nos
HaProxy LB — 2 Nos

Note: All nodes are installed with Ubuntu (Host Server)

Approach Details:-

Steps Involved to Create Linux Cluster:

On All Web Servers:

  1. Install Apache2

# sudo apt update && sudo apt install -y apache2

2. Configure Apache2 Web Servers

I just modify the exsiting default index.html with sample content as below.

sudo echo “Test Data” > /var/www/html/index.html

3. Start and Enable Apache2 Service.

sudo systemctl enable apache2
sudo systemctl start apache2

On All HAProxy Servers:

4. Install HAProxy

# sudo apt update && sudo apt install -y haproxy

5. Set up HAProxy with Frontend and Backend Configuration.

frontend my web
bind *:80
option tcplog
mode tcp
default_backend web-servers
backend web-servers
mode tcp
balance round-robin
option tcp-check
server web1 192.168.2.13:80 check fall 3 rise 2
server web2 192.168.2.14:80 check fall 3 rise 2

6. Start and Enable HAProxy Service.

# systemctl restart haproxy
# systemctl enable haproxy

Implementation:

Docker Running image

Docker Swarm

Local web use for testing

For more info here Demo of the Project:-