In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the relevant knowledge of "how to use Traefik". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Traefik is a http reverse proxy and load balancing software that makes it easier for you to expose microservices. Traefik supports K8S, docker swarm, mesos, consul, etcd, zookeeper and other infrastructure components. I think it is more suitable for containerized micro-services. The configuration of traefik will update itself automatically and dynamically.
Scene
This article mainly simulates the scene of traefik+docker swarm mode, and traefik automatically discovers the service under swarm mode.
Environment ubuntu16.04-1swarm managertraefikubuntu16.04-2swarm worksubuntu16.04-3swarm works
Ps: or the swarm cluster where the previous article did the experiment.
Download traefikwget 'https://github-production-release-asset-2e65be.s3.amazonaws.com/42408804/b7288f00-a48e-11e8-817e-298aa1a8bae9?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20180903%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20180903T065922Z&X-Amz-Expires=300&X-Amz-Signature=4d4a6a61122a5e0ac8aaae5da30883d555db307c2a9dbe1e300fb1dc2decb0a2&X-Amz-SignedHeaders=host&actor_id=12913767&response-content-disposition=attachment%3B%20filename%3Dtraefik_linux-amd64&response-content-type=application%2Foctet-stream'
Ps: rename the downloaded traefik_linux-amd64 binary file to traefik and upload it to the image creation server.
Mirror image production
Dockfile
FROM scratchCOPY. / traefik / EXPOSE 80ENTRYPOINT ["/ traefik"] compiles imagedocker build-t traefik. Upload image
Docker tag traefik 172.31.68.241/library/traefikdocker push 172.31.68.241/library/traefik deploys traefik to create network docker network create-- driver=overlay traefik-net
Ps:traefik and app must be in the same network, otherwise traefik will not recognize app
Deploy traefikdocker service create\-- name traefik\-- constraint=node.role==manager\-- publish 8090 docker.watch 80-- publish 8080\-- mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock\-- network traefik-net\ 172.31.68.241/library/traefik\-- docker\-- docker.swarmMode\-- docker.domain=example.org\-- docker.watch\-- logLevel=DEBUG\-- web
View web http://172.31.68.241:8080/dashboard/
Visit appdocker service create-- replicas 2-- network traefik-net-- label traefik.port=80-- label traefik.frontend.rule=Host:test.example.org-- name hello 172.31.68.241/library/friendlyhello during rotation training
Verify curl-H Host:test.example.org http://172.31.68.241:8090
Session sticky access appdocker service create-replicas 2-network traefik-net-label traefik.port=80-label traefik.frontend.rule=Host:test.example.org-label traefik.backend.loadbalancer.sticky=true-name hello 172.31.68.241/library/friendlyhello
Verify curl-c cookies.txt-H Host:test.example.org http://172.31.68.241:8090curl-b cookies.txt-H Host:test.example.org http://172.31.68.241:8090
View cookies
That's all for the content of "how to use Traefik". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.