Move dynamic config into a dedicated package.
This commit is contained in:
parent
09cc1161c9
commit
c8bf8e896a
102 changed files with 3170 additions and 3166 deletions
|
@ -14,7 +14,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/cenkalti/backoff"
|
||||
"github.com/containous/traefik/pkg/config"
|
||||
"github.com/containous/traefik/pkg/config/dynamic"
|
||||
"github.com/containous/traefik/pkg/job"
|
||||
"github.com/containous/traefik/pkg/log"
|
||||
"github.com/containous/traefik/pkg/provider/kubernetes/crd/traefik/v1alpha1"
|
||||
|
@ -80,7 +80,7 @@ func (p *Provider) Init() error {
|
|||
|
||||
// Provide allows the k8s provider to provide configurations to traefik
|
||||
// using the given configuration channel.
|
||||
func (p *Provider) Provide(configurationChan chan<- config.Message, pool *safe.Pool) error {
|
||||
func (p *Provider) Provide(configurationChan chan<- dynamic.Message, pool *safe.Pool) error {
|
||||
ctxLog := log.With(context.Background(), log.Str(log.ProviderName, "kubernetescrd"))
|
||||
logger := log.FromContext(ctxLog)
|
||||
// Tell glog (used by client-go) to log into STDERR. Otherwise, we risk
|
||||
|
@ -124,7 +124,7 @@ func (p *Provider) Provide(configurationChan chan<- config.Message, pool *safe.P
|
|||
logger.Debugf("Skipping Kubernetes event kind %T", event)
|
||||
} else {
|
||||
p.lastConfiguration.Set(conf)
|
||||
configurationChan <- config.Message{
|
||||
configurationChan <- dynamic.Message{
|
||||
ProviderName: "kubernetescrd",
|
||||
Configuration: conf,
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ func checkStringQuoteValidity(value string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
func loadTCPServers(client Client, namespace string, svc v1alpha1.ServiceTCP) ([]config.TCPServer, error) {
|
||||
func loadTCPServers(client Client, namespace string, svc v1alpha1.ServiceTCP) ([]dynamic.TCPServer, error) {
|
||||
service, exists, err := client.GetService(namespace, svc.Name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -172,9 +172,9 @@ func loadTCPServers(client Client, namespace string, svc v1alpha1.ServiceTCP) ([
|
|||
return nil, errors.New("service port not found")
|
||||
}
|
||||
|
||||
var servers []config.TCPServer
|
||||
var servers []dynamic.TCPServer
|
||||
if service.Spec.Type == corev1.ServiceTypeExternalName {
|
||||
servers = append(servers, config.TCPServer{
|
||||
servers = append(servers, dynamic.TCPServer{
|
||||
Address: fmt.Sprintf("%s:%d", service.Spec.ExternalName, portSpec.Port),
|
||||
})
|
||||
} else {
|
||||
|
@ -205,7 +205,7 @@ func loadTCPServers(client Client, namespace string, svc v1alpha1.ServiceTCP) ([
|
|||
}
|
||||
|
||||
for _, addr := range subset.Addresses {
|
||||
servers = append(servers, config.TCPServer{
|
||||
servers = append(servers, dynamic.TCPServer{
|
||||
Address: fmt.Sprintf("%s:%d", addr.IP, port),
|
||||
})
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ func loadTCPServers(client Client, namespace string, svc v1alpha1.ServiceTCP) ([
|
|||
return servers, nil
|
||||
}
|
||||
|
||||
func loadServers(client Client, namespace string, svc v1alpha1.Service) ([]config.Server, error) {
|
||||
func loadServers(client Client, namespace string, svc v1alpha1.Service) ([]dynamic.Server, error) {
|
||||
strategy := svc.Strategy
|
||||
if strategy == "" {
|
||||
strategy = "RoundRobin"
|
||||
|
@ -245,9 +245,9 @@ func loadServers(client Client, namespace string, svc v1alpha1.Service) ([]confi
|
|||
return nil, errors.New("service port not found")
|
||||
}
|
||||
|
||||
var servers []config.Server
|
||||
var servers []dynamic.Server
|
||||
if service.Spec.Type == corev1.ServiceTypeExternalName {
|
||||
servers = append(servers, config.Server{
|
||||
servers = append(servers, dynamic.Server{
|
||||
URL: fmt.Sprintf("http://%s:%d", service.Spec.ExternalName, portSpec.Port),
|
||||
})
|
||||
} else {
|
||||
|
@ -290,7 +290,7 @@ func loadServers(client Client, namespace string, svc v1alpha1.Service) ([]confi
|
|||
}
|
||||
|
||||
for _, addr := range subset.Addresses {
|
||||
servers = append(servers, config.Server{
|
||||
servers = append(servers, dynamic.Server{
|
||||
URL: fmt.Sprintf("%s://%s:%d", protocol, addr.IP, port),
|
||||
})
|
||||
}
|
||||
|
@ -347,11 +347,11 @@ func buildTLSOptions(ctx context.Context, client Client) map[string]tls.Options
|
|||
return tlsOptions
|
||||
}
|
||||
|
||||
func (p *Provider) loadIngressRouteConfiguration(ctx context.Context, client Client, tlsConfigs map[string]*tls.CertAndStores) *config.HTTPConfiguration {
|
||||
conf := &config.HTTPConfiguration{
|
||||
Routers: map[string]*config.Router{},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Services: map[string]*config.Service{},
|
||||
func (p *Provider) loadIngressRouteConfiguration(ctx context.Context, client Client, tlsConfigs map[string]*tls.CertAndStores) *dynamic.HTTPConfiguration {
|
||||
conf := &dynamic.HTTPConfiguration{
|
||||
Routers: map[string]*dynamic.Router{},
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Services: map[string]*dynamic.Service{},
|
||||
}
|
||||
|
||||
for _, ingressRoute := range client.GetIngressRoutes() {
|
||||
|
@ -388,7 +388,7 @@ func (p *Provider) loadIngressRouteConfiguration(ctx context.Context, client Cli
|
|||
continue
|
||||
}
|
||||
|
||||
var allServers []config.Server
|
||||
var allServers []dynamic.Server
|
||||
for _, service := range route.Services {
|
||||
servers, err := loadServers(client, ingressRoute.Namespace, service)
|
||||
if err != nil {
|
||||
|
@ -429,7 +429,7 @@ func (p *Provider) loadIngressRouteConfiguration(ctx context.Context, client Cli
|
|||
|
||||
serviceName := makeID(ingressRoute.Namespace, key)
|
||||
|
||||
conf.Routers[serviceName] = &config.Router{
|
||||
conf.Routers[serviceName] = &dynamic.Router{
|
||||
Middlewares: mds,
|
||||
Priority: route.Priority,
|
||||
EntryPoints: ingressRoute.Spec.EntryPoints,
|
||||
|
@ -438,7 +438,7 @@ func (p *Provider) loadIngressRouteConfiguration(ctx context.Context, client Cli
|
|||
}
|
||||
|
||||
if ingressRoute.Spec.TLS != nil {
|
||||
tlsConf := &config.RouterTLSConfig{}
|
||||
tlsConf := &dynamic.RouterTLSConfig{}
|
||||
if ingressRoute.Spec.TLS.Options != nil && len(ingressRoute.Spec.TLS.Options.Name) > 0 {
|
||||
tlsOptionsName := ingressRoute.Spec.TLS.Options.Name
|
||||
// Is a Kubernetes CRD reference, (i.e. not a cross-provider reference)
|
||||
|
@ -459,8 +459,8 @@ func (p *Provider) loadIngressRouteConfiguration(ctx context.Context, client Cli
|
|||
conf.Routers[serviceName].TLS = tlsConf
|
||||
}
|
||||
|
||||
conf.Services[serviceName] = &config.Service{
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
conf.Services[serviceName] = &dynamic.Service{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
Servers: allServers,
|
||||
// TODO: support other strategies.
|
||||
PassHostHeader: true,
|
||||
|
@ -472,10 +472,10 @@ func (p *Provider) loadIngressRouteConfiguration(ctx context.Context, client Cli
|
|||
return conf
|
||||
}
|
||||
|
||||
func (p *Provider) loadIngressRouteTCPConfiguration(ctx context.Context, client Client, tlsConfigs map[string]*tls.CertAndStores) *config.TCPConfiguration {
|
||||
conf := &config.TCPConfiguration{
|
||||
Routers: map[string]*config.TCPRouter{},
|
||||
Services: map[string]*config.TCPService{},
|
||||
func (p *Provider) loadIngressRouteTCPConfiguration(ctx context.Context, client Client, tlsConfigs map[string]*tls.CertAndStores) *dynamic.TCPConfiguration {
|
||||
conf := &dynamic.TCPConfiguration{
|
||||
Routers: map[string]*dynamic.TCPRouter{},
|
||||
Services: map[string]*dynamic.TCPService{},
|
||||
}
|
||||
|
||||
for _, ingressRouteTCP := range client.GetIngressRouteTCPs() {
|
||||
|
@ -508,7 +508,7 @@ func (p *Provider) loadIngressRouteTCPConfiguration(ctx context.Context, client
|
|||
continue
|
||||
}
|
||||
|
||||
var allServers []config.TCPServer
|
||||
var allServers []dynamic.TCPServer
|
||||
for _, service := range route.Services {
|
||||
servers, err := loadTCPServers(client, ingressRouteTCP.Namespace, service)
|
||||
if err != nil {
|
||||
|
@ -529,14 +529,14 @@ func (p *Provider) loadIngressRouteTCPConfiguration(ctx context.Context, client
|
|||
}
|
||||
|
||||
serviceName := makeID(ingressRouteTCP.Namespace, key)
|
||||
conf.Routers[serviceName] = &config.TCPRouter{
|
||||
conf.Routers[serviceName] = &dynamic.TCPRouter{
|
||||
EntryPoints: ingressRouteTCP.Spec.EntryPoints,
|
||||
Rule: route.Match,
|
||||
Service: serviceName,
|
||||
}
|
||||
|
||||
if ingressRouteTCP.Spec.TLS != nil {
|
||||
conf.Routers[serviceName].TLS = &config.RouterTCPTLSConfig{
|
||||
conf.Routers[serviceName].TLS = &dynamic.RouterTCPTLSConfig{
|
||||
Passthrough: ingressRouteTCP.Spec.TLS.Passthrough,
|
||||
}
|
||||
|
||||
|
@ -560,8 +560,8 @@ func (p *Provider) loadIngressRouteTCPConfiguration(ctx context.Context, client
|
|||
}
|
||||
}
|
||||
|
||||
conf.Services[serviceName] = &config.TCPService{
|
||||
LoadBalancer: &config.TCPLoadBalancerService{
|
||||
conf.Services[serviceName] = &dynamic.TCPService{
|
||||
LoadBalancer: &dynamic.TCPLoadBalancerService{
|
||||
Servers: allServers,
|
||||
},
|
||||
}
|
||||
|
@ -571,12 +571,12 @@ func (p *Provider) loadIngressRouteTCPConfiguration(ctx context.Context, client
|
|||
return conf
|
||||
}
|
||||
|
||||
func (p *Provider) loadConfigurationFromCRD(ctx context.Context, client Client) *config.Configuration {
|
||||
func (p *Provider) loadConfigurationFromCRD(ctx context.Context, client Client) *dynamic.Configuration {
|
||||
tlsConfigs := make(map[string]*tls.CertAndStores)
|
||||
conf := &config.Configuration{
|
||||
conf := &dynamic.Configuration{
|
||||
HTTP: p.loadIngressRouteConfiguration(ctx, client, tlsConfigs),
|
||||
TCP: p.loadIngressRouteTCPConfiguration(ctx, client, tlsConfigs),
|
||||
TLS: &config.TLSConfiguration{
|
||||
TLS: &dynamic.TLSConfiguration{
|
||||
Certificates: getTLSConfig(tlsConfigs),
|
||||
Options: buildTLSOptions(ctx, client),
|
||||
},
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,7 +1,7 @@
|
|||
package v1alpha1
|
||||
|
||||
import (
|
||||
"github.com/containous/traefik/pkg/config"
|
||||
"github.com/containous/traefik/pkg/config/dynamic"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
|
@ -13,7 +13,7 @@ type Middleware struct {
|
|||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata"`
|
||||
|
||||
Spec config.Middleware `json:"spec"`
|
||||
Spec dynamic.Middleware `json:"spec"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/cenkalti/backoff"
|
||||
"github.com/containous/traefik/pkg/config"
|
||||
"github.com/containous/traefik/pkg/config/dynamic"
|
||||
"github.com/containous/traefik/pkg/job"
|
||||
"github.com/containous/traefik/pkg/log"
|
||||
"github.com/containous/traefik/pkg/safe"
|
||||
|
@ -92,7 +92,7 @@ func (p *Provider) Init() error {
|
|||
|
||||
// Provide allows the k8s provider to provide configurations to traefik
|
||||
// using the given configuration channel.
|
||||
func (p *Provider) Provide(configurationChan chan<- config.Message, pool *safe.Pool) error {
|
||||
func (p *Provider) Provide(configurationChan chan<- dynamic.Message, pool *safe.Pool) error {
|
||||
ctxLog := log.With(context.Background(), log.Str(log.ProviderName, "kubernetes"))
|
||||
logger := log.FromContext(ctxLog)
|
||||
// Tell glog (used by client-go) to log into STDERR. Otherwise, we risk
|
||||
|
@ -138,7 +138,7 @@ func (p *Provider) Provide(configurationChan chan<- config.Message, pool *safe.P
|
|||
logger.Debugf("Skipping Kubernetes event kind %T", event)
|
||||
} else {
|
||||
p.lastConfiguration.Set(conf)
|
||||
configurationChan <- config.Message{
|
||||
configurationChan <- dynamic.Message{
|
||||
ProviderName: "kubernetes",
|
||||
Configuration: conf,
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ func checkStringQuoteValidity(value string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
func loadService(client Client, namespace string, backend v1beta1.IngressBackend) (*config.Service, error) {
|
||||
func loadService(client Client, namespace string, backend v1beta1.IngressBackend) (*dynamic.Service, error) {
|
||||
service, exists, err := client.GetService(namespace, backend.ServiceName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -174,7 +174,7 @@ func loadService(client Client, namespace string, backend v1beta1.IngressBackend
|
|||
return nil, errors.New("service not found")
|
||||
}
|
||||
|
||||
var servers []config.Server
|
||||
var servers []dynamic.Server
|
||||
var portName string
|
||||
var portSpec corev1.ServicePort
|
||||
var match bool
|
||||
|
@ -193,7 +193,7 @@ func loadService(client Client, namespace string, backend v1beta1.IngressBackend
|
|||
}
|
||||
|
||||
if service.Spec.Type == corev1.ServiceTypeExternalName {
|
||||
servers = append(servers, config.Server{
|
||||
servers = append(servers, dynamic.Server{
|
||||
URL: fmt.Sprintf("http://%s:%d", service.Spec.ExternalName, portSpec.Port),
|
||||
})
|
||||
} else {
|
||||
|
@ -230,29 +230,29 @@ func loadService(client Client, namespace string, backend v1beta1.IngressBackend
|
|||
}
|
||||
|
||||
for _, addr := range subset.Addresses {
|
||||
servers = append(servers, config.Server{
|
||||
servers = append(servers, dynamic.Server{
|
||||
URL: fmt.Sprintf("%s://%s:%d", protocol, addr.IP, port),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return &config.Service{
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
return &dynamic.Service{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
Servers: servers,
|
||||
PassHostHeader: true,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (p *Provider) loadConfigurationFromIngresses(ctx context.Context, client Client) *config.Configuration {
|
||||
conf := &config.Configuration{
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Routers: map[string]*config.Router{},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Services: map[string]*config.Service{},
|
||||
func (p *Provider) loadConfigurationFromIngresses(ctx context.Context, client Client) *dynamic.Configuration {
|
||||
conf := &dynamic.Configuration{
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Routers: map[string]*dynamic.Router{},
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Services: map[string]*dynamic.Service{},
|
||||
},
|
||||
TCP: &config.TCPConfiguration{},
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
}
|
||||
|
||||
ingresses := client.GetIngresses()
|
||||
|
@ -286,7 +286,7 @@ func (p *Provider) loadConfigurationFromIngresses(ctx context.Context, client Cl
|
|||
continue
|
||||
}
|
||||
|
||||
conf.HTTP.Routers["/"] = &config.Router{
|
||||
conf.HTTP.Routers["/"] = &dynamic.Router{
|
||||
Rule: "PathPrefix(`/`)",
|
||||
Priority: math.MinInt32,
|
||||
Service: "default-backend",
|
||||
|
@ -327,7 +327,7 @@ func (p *Provider) loadConfigurationFromIngresses(ctx context.Context, client Cl
|
|||
rules = append(rules, "PathPrefix(`"+p.Path+"`)")
|
||||
}
|
||||
|
||||
conf.HTTP.Routers[strings.Replace(rule.Host, ".", "-", -1)+p.Path] = &config.Router{
|
||||
conf.HTTP.Routers[strings.Replace(rule.Host, ".", "-", -1)+p.Path] = &dynamic.Router{
|
||||
Rule: strings.Join(rules, " && "),
|
||||
Service: serviceName,
|
||||
}
|
||||
|
@ -343,7 +343,7 @@ func (p *Provider) loadConfigurationFromIngresses(ctx context.Context, client Cl
|
|||
|
||||
certs := getTLSConfig(tlsConfigs)
|
||||
if len(certs) > 0 {
|
||||
conf.TLS = &config.TLSConfiguration{
|
||||
conf.TLS = &dynamic.TLSConfiguration{
|
||||
Certificates: certs,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/containous/traefik/pkg/config"
|
||||
"github.com/containous/traefik/pkg/config/dynamic"
|
||||
"github.com/containous/traefik/pkg/provider"
|
||||
"github.com/containous/traefik/pkg/tls"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -23,36 +23,36 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
testCases := []struct {
|
||||
desc string
|
||||
ingressClass string
|
||||
expected *config.Configuration
|
||||
expected *dynamic.Configuration
|
||||
}{
|
||||
{
|
||||
desc: "Empty ingresses",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Routers: map[string]*config.Router{},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Services: map[string]*config.Service{},
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Routers: map[string]*dynamic.Router{},
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Services: map[string]*dynamic.Service{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "Ingress with a basic rule on one path",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"/bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/80",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/80": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
},
|
||||
|
@ -68,11 +68,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress with two different rules with one path",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"/bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/80",
|
||||
|
@ -82,11 +82,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Service: "testing/service1/80",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/80": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
},
|
||||
|
@ -102,11 +102,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress one rule with two paths",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"/bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/80",
|
||||
|
@ -116,11 +116,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Service: "testing/service1/80",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/80": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
},
|
||||
|
@ -136,21 +136,21 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress one rule with one path and one host",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"traefik-tchouk/bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/80",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/80": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
},
|
||||
|
@ -165,21 +165,21 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
}, {
|
||||
desc: "Ingress with one host without path",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"example-com": {
|
||||
Rule: "Host(`example.com`)",
|
||||
Service: "testing/example-com/80",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/example-com/80": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.11.0.1:80",
|
||||
},
|
||||
|
@ -192,11 +192,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress one rule with one host and two paths",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"traefik-tchouk/bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/80",
|
||||
|
@ -206,11 +206,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Service: "testing/service1/80",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/80": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
},
|
||||
|
@ -226,11 +226,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress Two rules with one host and one path",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"traefik-tchouk/bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/80",
|
||||
|
@ -240,11 +240,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Service: "testing/service1/80",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/80": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
},
|
||||
|
@ -260,11 +260,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress with a bad path syntax",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"/bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/80",
|
||||
|
@ -274,11 +274,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Service: "testing/service1/80",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/80": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
},
|
||||
|
@ -294,32 +294,32 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress with only a bad path syntax",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{},
|
||||
Services: map[string]*config.Service{},
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{},
|
||||
Services: map[string]*dynamic.Service{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "Ingress with a bad host syntax",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"traefik-courgette/carotte": {
|
||||
Rule: "Host(`traefik.courgette`) && PathPrefix(`/carotte`)",
|
||||
Service: "testing/service1/80",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/80": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
},
|
||||
|
@ -335,22 +335,22 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress with only a bad host syntax",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{},
|
||||
Services: map[string]*config.Service{},
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{},
|
||||
Services: map[string]*dynamic.Service{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "Ingress with two services",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"traefik-tchouk/bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/80",
|
||||
|
@ -360,11 +360,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Service: "testing/service2/8082",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/80": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
},
|
||||
|
@ -375,9 +375,9 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
},
|
||||
"testing/service2/8082": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.2:8080",
|
||||
},
|
||||
|
@ -393,44 +393,44 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress with one service without endpoints subset",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{},
|
||||
Services: map[string]*config.Service{},
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{},
|
||||
Services: map[string]*dynamic.Service{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "Ingress with one service without endpoint",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{},
|
||||
Services: map[string]*config.Service{},
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{},
|
||||
Services: map[string]*dynamic.Service{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "Single Service Ingress (without any rules)",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"/": {
|
||||
Rule: "PathPrefix(`/`)",
|
||||
Service: "default-backend",
|
||||
Priority: math.MinInt32,
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"default-backend": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
},
|
||||
|
@ -446,21 +446,21 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress with port value in backend and no pod replica",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"traefik-tchouk/bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/80",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/80": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8089",
|
||||
},
|
||||
|
@ -476,21 +476,21 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress with port name in backend and no pod replica",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"traefik-tchouk/bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/tchouk",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/tchouk": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8089",
|
||||
},
|
||||
|
@ -506,21 +506,21 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress with with port name in backend and 2 pod replica",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"traefik-tchouk/bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/tchouk",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/tchouk": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8089",
|
||||
},
|
||||
|
@ -536,11 +536,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress with two paths using same service and different port name",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"traefik-tchouk/bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/tchouk",
|
||||
|
@ -550,11 +550,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Service: "testing/service1/carotte",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/tchouk": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8089",
|
||||
},
|
||||
|
@ -565,9 +565,9 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
},
|
||||
"testing/service1/carotte": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8090",
|
||||
},
|
||||
|
@ -583,11 +583,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "2 ingresses in different namespace with same service name",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"traefik-tchouk/bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/tchouk",
|
||||
|
@ -597,11 +597,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Service: "toto/service1/tchouk",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/tchouk": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8089",
|
||||
},
|
||||
|
@ -612,9 +612,9 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
},
|
||||
"toto/service1/tchouk": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.11.0.1:8089",
|
||||
},
|
||||
|
@ -630,43 +630,43 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress with unknown service port name",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{},
|
||||
Services: map[string]*config.Service{},
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{},
|
||||
Services: map[string]*dynamic.Service{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "Ingress with unknown service port",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{},
|
||||
Services: map[string]*config.Service{},
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{},
|
||||
Services: map[string]*dynamic.Service{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "Ingress with service with externalName",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"traefik-tchouk/bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/8080",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/8080": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://traefik.wtf:8080",
|
||||
},
|
||||
|
@ -679,21 +679,21 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "TLS support",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"example-com": {
|
||||
Rule: "Host(`example.com`)",
|
||||
Service: "testing/example-com/80",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/example-com/80": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.11.0.1:80",
|
||||
},
|
||||
|
@ -702,7 +702,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
TLS: &config.TLSConfiguration{
|
||||
TLS: &dynamic.TLSConfiguration{
|
||||
Certificates: []*tls.CertAndStores{
|
||||
{
|
||||
Certificate: tls.Certificate{
|
||||
|
@ -716,21 +716,21 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress with a basic rule on one path with https (port == 443)",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"/bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/443",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/443": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "https://10.10.0.1:443",
|
||||
},
|
||||
|
@ -746,21 +746,21 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress with a basic rule on one path with https (portname == https)",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"/bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/8443",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/8443": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "https://10.10.0.1:8443",
|
||||
},
|
||||
|
@ -776,22 +776,22 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress with a basic rule on one path with https (portname starts with https)",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
|
||||
Routers: map[string]*config.Router{
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"/bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/8443",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/8443": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "https://10.10.0.1:8443",
|
||||
},
|
||||
|
@ -807,22 +807,22 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Double Single Service Ingress",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"/": {
|
||||
Rule: "PathPrefix(`/`)",
|
||||
Service: "default-backend",
|
||||
Priority: math.MinInt32,
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"default-backend": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.30.0.1:8080",
|
||||
},
|
||||
|
@ -838,21 +838,21 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress with default traefik ingressClass",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"/bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/80",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/80": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
},
|
||||
|
@ -865,48 +865,48 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress without provider traefik ingressClass and unknown annotation",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{},
|
||||
Services: map[string]*config.Service{},
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{},
|
||||
Services: map[string]*dynamic.Service{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "Ingress with non matching provider traefik ingressClass and annotation",
|
||||
ingressClass: "tchouk",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{},
|
||||
Services: map[string]*config.Service{},
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{},
|
||||
Services: map[string]*dynamic.Service{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "Ingress with ingressClass without annotation",
|
||||
ingressClass: "tchouk",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{},
|
||||
Services: map[string]*config.Service{},
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{},
|
||||
Services: map[string]*dynamic.Service{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "Ingress with ingressClass without annotation",
|
||||
ingressClass: "toto",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{},
|
||||
Services: map[string]*config.Service{},
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{},
|
||||
Services: map[string]*dynamic.Service{},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue