您好,登錄后才能下訂單哦!
本篇內(nèi)容介紹了“Traefik怎么使用”的有關(guān)知識(shí),在實(shí)際案例的操作過(guò)程中,不少人都會(huì)遇到這樣的困境,接下來(lái)就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!
traefik是一個(gè)使你把微服務(wù)暴露出來(lái)變的更容易的http反向代理和負(fù)載均衡軟件。traefik支持K8S、docker swarm、mesos、consul、etcd、zookeeper等基礎(chǔ)設(shè)施組件,個(gè)人認(rèn)為更適合容器化的微服務(wù),traefik的配置會(huì)自動(dòng)的、動(dòng)態(tài)的配置更新自己。
本篇主要模擬的是traefik+docker swarm mode的場(chǎng)景,由traefik自動(dòng)發(fā)現(xiàn)swarm mode下的service
ubuntu16.04-1 | swarm manager | traefik |
ubuntu16.04-2 | swarm works | |
ubuntu16.04-3 | swarm works |
ps:還是之前文章做實(shí)驗(yàn)的swarm集群
wget '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:把下載完的traefik_linux-amd64二進(jìn)制文件重命名成traefik,上傳到鏡像制作服務(wù)器。
Dockfile
FROM scratch COPY ./traefik / EXPOSE 80 ENTRYPOINT ["/traefik"]
docker build -t traefik .
docker tag traefik 172.31.68.241/library/traefik docker push 172.31.68.241/library/traefik
docker network create --driver=overlay traefik-net
ps:traefik和app要在同一個(gè)網(wǎng)絡(luò)內(nèi),否則traefik識(shí)別不到app
docker service create \ --name traefik \ --constraint=node.role==manager \ --publish 8090:80 --publish 8080: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
http://172.31.68.241:8080/dashboard/
docker 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
curl -H Host:test.example.org http://172.31.68.241:8090
docker 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
curl -c cookies.txt -H Host:test.example.org http://172.31.68.241:8090 curl -b cookies.txt -H Host:test.example.org http://172.31.68.241:8090
“Traefik怎么使用”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注億速云網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。