
This repository contains the source code to deploy the application to docker-swarm
In this lecture, we discussed what is docker swarm, why to use it, and the architecture of the docker swarm.
Docker swarm is a container orchestration tool, meaning that it allows you to manage multiple containers deployed across multiple host machines. A swarm is a cluster of one or more physical or virtual machine running Docker.
One of the key benefits associated with the operation of a docker swarm is the high level of availability offered for applications.
Working of docker swarm
In a docker swarm, there are typically several worker nodes and at least one manager node that is responsible for handling the worker nodes' resources efficiently and ensuring that the cluster operates efficiently.
The manager node knows the status of the worker nodes in a cluster, and the worker nodes accept tasks sent from the manager node. Every worker node has an agent that reports on the state of the node's tasks to the manager. This way, the manager node can maintain the desired state of the cluster.
Features of docker swarm
Decentralized access: Swarm makes it very easy for teams to access and manage the environment
High security: Any communication between the manager and client nodes within the Swarm is highly secure
Autoload balancing: There is autoload balancing within your environment, and you can script that into how you write out and structure the Swarm environment
High scalability: Load balancing converts the Swarm environment into a highly scalable infrastructure
Roll-back a task: Swarm allows you to roll back environments to previous safe environments
In this lecture, we discussed how we can create the manager and worker in our local system, we used a tool named Docker-Machine. Docker Machine is a tool for provisioning and managing your Dockerized hosts (hosts with Docker Engine on them).
We created 3 nodes (1 manager and 2 worker nodes) for our swarm cluster.
Before creating any node, please make sure that VirtualBox/HyperV is installed.
Linux and OSX user need to install VirtualBox and windows user needs to enable HyperV for virtualization
OSX users also need to enable permission for VirtualBox from the System Preference -> Security and Privacy.
MacOS user can install VirtualBox using: brew install --cask virtualbox
Linux users can install VirtualBox using: sudo apt install virtualbox.
Windows user can download VirtualBox from here: https://www.virtualbox.org/wiki/Downloads
if you find an error something like this docker-machine: Error with pre-create check: “exit status 126”
refer ->https://stackoverflow.com/questions/56091308/docker-machine-error-with-pre-create-check-in-windows
Create Docker machines
docker-machine create --driver hyperv manager1 or docker-machine create --driver virtualbox manager1
use command docker-machine ls to see all the nodes.
Commands used in the lecture
docker-machine create --driver virtualbox <nodeName>
docker-machine ls
docker-machine IP <nodeName>
FAQs & Helpful Tips:
A swarm is a group of machines that are running Docker and joined into a cluster
A cluster is managed by a swarm manager The machines in a swarm can be physical or virtual.
After joining a swarm, they are referred to as nodes Swarm managers are the only machines in a swarm that can execute your commands, or authorize other machines to join the swarm as workers
Workers are just there to provide capacity and do not have the authority to tell any other machine what it can and cannot do you can have a node join as a worker or as a manager.
At any point in time, there is only one LEADER and the other manager nodes will be as a backup in case the current LEADER opts out
In this course, you are going to learn how you can set up Hyperledger Fabric Network on multiple hosts on multiple clouds. We are going to use the following configuration for deploying fabric applications.
3 Virtual Machine (any cloud of your choice.
3 Orgs - 3 Peer Orgs(1 peer each) and 1 Orderer Orgs( 5 Ordering Nodes).
3 Certificates Authority for each org. (For certificate creation).
NodeJS API Server for Chaincode invocation.
Various Ways for Multi-host Deployment
As Hyperledger Fabric components are deployed as containers, everything works fine when running in the localhost. When they are running in different hosts, we need to find a way to make these containers talk to one another.
Static IP By specifying the host IP where a container is running, containers can communicate with each other. Those host IPs are specified using extra_hosts in docker-compose files, and after a container is running, these entries are seen in, etc/hosts. The downside is that things are statically configured, and there are challenges when one needs to add or change the configuration.
Docker Swarm Docker Swarm is a container orchestration tool natively in the Docker environment. In a nutshell, It provides an overlay network for containers across multiple hosts. Those containers on this overlay network can communicate to one another as if they were on a large host. Obviously, the good side is that the original configuration can be used with minimal modification, and no static information such as IP is coded in the configuration.
Kubernetes (k8s) K8s by far is the most popular container orchestration tool. The mechanism is similar to Docker Swarm. The implementation of this approach is much more challenging than the previous two mechanisms.
What we cover in this course
Purely Hands-on experience of
VM Creation & Network Setup (3 VM)
Create Docker Swarm Network
Certificate and Private keys creation using Certificates Authority (3 Org - 3 CA, 5 Orderer - 1 CA)
Channel Artifacts Creation
Setting up CLI tools for each organization.
Channel Creation & Joining on Each VM.
Chaincode Install & Approve for Each Orgs
Committing & Invoking Chaincode
API Server(Container) creation.
Invoking Transaction from API Server
Setting up Hyperledger Explorer