Factorize labels
* refactor(accesslog): factorize file name. * traefik.frontend.rule * traefik.frontend.value * traefik.backend.circuitbreaker.expression * traefik.enable * traefik.backend.loadbalancer.method * traefik.backend.loadbalancer.sticky * traefik.backend.maxconn.amount * traefik.backend.maxconn.extractorfunc * traefik.port * traefik.tags * traefik.backend * traefik.weight * traefik.domain * traefik.protocol * traefik.frontend.passHostHeader * traefik.frontend.whitelistSourceRange * traefik.frontend.priority * traefik.frontend.entryPoints * traefik.frontend.auth.basic * traefik.backend.id * traefik.backend.circuitbreaker * traefik.frontend.rule.type * traefik.portIndex * refactor(docker): specific labels * refactor(rancher): specific labels * traefik.backend.healthcheck.* * refactor(providers): factorize labels.
This commit is contained in:
parent
2e84b1e556
commit
d653a348b1
20 changed files with 390 additions and 330 deletions
|
@ -27,9 +27,8 @@ import (
|
|||
var _ provider.Provider = (*Provider)(nil)
|
||||
|
||||
const (
|
||||
annotationFrontendRuleType = "traefik.frontend.rule.type"
|
||||
ruleTypePathPrefix = "PathPrefix"
|
||||
ruleTypeReplacePath = "ReplacePath"
|
||||
ruleTypePathPrefix = "PathPrefix"
|
||||
ruleTypeReplacePath = "ReplacePath"
|
||||
|
||||
annotationKubernetesIngressClass = "kubernetes.io/ingress.class"
|
||||
annotationKubernetesAuthRealm = "ingress.kubernetes.io/auth-realm"
|
||||
|
@ -169,7 +168,7 @@ func (p *Provider) loadIngresses(k8sClient Client) (*types.Configuration, error)
|
|||
|
||||
PassHostHeader := p.getPassHostHeader()
|
||||
|
||||
passHostHeaderAnnotation, ok := i.Annotations["traefik.frontend.passHostHeader"]
|
||||
passHostHeaderAnnotation, ok := i.Annotations[types.LabelFrontendPassHostHeader]
|
||||
switch {
|
||||
case !ok:
|
||||
// No op.
|
||||
|
@ -178,7 +177,7 @@ func (p *Provider) loadIngresses(k8sClient Client) (*types.Configuration, error)
|
|||
case passHostHeaderAnnotation == "true":
|
||||
PassHostHeader = true
|
||||
default:
|
||||
log.Warnf("Unknown value '%s' for traefik.frontend.passHostHeader, falling back to %s", passHostHeaderAnnotation, PassHostHeader)
|
||||
log.Warnf("Unknown value '%s' for %s, falling back to %s", passHostHeaderAnnotation, types.LabelFrontendPassHostHeader, PassHostHeader)
|
||||
}
|
||||
if realm := i.Annotations[annotationKubernetesAuthRealm]; realm != "" && realm != traefikDefaultRealm {
|
||||
return nil, errors.New("no realm customization supported")
|
||||
|
@ -235,17 +234,17 @@ func (p *Provider) loadIngresses(k8sClient Client) (*types.Configuration, error)
|
|||
continue
|
||||
}
|
||||
|
||||
if expression := service.Annotations["traefik.backend.circuitbreaker"]; expression != "" {
|
||||
if expression := service.Annotations[types.LabelTraefikBackendCircuitbreaker]; expression != "" {
|
||||
templateObjects.Backends[r.Host+pa.Path].CircuitBreaker = &types.CircuitBreaker{
|
||||
Expression: expression,
|
||||
}
|
||||
}
|
||||
|
||||
if service.Annotations["traefik.backend.loadbalancer.method"] == "drr" {
|
||||
if service.Annotations[types.LabelBackendLoadbalancerMethod] == "drr" {
|
||||
templateObjects.Backends[r.Host+pa.Path].LoadBalancer.Method = "drr"
|
||||
}
|
||||
|
||||
if service.Annotations["traefik.backend.loadbalancer.sticky"] == "true" {
|
||||
if service.Annotations[types.LabelBackendLoadbalancerSticky] == "true" {
|
||||
templateObjects.Backends[r.Host+pa.Path].LoadBalancer.Sticky = true
|
||||
}
|
||||
|
||||
|
@ -309,7 +308,7 @@ func getRuleForPath(pa v1beta1.HTTPIngressPath, i *v1beta1.Ingress) string {
|
|||
return ""
|
||||
}
|
||||
|
||||
ruleType := i.Annotations[annotationFrontendRuleType]
|
||||
ruleType := i.Annotations[types.LabelFrontendRuleType]
|
||||
if ruleType == "" {
|
||||
ruleType = ruleTypePathPrefix
|
||||
}
|
||||
|
|
|
@ -383,7 +383,7 @@ func TestRuleType(t *testing.T) {
|
|||
|
||||
if test.ingressRuleType != "" {
|
||||
ingress.ObjectMeta.Annotations = map[string]string{
|
||||
annotationFrontendRuleType: test.ingressRuleType,
|
||||
types.LabelFrontendRuleType: test.ingressRuleType,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1224,8 +1224,8 @@ func TestServiceAnnotations(t *testing.T) {
|
|||
UID: "1",
|
||||
Namespace: "testing",
|
||||
Annotations: map[string]string{
|
||||
"traefik.backend.circuitbreaker": "NetworkErrorRatio() > 0.5",
|
||||
"traefik.backend.loadbalancer.method": "drr",
|
||||
types.LabelTraefikBackendCircuitbreaker: "NetworkErrorRatio() > 0.5",
|
||||
types.LabelBackendLoadbalancerMethod: "drr",
|
||||
},
|
||||
},
|
||||
Spec: v1.ServiceSpec{
|
||||
|
@ -1243,8 +1243,8 @@ func TestServiceAnnotations(t *testing.T) {
|
|||
UID: "2",
|
||||
Namespace: "testing",
|
||||
Annotations: map[string]string{
|
||||
"traefik.backend.circuitbreaker": "",
|
||||
"traefik.backend.loadbalancer.sticky": "true",
|
||||
types.LabelTraefikBackendCircuitbreaker: "",
|
||||
types.LabelBackendLoadbalancerSticky: "true",
|
||||
},
|
||||
},
|
||||
Spec: v1.ServiceSpec{
|
||||
|
@ -1418,7 +1418,7 @@ func TestIngressAnnotations(t *testing.T) {
|
|||
ObjectMeta: v1.ObjectMeta{
|
||||
Namespace: "testing",
|
||||
Annotations: map[string]string{
|
||||
"traefik.frontend.passHostHeader": "false",
|
||||
types.LabelFrontendPassHostHeader: "false",
|
||||
},
|
||||
},
|
||||
Spec: v1beta1.IngressSpec{
|
||||
|
@ -1447,7 +1447,7 @@ func TestIngressAnnotations(t *testing.T) {
|
|||
Namespace: "testing",
|
||||
Annotations: map[string]string{
|
||||
"kubernetes.io/ingress.class": "traefik",
|
||||
"traefik.frontend.passHostHeader": "true",
|
||||
types.LabelFrontendPassHostHeader: "true",
|
||||
},
|
||||
},
|
||||
Spec: v1beta1.IngressSpec{
|
||||
|
@ -1784,7 +1784,7 @@ func TestInvalidPassHostHeaderValue(t *testing.T) {
|
|||
ObjectMeta: v1.ObjectMeta{
|
||||
Namespace: "testing",
|
||||
Annotations: map[string]string{
|
||||
"traefik.frontend.passHostHeader": "herpderp",
|
||||
types.LabelFrontendPassHostHeader: "herpderp",
|
||||
},
|
||||
},
|
||||
Spec: v1beta1.IngressSpec{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue