Traefik
  • 05 Jul 2023
  • 2 Minutes to read
  • PDF

Traefik

  • PDF

Article Summary

Traefik is an open-source reverse proxy and load balancer designed for microservices and containerized applications. It is commonly used in cloud-native environments and works well with container orchestration platforms like Docker, Kubernetes, and Swarm.

Traefik acts as a gateway for incoming traffic, routing requests to the appropriate services based on rules and configurations. It dynamically discovers new services as they are added or removed, making it flexible and scalable in dynamic environments. It also provides features such as SSL/TLS termination, traffic routing based on HTTP headers or paths. Traceable provides a plugin to capture the data passing through Traefik and sends it to Traceable's Platform agent, that in turn sends the data to Traceable's Platform for further analysis. The following is a high-level deployment diagram of Traceable's Traefik plugin:

traceable_traefik_deployment_diagram

Note
Traceable's Traefik plugin does not support blocking.



Before you begin

Make a note of the following points before you proceed with deployment:

  • Make sure that Traceable Platform agent is already installed and configured. For more information on installing the agent, see Platform agent.
  • Make a note of Platform agent's host name or IP address. This would be required when you configure the plugin.

Deployment

Deploying Traceable's Traefik plugin requires configuring the Traefik static configuration and Traefik dynamic configuration. The download location and plugin version are configured as static condition. The dynamic configuration is to configure middleware and router. Middleware and router are two important concepts in Traefik.

  • Middleware - Middleware in Traefik refers to a set of actions or modifications that can be applied to requests or responses passing through Traefik. Middleware allows you to customize and enhance the behavior of your services without modifying the services themselves.
  • Router - Routers define how incoming requests are matched and routed to the appropriate services. They act as traffic managers within Traefik. A router consists of a set of conditions and rules that determine which requests should be directed to which services.

The static and dynamic configurations are added to traefik.yml file.

Configure download location

Traceable's Traefik plugin is available at Traceable's Github repository. This location is configured in traefik.yml file as shown below.

experimental:
  plugins:
    plugin-traceableai:
      moduleName: github.com/traceableai/traceable_traefik_plugin
      moduleVersion: 1.0.0

Configure middleware

Configure middleware as shown below. Add the service name to servicename. This is the name that would be visible in Traceable's UI. Configure the Platform agent's IP address or hostname in tpaendpoint as shown below:

  middlewares:
    my-plugin-traceableai:
      plugin:
        traceableai:
          allowedContentTypes:
            - "json"
            - "xml"
            - "x-www-form-urlencoded"
            - "grpc"
          bodyCaptureSize: 131072
          serviceName: traefik
          tpaEndpoint: http://<REPLACE_WITH_TPA_HOST_OR_IP>:5442

Configure router

Configure the router as shown below:

http:
  routers:
    example-router:
      service: a-service
      rule: Headers(`host`, `frontend.local`)
      middlewares:
        - my-plugin-traceableai

Upgrade

Upgrading Traceable's plugin requires updating the version number in the static configuration in traefik.yml file:

experimental:
  plugins:
    traceableai:
      moduleName: "github.com/traceableai/traceableai_traefik_plugin"
      version: "v1.0.0"

Uninstall

Uninstalling Traceable's plugin requires removing the Traceable configuration from the traefik.yml file.


Was this article helpful?

What's Next