Add routes priorities in providers
Signed-off-by: Emile Vauge <emile@vauge.com>
This commit is contained in:
parent
287b3ba1f4
commit
f4cb4bb1b8
8 changed files with 25 additions and 4 deletions
|
@ -167,6 +167,7 @@ func (provider *Docker) loadDockerConfig(containersInspected []dockertypes.Conta
|
||||||
"getDomain": provider.getDomain,
|
"getDomain": provider.getDomain,
|
||||||
"getProtocol": provider.getProtocol,
|
"getProtocol": provider.getProtocol,
|
||||||
"getPassHostHeader": provider.getPassHostHeader,
|
"getPassHostHeader": provider.getPassHostHeader,
|
||||||
|
"getPriority": provider.getPriority,
|
||||||
"getEntryPoints": provider.getEntryPoints,
|
"getEntryPoints": provider.getEntryPoints,
|
||||||
"getFrontendRule": provider.getFrontendRule,
|
"getFrontendRule": provider.getFrontendRule,
|
||||||
"replace": replace,
|
"replace": replace,
|
||||||
|
@ -300,6 +301,13 @@ func (provider *Docker) getPassHostHeader(container dockertypes.ContainerJSON) s
|
||||||
return "true"
|
return "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (provider *Docker) getPriority(container dockertypes.ContainerJSON) string {
|
||||||
|
if priority, err := getLabel(container, "traefik.frontend.priority"); err == nil {
|
||||||
|
return priority
|
||||||
|
}
|
||||||
|
return "0"
|
||||||
|
}
|
||||||
|
|
||||||
func (provider *Docker) getEntryPoints(container dockertypes.ContainerJSON) []string {
|
func (provider *Docker) getEntryPoints(container dockertypes.ContainerJSON) []string {
|
||||||
if entryPoints, err := getLabel(container, "traefik.frontend.entryPoints"); err == nil {
|
if entryPoints, err := getLabel(container, "traefik.frontend.entryPoints"); err == nil {
|
||||||
return strings.Split(entryPoints, ",")
|
return strings.Split(entryPoints, ",")
|
||||||
|
|
|
@ -116,6 +116,7 @@ func (provider *Marathon) loadMarathonConfig() *types.Configuration {
|
||||||
"getDomain": provider.getDomain,
|
"getDomain": provider.getDomain,
|
||||||
"getProtocol": provider.getProtocol,
|
"getProtocol": provider.getProtocol,
|
||||||
"getPassHostHeader": provider.getPassHostHeader,
|
"getPassHostHeader": provider.getPassHostHeader,
|
||||||
|
"getPriority": provider.getPriority,
|
||||||
"getEntryPoints": provider.getEntryPoints,
|
"getEntryPoints": provider.getEntryPoints,
|
||||||
"getFrontendRule": provider.getFrontendRule,
|
"getFrontendRule": provider.getFrontendRule,
|
||||||
"getFrontendBackend": provider.getFrontendBackend,
|
"getFrontendBackend": provider.getFrontendBackend,
|
||||||
|
@ -322,6 +323,13 @@ func (provider *Marathon) getPassHostHeader(application marathon.Application) st
|
||||||
return "true"
|
return "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (provider *Marathon) getPriority(application marathon.Application) string {
|
||||||
|
if priority, err := provider.getLabel(application, "traefik.frontend.priority"); err == nil {
|
||||||
|
return priority
|
||||||
|
}
|
||||||
|
return "0"
|
||||||
|
}
|
||||||
|
|
||||||
func (provider *Marathon) getEntryPoints(application marathon.Application) []string {
|
func (provider *Marathon) getEntryPoints(application marathon.Application) []string {
|
||||||
if entryPoints, err := provider.getLabel(application, "traefik.frontend.entryPoints"); err == nil {
|
if entryPoints, err := provider.getLabel(application, "traefik.frontend.entryPoints"); err == nil {
|
||||||
return strings.Split(entryPoints, ",")
|
return strings.Split(entryPoints, ",")
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
[frontends.frontend-{{.ServiceName}}]
|
[frontends.frontend-{{.ServiceName}}]
|
||||||
backend = "backend-{{.ServiceName}}"
|
backend = "backend-{{.ServiceName}}"
|
||||||
passHostHeader = {{getAttribute "frontend.passHostHeader" .Attributes "true"}}
|
passHostHeader = {{getAttribute "frontend.passHostHeader" .Attributes "true"}}
|
||||||
|
priority = {{getAttribute "frontend.priority" .Attributes "0"}}
|
||||||
{{$entryPoints := getAttribute "frontend.entrypoints" .Attributes ""}}
|
{{$entryPoints := getAttribute "frontend.entrypoints" .Attributes ""}}
|
||||||
{{with $entryPoints}}
|
{{with $entryPoints}}
|
||||||
entrypoints = [{{range getEntryPoints $entryPoints}}
|
entrypoints = [{{range getEntryPoints $entryPoints}}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
[frontends."frontend-{{$frontend}}"]{{$container := index $containers 0}}
|
[frontends."frontend-{{$frontend}}"]{{$container := index $containers 0}}
|
||||||
backend = "backend-{{getBackend $container}}"
|
backend = "backend-{{getBackend $container}}"
|
||||||
passHostHeader = {{getPassHostHeader $container}}
|
passHostHeader = {{getPassHostHeader $container}}
|
||||||
|
priority = {{getPriority $container}}
|
||||||
entryPoints = [{{range getEntryPoints $container}}
|
entryPoints = [{{range getEntryPoints $container}}
|
||||||
"{{.}}",
|
"{{.}}",
|
||||||
{{end}}]
|
{{end}}]
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
[frontends."{{$frontend}}"]
|
[frontends."{{$frontend}}"]
|
||||||
backend = "{{Get "" . "/backend"}}"
|
backend = "{{Get "" . "/backend"}}"
|
||||||
passHostHeader = {{Get "true" . "/passHostHeader"}}
|
passHostHeader = {{Get "true" . "/passHostHeader"}}
|
||||||
|
priority = {{Get "0" . "/priority"}}
|
||||||
entryPoints = [{{range $entryPoints}}
|
entryPoints = [{{range $entryPoints}}
|
||||||
"{{.}}",
|
"{{.}}",
|
||||||
{{end}}]
|
{{end}}]
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
[frontends.frontend{{.ID | replace "/" "-"}}]
|
[frontends.frontend{{.ID | replace "/" "-"}}]
|
||||||
backend = "backend{{getFrontendBackend .}}"
|
backend = "backend{{getFrontendBackend .}}"
|
||||||
passHostHeader = {{getPassHostHeader .}}
|
passHostHeader = {{getPassHostHeader .}}
|
||||||
|
priority = {{getPriority .}}
|
||||||
entryPoints = [{{range getEntryPoints .}}
|
entryPoints = [{{range getEntryPoints .}}
|
||||||
"{{.}}",
|
"{{.}}",
|
||||||
{{end}}]
|
{{end}}]
|
||||||
|
|
|
@ -34,7 +34,7 @@ type CircuitBreaker struct {
|
||||||
// Server holds server configuration.
|
// Server holds server configuration.
|
||||||
type Server struct {
|
type Server struct {
|
||||||
URL string `json:"url,omitempty"`
|
URL string `json:"url,omitempty"`
|
||||||
Weight int `json:"weight,omitempty"`
|
Weight int `json:"weight"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Route holds route configuration.
|
// Route holds route configuration.
|
||||||
|
@ -52,7 +52,7 @@ type Frontend struct {
|
||||||
Backend string `json:"backend,omitempty"`
|
Backend string `json:"backend,omitempty"`
|
||||||
Routes map[string]Route `json:"routes,omitempty"`
|
Routes map[string]Route `json:"routes,omitempty"`
|
||||||
PassHostHeader bool `json:"passHostHeader,omitempty"`
|
PassHostHeader bool `json:"passHostHeader,omitempty"`
|
||||||
Priority int `json:"priority,omitempty"`
|
Priority int `json:"priority"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadBalancerMethod holds the method of load balancing to use.
|
// LoadBalancerMethod holds the method of load balancing to use.
|
||||||
|
|
|
@ -16,7 +16,8 @@
|
||||||
</div>
|
</div>
|
||||||
<div data-bg-show="frontendCtrl.frontend.backend" class="panel-footer">
|
<div data-bg-show="frontendCtrl.frontend.backend" class="panel-footer">
|
||||||
<span data-ng-repeat="entryPoint in frontendCtrl.frontend.entryPoints"><span class="label label-primary">{{entryPoint}}</span><span data-ng-hide="$last"> </span></span>
|
<span data-ng-repeat="entryPoint in frontendCtrl.frontend.entryPoints"><span class="label label-primary">{{entryPoint}}</span><span data-ng-hide="$last"> </span></span>
|
||||||
<span class="label label-warning" role="button" data-toggle="collapse" href="#{{frontendCtrl.frontend.backend}}" aria-expanded="false">{{frontendCtrl.frontend.backend}}</span>
|
<span class="label label-warning" role="button" data-toggle="collapse" href="#{{frontendCtrl.frontend.backend}}" aria-expanded="false">Backend:{{frontendCtrl.frontend.backend}}</span>
|
||||||
<span data-ng-show="frontendCtrl.frontend.passHostHeader" class="label label-warning">Pass Host Header</span>
|
<span data-ng-show="frontendCtrl.frontend.passHostHeader" class="label label-warning">PassHostHeader</span>
|
||||||
|
<span data-ng-show="frontendCtrl.frontend.priority" class="label label-warning">Priority:{{frontendCtrl.frontend.priority}}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue