feat(rancher): add HealthCheck labels.
This commit is contained in:
parent
c884c7bb8a
commit
a1f47cb4db
2 changed files with 17 additions and 0 deletions
|
@ -41,6 +41,10 @@ func (p *Provider) buildConfiguration(services []rancherData) *types.Configurati
|
||||||
"getRedirectRegex": getFuncString(label.TraefikFrontendRedirectRegex, ""),
|
"getRedirectRegex": getFuncString(label.TraefikFrontendRedirectRegex, ""),
|
||||||
"getRedirectReplacement": getFuncString(label.TraefikFrontendRedirectReplacement, ""),
|
"getRedirectReplacement": getFuncString(label.TraefikFrontendRedirectReplacement, ""),
|
||||||
"getWhitelistSourceRange": getFuncSliceString(label.TraefikFrontendWhitelistSourceRange),
|
"getWhitelistSourceRange": getFuncSliceString(label.TraefikFrontendWhitelistSourceRange),
|
||||||
|
"hasHealthCheckLabels": hasFunc(label.TraefikBackendHealthCheckPath),
|
||||||
|
"getHealthCheckPath": getFuncString(label.TraefikBackendHealthCheckPath, ""),
|
||||||
|
"getHealthCheckPort": getFuncInt(label.TraefikBackendHealthCheckPort, label.DefaultBackendHealthCheckPort),
|
||||||
|
"getHealthCheckInterval": getFuncString(label.TraefikBackendHealthCheckInterval, ""),
|
||||||
}
|
}
|
||||||
|
|
||||||
// filter services
|
// filter services
|
||||||
|
@ -162,6 +166,12 @@ func getFuncString(labelName string, defaultValue string) func(service rancherDa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getFuncInt(labelName string, defaultValue int) func(service rancherData) int {
|
||||||
|
return func(service rancherData) int {
|
||||||
|
return label.GetIntValue(service.Labels, labelName, defaultValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func getFuncBool(labelName string, defaultValue bool) func(service rancherData) bool {
|
func getFuncBool(labelName string, defaultValue bool) func(service rancherData) bool {
|
||||||
return func(service rancherData) bool {
|
return func(service rancherData) bool {
|
||||||
return label.GetBoolValue(service.Labels, labelName, defaultValue)
|
return label.GetBoolValue(service.Labels, labelName, defaultValue)
|
||||||
|
|
|
@ -23,6 +23,13 @@
|
||||||
extractorFunc = "{{getMaxConnExtractorFunc $backend}}"
|
extractorFunc = "{{getMaxConnExtractorFunc $backend}}"
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
|
{{if hasHealthCheckLabels $backend}}
|
||||||
|
[backends.backend-{{$backendName}}.healthCheck]
|
||||||
|
path = "{{getHealthCheckPath $backend}}"
|
||||||
|
port = {{getHealthCheckPort $backend}}
|
||||||
|
interval = "{{getHealthCheckInterval $backend}}"
|
||||||
|
{{end}}
|
||||||
|
|
||||||
{{range $index, $ip := $backend.Containers}}
|
{{range $index, $ip := $backend.Containers}}
|
||||||
[backends.backend-{{$backendName}}.servers.server-{{$index}}]
|
[backends.backend-{{$backendName}}.servers.server-{{$index}}]
|
||||||
url = "{{getProtocol $backend}}://{{$ip}}:{{getPort $backend}}"
|
url = "{{getProtocol $backend}}://{{$ip}}:{{getPort $backend}}"
|
||||||
|
|
Loading…
Reference in a new issue