Walk through Running Traefik on Service Fabric Local Cluster
Premier Development Consultant Kurt Schenk provides a walk through to help you get up and running with Traefik on a Service Fabric Local Cluster.
In order to help you get up and running quickly to test Træfik and Service Fabric, this post will walk you through how to set this up on your local development cluster. There is good documentation at Running Træfik on Azure Service Fabric, but with a local development cluster you can skip some steps, and there are one or two snags I can help you avoid.
First off, why would you want to run Træfik on Azure Service Fabric? The reason is that Azure Service Fabric’s built-in reverse proxy is NOT recommended to expose APIs external to the cluster. Instead, Træfik and APIM are recommended by the Service Fabric product team (see Question – Azure Application Gateway with Service Fabric):
“At this point in time, there are a couple solutions available to you that don’t require you to write your own gateway service:
Azure API Management. APIM integrates with Service Fabric, meaning it has a Service Fabric back-end option that understands Service Fabric’s service discovery so it’s aware of services and how to discover their endpoints (works for stateful services too). If you end up having to manage a lot of front-end services, this could be a good option for you as APIM is specifically designed for that scenario.
Host a proxy server that can route traffic at L7. This is the direction we’re going with an integrated ingress proxy, but that’s still a few months out at least at this point. In the meantime though, take a look at running Traefik in your cluster, which integrates with Service Fabric and should be able to provide SSL termination and L7 traffic routing: https://docs.traefik.io/configuration/backends/servicefabric/”
Azure Service Fabric Mesh will use Envoy, but still recommend Træfik, or APIM for Azure Service Fabric and Service Fabric Standalone (on premises).
So let’s walk through deploying Træfik to your local development cluster. First, switch your cluster mode to 1 Node. Otherwise deployment to your local development cluster will fail since the GitHub project as it is will try to start 5 instances of Træfik listening on port 80 if you use 5 Node cluster.
Now from Running Træfik on Azure Service Fabric you can choose where to deploy from, and for this walkthrough chose Visual Studio as described in Running Træfik on Azure Service Fabric >> Visual Studio.
1. Clone this repository to your local machine.
In my case, I just clicked on Clone or download
2. Download the Træfik binary into the solution by running the following PowerShell script.
./$REPO_ROOT/Traefik/Scripts/Get-TraefikBinary.ps1 -url $TRAEFIK_RELEASE
I chose v1.5.4, the latest stable release.
3. Open the Traefik.sln file in Visual
4…8. Skipped these steps. The documentation says that if “working against a local development cluster or don’t require a secure cluster, skip to step 7.” But since step 7 is setting up TLS skipped that as well for local development cluster. Also skipped step 8 setting up watchdog service
9. You can now simply publish Træfik from Visual Studio like any other Service Fabric application
Right click on the project, select Publish and follow the wizard.
This will deploy Træfik to listen on port 80 for incoming traffic, and expose the Træfik dashboard on port 8080. But since there were system services listening on port 80 on my Windows 10 laptop this failed:
I had to first stop these services, which I did as follows:
Now when you publish it should work and in Service Fabric Explorer you will see this.
10. Skipped this step since not deploying to Azure Service Fabric, and instead to local development cluster.
11. Once the load balancer has been configured to route traffic on the required ports, you should be able to visit the Træfik dashboard at http[s]://[clusterfqdn]:8080 if you have it enabled.
For me deploying to local development cluster this was http://localhost:8080
Now, you can navigate to ./$REPO_ROOT/Traefik/Demos and run through demo as described in Running Træfik on Azure Service Fabric >> Demos >> routine.txt. For example, here is a screen shot as walking through demo of blue/green upgrade.
The demo described in routine.txt above also shows canary upgrade, distributing traffic between versions (25% progressively to 100%).
Now, after you have experimented a bit with Træfik on your Service Fabric local development cluster, it should make it easier for you to get up and running in Azure Service Fabric, or Service Fabric Standalone (on premises).