feat(k8s): add max conn annotations.

This commit is contained in:
Fernandez Ludovic 2017-12-21 22:44:06 +01:00 committed by Traefiker
parent 1c495d7ea4
commit 53388a3570
4 changed files with 79 additions and 4 deletions

View file

@ -273,6 +273,10 @@ func (p *Provider) loadIngresses(k8sClient Client) (*types.Configuration, error)
templateObjects.Backends[r.Host+pa.Path].LoadBalancer = getLoadBalancer(service)
templateObjects.Backends[r.Host+pa.Path].Buffering = getBuffering(service)
if maxConn := getMaxConn(service); maxConn != nil {
templateObjects.Backends[r.Host+pa.Path].MaxConn = maxConn
}
protocol := label.DefaultProtocol
for _, port := range service.Spec.Ports {
if equalPorts(port, pa.Backend.ServicePort) {
@ -587,3 +591,15 @@ func getRateLimit(i *v1beta1.Ingress) *types.RateLimit {
}
return nil
}
func getMaxConn(service *v1.Service) *types.MaxConn {
amount := label.GetInt64Value(service.Annotations, label.TraefikBackendMaxConnAmount, -1)
extractorFunc := service.Annotations[label.TraefikBackendMaxConnExtractorFunc]
if amount >= 0 && len(extractorFunc) > 0 {
return &types.MaxConn{
ExtractorFunc: extractorFunc,
Amount: amount,
}
}
return nil
}