Solution for Docker Swarm external verification load balancing not taking effect

Solution for Docker Swarm external verification load balancing not taking effect

Problem Description

I created three virtual machines with centos7 installed locally and initialized the swarm cluster, namely one manager node and two worker nodes; the IP addresses of the three machines are 192.168.124.8 - (manager節點) , 192.168.124.9 - (worker節點) , 192.168.124.10 - (worker節點)

[root@localhost ~]# docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
j0f4up8v7epacp3vceby4exsz localhost.localdomain Ready Active 19.03.13
qeeqc10gl9e56w61pajjqle08 localhost.localdomain Ready Active 19.03.13
r5sg5m9dkwcu76t56hg0vu29t * localhost.localdomain Ready Active Leader 19.03.14

Then I started a service on the swarm cluster with the following command

docker service create --name test-vote --replicas 2 --constraint node.role==worker --publish 8080:80 registry.cn-hangzhou.aliyuncs.com/anoy/vote

Directly curling the worker node ip:port can get a response, but the returned containerId remains unchanged, and if you directly access the manager node, you will not get a response, it seems that the load balancing is not effective!

solve

After some searching, I found the answer on stack overflow: https://stackoverflow.com/questions/48360577/docker-swarm-mode-routing-mesh-not-working

It turned out to be a firewall issue. According to the documentation, in order for swarm mode routing mesh to take effect, tcp/udp port 7946 and udp port 4789 must be opened before initializing the swarm cluster. https://docs.docker.com/engine/swarm/ingress/

So if it is centos, you can use the following script to open the port. Each host in the swarm cluster needs to be opened. For convenience, both TCP and UDP ports are opened. After opening the port, you need to restart the machine.

firewall-cmd --permanent --zone=public --add-port=4789/tcp && \
firewall-cmd --permanent --zone=public --add-port=7946/tcp && \
firewall-cmd --permanent --zone=public --add-port=4789/udp && \
firewall-cmd --permanent --zone=public --add-port=7946/udp && \
firewall-cmd --reload && \
# Reboot sudo reboot

This is the end of this article about docker swarm external verification load balancing not taking effect. For more relevant docker swarm load balancing content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Detailed explanation of Docker Swarm service discovery and load balancing principles
  • How does docker swarm run a specified container on a specified node?
  • Detailed explanation of docker swarm cluster failures and exceptions
  • How to use Docker Swarm to build a cluster
  • Detailed explanation of using Docker 1.12 to build a multi-host Docker swarm cluster

<<:  Summary of the most commonly used knowledge points about ES6 new features

>>:  JS, CSS style reference writing

Recommend

Summary of Nginx load balancing methods

To understand load balancing, you must first unde...

Detailed tutorial on installing PHP and Nginx on Centos7

As the application of centos on the server side b...

Install Python 3.6 on Linux and avoid pitfalls

Installation of Python 3 1. Install dependent env...

Implementation of Node connection to MySQL query transaction processing

Table of contents Enter the topic mysql add, dele...

Detailed explanation of the usage of grep command in Linux

1. Official Introduction grep is a commonly used ...

Detailed explanation of COLLATION examples in MySQL that you may have overlooked

Preface The string types of MySQL database are CH...

Detailed explanation of the available environment variables in Docker Compose

Several parts of Compose deal with environment va...

MySQL pessimistic locking and optimistic locking implementation

Table of contents Preface Actual Combat 1. No loc...

How to create a project with WeChat Mini Program using typescript

Create a project Create a project in WeChat Devel...

Ubuntu 20.04 Chinese input method installation steps

This article installs Google Input Method. In fac...

Graphic tutorial on installing Mac system in virtual machine under win10

1. Download the virtual machine version 15.5.1 I ...

Pure CSS to achieve click to expand and read the full text function

Note When developing an article display list inte...

Calling Baidu Map to obtain longitude and latitude in Vue

In the project, it is necessary to obtain the lat...

Repair solution for inconsistent MySQL GTID master and slave

Table of contents Solution 1: Rebuild Replicas Pr...

Things You Don’t Know About the CSS ::before and ::after Pseudo-Elements

CSS has two pseudo-classes that are not commonly ...