In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
The following brings you how Docker Swarm should centralize the deployment of Traefik load balancer, hoping to give you some help in practical application. Load balancing involves more things, there are not many theories, and there are many books on the Internet. Today, we will use the accumulated experience in the industry to do an answer.
First, create a single-node Docker Swarm cluster
Docker swarm init
Create a network in the Swarm cluster
Docker network create-driver=overlay traefik-attachable
Deploy the traefik load balancer service in the Swarm cluster
Docker service create\
-- name traefik\
-- constraint=node.role==manager\
-- publish 80:80-- publish 8080RV 8080\
-- mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock\
-- network traefik\
Traefik\
-- docker\
-- docker.swarmmode\
-- docker.domain=traefik\
-- docker.watch\
-- web
4. Deploy two container services (httpd and nginx) in the Swarm cluster
# 2.1 httpd.abc.com
Docker service create\
-- name httpd\
-- network traefik\
-label "traefik.backend=httpd"\
-label "traefik.enable=true"\
-label "traefik.protocol=http"\
-label "traefik.port=80"\
-label "traefik.frontend.rule=Host:httpd.abc.com"\
Httpd
# 2.2 nginx.abc.com
Docker service create\
-- name nginx\
-- network traefik\
-label "traefik.backend=nginx"\
-label "traefik.enable=true"\
-label "traefik.protocol=http"\
-label "traefik.port=80"\
-label "traefik.frontend.rule=Host:nginx.abc.com"\
Nginx
5. Visit 2 websites and view Traefik UI through domain name in browser
# modify the hosts file C:\ Windows\ System32\ drivers\ etc\ hosts of the Win7 client computer
# add 2 host records:
Httpd.abc.com 192.168.3.168
Nginx.abc.com 192.168.3.168
Http://192.168.3.168:8080
Http://httpd.abc.com
Http://nginx.abc.com
6. Check Traefik UI after the service capacity in the Swarm cluster is expanded.
Docker service scale httpd=2
Docker service scale nginx=3
Http://192.168.3.168:8080
Attached picture:
After reading the above about how Docker Swarm should centrally deploy Traefik load balancers, if there is anything else you need to know, you can find out what you are interested in in the industry information or find our professional and technical engineers for answers. Technical engineers have more than ten years of experience in the industry. Official website link www.yisu.com
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.