Setting up a Docker Swarm runtime environment
You can use Docker containers to run your APIs and applications being managed by API Connect. NOTE: This article refers to third-party software that IBM does not control. As such, the software may change and this information may become outdated. For the latest information, refer to https://www.docker.com/.
Before you begin
Before setting up a Docker Swarm, you need to determine its topology. A topology includes information about how many manager nodes and how many worker nodes the developer will have in the Swarm cluster. A topology also needs to determine the number of Docker registries and how these nodes are wired up with a virtual network. A cluster may be divided by multiple overlay networks. Each overlay network is isolated from other networks by default.
About this task
Docker automates the deployment of applications inside software containers. Docker containers wrap up a piece of software in a complete filesystem that contains everything it needs to run. Docker Swarm mode provides native clustering capabilities to turn a group of Docker engines into a single, virtual Docker Engine. For more information, see https://www.docker.com. You can use Docker containers to run your APIs and applications being managed by API Connect.
Docker Swarm provides high availability for worker nodes as well as manager nodes. Swarm dispatches the containers among all nodes registered to a Swarm cluster with a fair algorithm. However, the number of containers usually depends on the traffic and the system’s degree of high availability.
Docker Swarm provides high availability for manager nodes using a Raft algorithm, which needs an odd number of nodes registered as manager (3, 5, 7 and so on). This algorithm selects a leader among different manager nodes. Having three managers in the cluster provides a fault tolerance of one node, and having five nodes provides a tolerance of up to two nodes.
See https://github.com/ibm-apiconnect/docker-swarm-setup for the scripts used in this article
Setting up Docker Swarm
Procedure
Setting up the registry using self-signed certificates
About this task
The server that hosts your registry should be separate from the manager or worker node servers.
Procedure
Building a Docker image for a LoopBack project
About this task
npm
and create a deployable image to run in a Docker Swarm runtime
environment. Procedure
Building a Docker image for a Java application
About this task
Procedure
Adding Docker Swarm visualizer tool
About this task
Procedure
docker service create \
--name=viz \
--publish=8080:8080/tcp \
--constraint=node.role==manager \
--mount=type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock \manomarks/visualizer
Adding a health check for LoopBack application
About this task
You can implement this endpoint in a LoopBack app by adding a new component as detailed below. Note that this REST endpoint is available only to the cluster. No API consumer can hit this endpoint since it is not listed in the Swagger file and the API is protected by DataPower.