Warning: Developing this solution is a non-trivial task especially if you are unfamiliar with the
golang
,dep
and its tooling. We highly recommend taking the time to understand bothdep
andgolang
on a simpler project before starting.
- Golang Environment: Guide NOTE: Ensure you have your GOPATH and other required environment variables configured.
- Docker Installed
- Dep Installed: Install Guide and How-to
- Local Service Fabric cluster: Mac or Windows
- Sample Application deployed into Service Fabric cluster
- Git
- VSCode with Go Extension
- Delve debugger installed and configured
In this doc we will focus on setting up your dev environment and assume a working knowledge of the SF provider and Traefik.
This blog provides a good understanding of how the integration works and why it was written. It is highly recommended that you read the blog and Traefik docs before proceeding.
The solution consists of several different github projects:
- Traefik Extra Service Fabric: SF provider for Traefik
- Service Fabric Go SDK: SF Management SDK for Go
- Traefik: Builds the proxy
The Traefik
project imports Traefik Extra Service Fabric
which in turn import the Service Fabric Golang SDK
all using dep
and versioned by CommitID pinning.
Traefik (03ce6a) => Traefik Extra Service Fabric (29a6d7) => Service Fabric Golang SDK (8eebe1)
To release an update of the Service Fabric Golang SDK
a pull-request (PR) should be made to it's repository and once accepted Traefik Extra Service Fabric
's gopkg.toml
can be update to reference this new CommitID and this change is PR'd. Then finally Traefik
can be updated to reference this new version of Traefik Extra Service Fabric
. While this provides the necessary control to version releases of Traefik
this isn't a workable flow when developing.
$ go get github.com/containous/traefik
$ cd $GOPATH/src/github.com/containous/traefik
# `master` branch of `Traefik Extra Service Fabric` is compatible with `Traefik` v1.6+
$ git checkout v1.6
For local development you can simplify the flow by cloning both Traefik Extra Service Fabric
and Service Fabric Go SDK
into the /vendor
folder of Traefik
. This provides a quick and easy way to build/debug Traefik
by making changes to Traefik Extra Service Fabric
in the /vendor
folder. These changes can then be checked in an pushed from each projects folder /vendor/github.com/jjcollinge/servicefabric
for example.
NOTE: This is only a local solution to speed things up, the full flow is required for releases.
NOTE: Be aware that
golang
is sensitive to file paths so, even if you are working on a fork, you must ensure yourTraefik
instance is located at$gopath/src/github.com/containous/traefik
NOTE: If you do work inside
Traefik
's/vendor
directory, it may be helpful to delete the.git
folder insideTraefik
to avoid confusion between the nested git repositories.
# replace vendored `containous/traefik-extra-service-fabric` folder with git repo
$ cd $GOPATH/src/github.com/containous/traefik/vendor/github.com/containous
$ rm -r traefik-extra-service-fabric
$ git clone https://github.com/containous/traefik-extra-service-fabric
# replace vendored `jjcollinge/servicefabric` folder with git repo
$ cd $GOPATH/src/github.com/containous/traefik/vendor/github.com/jjcollinge
$ rm -r servicefabric
$ git clone https://github.com/jjcollinge/servicefabric
WARNING: Building the top level
traefik
solution can overwrite thevendor
file and any changes intraefik-service-fabric-extra
can be lost. This is caused bymake
. Ensure changes are pushed to a remote before attempting to buildtraefik
. Be sure to usego build ./cmd/traefik
to build rather than themake
command.
-
Follow Traefik WebUI Build: How to build for backend devs.
NOTE: If you have an empty
/static
folder already delete it before runningmake generate-ui
. This may fail on Windows, if so, please use abash
environment such as WSL. -
Follow the Traefik Guide: Method #2
In the traefik
directory run:
go test -v ./vendor/github.com/containous/traefik-extra-service-fabric/...
go test -v ./vendor/github.com/jjcollinge/servicefabric/...
In your Traefik
directory create the following files then hit F5
. You can step and set breakpoints in both Traefik
and the other packages in the vendor
file.
.vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"port": 2345,
"host": "127.0.0.1",
"program": "${workspaceRoot}/cmd/traefik",
"args": [
"--configfile=./.vscode/testconfig.toml",
],
"showLog": true
}
]
}
.vscode/testconfig.toml
################################################################
# Global configuration
################################################################
# Enable debug mode
#
# Optional
# Default: false
#
debug = true
# Log level
#
# Optional
# Default: "ERROR"
#
logLevel = "DEBUG"
################################################################
# Entrypoints configuration
################################################################
# Entrypoints definition
#
# Optional
# Default:
[entryPoints]
[entryPoints.http]
address = ":8081"
[entryPoints.traefik]
address = ":8080"
################################################################
# API and dashboard configuration
################################################################
# Enable API and dashboard
[api]
# Name of the related entry point
#
# Optional
# Default: "traefik"
#
# entryPoint = "traefik"
# Enabled Dashboard
#
# Optional
# Default: true
#
# dashboard = false
################################################################
# Ping configuration
################################################################
# Enable ping
[ping]
# Name of the related entry point
#
# Optional
# Default: "traefik"
#
# entryPoint = "traefik"
################################################################
# Service Fabric provider
################################################################
# Enable Service Fabric configuration backend
[servicefabric]
# Service Fabric Management Endpoint
clustermanagementurl = "http://localhost:19080"
# Note: use "https://localhost:19080" if you're using a secure cluster
# Service Fabric Management Endpoint API Version
apiversion = "3.0"
# Enable TLS connection.
#
# Optional
#
#[serviceFabric.tls]
# cert = "certs/servicefabric.crt"
# key = "certs/servicefabric.key"
# insecureskipverify = true