In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces you how to use Label to control the location of Service, the content is very detailed, interested friends can refer to, hope to be helpful to you.
Whether using global mode or replicated mode, which node the replica runs on is determined by Swarm. As users, is it possible for us to finely control the running location of Service?
The answer is: yes, use label.
The logic is divided into two steps:
Define a label for each node.
Set service to run on the node of the specified label.
Label can flexibly describe the attributes of node in the form of key=value, which you can specify arbitrarily, such as adding label env=test to swarm-worker1 as a test environment:
Docker node update-label-add env=test swarm-worker1
Correspondingly, use swarm-worker2 as the production environment and add label env=prod:
Docker node update-label-add env=prod swarm-worker2
Now deploy service to the test environment:
Docker service create\-- constraint node.labels.env==test\-- replicas 3\-- name my_web\-- publish 8080 replicas 80\ httpd
-- constraint node.labels.env==test restricts the deployment of service to the node of label=test, namely swarm-worker1. From the deployment results, all three copies are running on swarm-worker1.
You can view the settings of constraint through docker service inspect:
Update service and migrate it to the production environment:
Docker service update-constraint-rm node.labels.env==test my_web docker service update-constraint-add node.labels.env==prod my_web
Delete and add a new constraint, set up node.labels.env==prod, and eventually all copies are migrated to swarm-worker2.
Label can also be used in conjunction with the global schema, such as collecting only the logs of containers in a production environment.
Docker service create\-mode global\-constraint node.labels.env==prod\-name logspout\-mount type=bind,source=/var/run/docker.sock,destination=/var/run/docker.sock\ gliderlabs/logspout
Logspout runs only on the swarm-worker2 node.
On how to use Label to control the location of Service to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
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.