Setting Up: Traefik Balancer In Rancher Cloud

DevOpsUPDATED ON October 8, 2020

This post spotlights Traefik load balancer that works in conjunction with Docker labels and Rancher API. Check out a step-by-step guide on how our DevOps consultants deploy Traefik balancer in Rancher cloud and get a quick access to services back-end and dynamic configurations reload.

Here we will consider ‘modern HTTP reverse proxy’© as an alternative to HAProxy in Rancher Cloud.

Getting ready to deploy in Rancher 2.0

In API -> Keys -> Add Account API Key create a key:


Save received Access Key and Secret Key

Add label for a host where traefik will be launched:

In Infrastructure ->Hosts click Edit

Add label:

Write docker-compose for traefik:

Deploy traefic in Rancher:

In Stacks -> User -> Add Stack write stack’s name and upload docker-compose.yml

Turn on traefik support in services that will receive traffic through a balancer:

If everything goes right, after redirecting to the address traefik_ip_addess:8080, you will see:

Collecting Balancer metrics

Use Prometheus for collecting metrics and Grafana for visualization. To collect metrics in traefik, add to docker-compose.yml two lines:

Create directories /opt/conf/prometheus:

Create a file prometheus.yml in there:

Deploy grafana and prometheus:

Grafana should be accessible through the address grafana_ip:3000. Shift to Data Sources -> Add Data Source and set up Prometheus connection

Now download Traefik Realtime Metrics dashboard from Import Dashboard and enjoy the result.

Now, you have an idea on how to deploy Traefik balancer in Rancher cloud. All you need is to set up following the guide. In case you face any difficulties, K&C team is always here to help.