Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement micro-service by deploying Traefik in Rancher

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces how to deploy Traefik to achieve micro-services in Rancher. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.

What is Traefik?

Traefik is a modern HTTP reverse proxy and load balancing tool born to make it easier to deploy micro-services. It supports multiple backends (Rancher, Docker, Swarm, Kubernetes, Marathon, Mesos, Consul, Etcd, Zookeeper, BoltDB, Rest API, file …) Automatically and dynamically refresh the configuration file to achieve rapid service discovery.

Characteristics

It's very fast.

A single executable written in the Go language without installing other dependencies

Support for Rest API

Multiple backend support: Rancher, Docker, Swarm, Kubernetes, Marathon, Mesos, Consul, Etcd, and more

Background monitoring, which can listen for background changes and automatically apply new profile settings

Profile hot update. No need to restart the process

End http connection normally

Back-end circuit breaker

Polling, rebalancer load balancer

Rest Metrics

Support for minimizing official docker images

Backend support for SSL

The front desk supports SSL (including SNI)

Refreshing AngularJS front-end page

Support for Websocket

Support for HTTP/2

Network error retry

Support for Let's Encrypt (automatic updating of HTTPS certificates)

High availability cluster mode

A refreshing interface

Traefik has a simple web interface based on AngularJS.

Rancher-Traefik deployment

In order to ensure that Traefik resources are not affected by other services, we can let the Traefik service run on a node by specifying a dedicated dedicated machine.

PS: special plane-specific function, which is only applicable to Rancher automatic scheduling containers.

First, run Rancher Server and add a special node for Rancher-Agent special plane

Log in to WEB via http://rancher-server:8080 address

Locate the function to the infrastructure | Host, and click add Host to copy the generated command to add a Rancher-Agent

After the host is successfully added, the page navigates to the infrastructure | Host, find the desired host, click the ellipsis of the three dots in the upper right corner of the host view, and then click Edit.

In the host editing view, add traefik_lb=true to the tag and container tag requirements, respectively

PS: first tag: the Traefik service checks whether the host has a traefik_lb=true tag when it starts, and only hosts with this tag can install the Traefik service. The second container tag requirement: this is the special plane-specific function. By setting the traefik_lb=true tag, only services with traefik_lb=true tags can run on this node.

Enter the store (Catalog) to search and install Traefik applications

Once the tag is set, go to the store to search for Traefik and install it

Click to view the details to enter the configuration interface. Here we change the http port port to 80 and keep the other configurations by default. Finally, click start.

Enter the application | in the user view, you can see that the Traefik application is running normally

Enter the infrastructure | in the host view, you can see Traefik running on the specified host.

3. Run demo application

Create a new empty application stack named demo; add a service named nginx to demo and set the number to 4

In the label settings, add the following tags:

Traefik.enable = true can be understood as a switch on whether to register this service with traefik; traefik.domain = test.local a primary domain name suitable for all service access, which can be separated by commas; traefik.alias = nginx service alias, which can be understood as a secondary domain name under the primary domain name, and multiple domain names can be separated by commas; traefik.port = 80 tells the port number exposed by the traefik service Traefik forces health check to be enabled by default, and only healthy services will be registered with Traefik. Configure health check in health check

The service is running normally

IV. Demo-nginx service configuration

Traefik has a service management console with a default port of 8000.

So much for sharing about how to implement micro-services in Rancher through the deployment of Traefik. I hope the above content can be helpful to you and 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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report