2019-03-14 14:56:06 +00:00
|
|
|
package crd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2021-03-04 19:08:03 +00:00
|
|
|
"os"
|
2020-12-10 13:58:04 +00:00
|
|
|
"path/filepath"
|
2021-09-14 13:16:11 +00:00
|
|
|
"strings"
|
2019-03-14 14:56:06 +00:00
|
|
|
"testing"
|
2020-09-11 13:40:03 +00:00
|
|
|
"time"
|
2019-03-14 14:56:06 +00:00
|
|
|
|
2021-09-14 13:16:11 +00:00
|
|
|
auth "github.com/abbot/go-http-auth"
|
2019-03-14 14:56:06 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
2020-12-10 13:58:04 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2021-10-26 08:54:11 +00:00
|
|
|
ptypes "github.com/traefik/paerser/types"
|
2023-02-03 14:24:05 +00:00
|
|
|
"github.com/traefik/traefik/v3/pkg/config/dynamic"
|
|
|
|
"github.com/traefik/traefik/v3/pkg/provider"
|
2023-04-17 08:56:36 +00:00
|
|
|
traefikcrdfake "github.com/traefik/traefik/v3/pkg/provider/kubernetes/crd/generated/clientset/versioned/fake"
|
|
|
|
traefikv1alpha1 "github.com/traefik/traefik/v3/pkg/provider/kubernetes/crd/traefikio/v1alpha1"
|
2023-02-03 14:24:05 +00:00
|
|
|
"github.com/traefik/traefik/v3/pkg/provider/kubernetes/k8s"
|
|
|
|
"github.com/traefik/traefik/v3/pkg/tls"
|
|
|
|
"github.com/traefik/traefik/v3/pkg/types"
|
2020-08-21 09:12:04 +00:00
|
|
|
corev1 "k8s.io/api/core/v1"
|
2020-12-10 13:58:04 +00:00
|
|
|
"k8s.io/apimachinery/pkg/runtime"
|
2021-01-15 14:54:04 +00:00
|
|
|
"k8s.io/apimachinery/pkg/util/intstr"
|
2020-12-10 13:58:04 +00:00
|
|
|
kubefake "k8s.io/client-go/kubernetes/fake"
|
2019-03-14 14:56:06 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var _ provider.Provider = (*Provider)(nil)
|
|
|
|
|
2019-09-30 16:12:04 +00:00
|
|
|
func Int(v int) *int { return &v }
|
|
|
|
func Bool(v bool) *bool { return &v }
|
2019-08-26 08:30:05 +00:00
|
|
|
|
2019-06-11 13:12:04 +00:00
|
|
|
func TestLoadIngressRouteTCPs(t *testing.T) {
|
|
|
|
testCases := []struct {
|
2022-03-07 10:08:07 +00:00
|
|
|
desc string
|
|
|
|
ingressClass string
|
|
|
|
paths []string
|
|
|
|
allowEmptyServices bool
|
|
|
|
expected *dynamic.Configuration
|
2019-06-11 13:12:04 +00:00
|
|
|
}{
|
|
|
|
{
|
|
|
|
desc: "Empty",
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple Ingress Route, with foo entrypoint",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/simple.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-07-10 07:26:04 +00:00
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-06-11 13:12:04 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
2019-06-11 13:12:04 +00:00
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-06-11 13:30:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple Ingress Route, with foo entrypoint and middleware",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_middleware.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-06-11 13:30:05 +00:00
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
2022-10-26 15:16:05 +00:00
|
|
|
Middlewares: []string{"default-ipallowlist", "foo-ipallowlist"},
|
2021-06-11 13:30:05 +00:00
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{
|
2022-10-26 15:16:05 +00:00
|
|
|
"default-ipallowlist": {
|
|
|
|
IPAllowList: &dynamic.TCPIPAllowList{
|
2021-06-11 13:30:05 +00:00
|
|
|
SourceRange: []string{"127.0.0.1/32"},
|
|
|
|
},
|
|
|
|
},
|
2022-10-26 15:16:05 +00:00
|
|
|
"foo-ipallowlist": {
|
|
|
|
IPAllowList: &dynamic.TCPIPAllowList{
|
2021-06-11 13:30:05 +00:00
|
|
|
SourceRange: []string{"127.0.0.1/32"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.TCPService{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-06-11 13:30:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2021-10-07 13:40:05 +00:00
|
|
|
{
|
|
|
|
desc: "Middlewares in ingress route config are normalized",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_middleware_multiple_hyphens.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
|
|
|
Middlewares: []string{"default-multiple-hyphens"},
|
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{
|
|
|
|
"default-multiple-hyphens": {
|
2022-10-26 15:16:05 +00:00
|
|
|
IPAllowList: &dynamic.TCPIPAllowList{
|
2021-10-07 13:40:05 +00:00
|
|
|
SourceRange: []string{"127.0.0.1/32"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.TCPService{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-10-07 13:40:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
{
|
|
|
|
desc: "Simple Ingress Route, with foo entrypoint and crossprovider middleware",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_middleware_crossprovider.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-06-11 13:30:05 +00:00
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
2022-10-26 15:16:05 +00:00
|
|
|
Middlewares: []string{"default-ipallowlist", "foo-ipallowlist", "ipallowlist@file", "ipallowlist-foo@file"},
|
2021-06-11 13:30:05 +00:00
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{
|
2022-10-26 15:16:05 +00:00
|
|
|
"default-ipallowlist": {
|
|
|
|
IPAllowList: &dynamic.TCPIPAllowList{
|
2021-06-11 13:30:05 +00:00
|
|
|
SourceRange: []string{"127.0.0.1/32"},
|
|
|
|
},
|
|
|
|
},
|
2022-10-26 15:16:05 +00:00
|
|
|
"foo-ipallowlist": {
|
|
|
|
IPAllowList: &dynamic.TCPIPAllowList{
|
2021-06-11 13:30:05 +00:00
|
|
|
SourceRange: []string{"127.0.0.1/32"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-06-11 13:12:04 +00:00
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "One ingress Route with two different rules",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_two_rules.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-06-11 13:12:04 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
2019-06-11 13:12:04 +00:00
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
},
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-f44ce589164e656d231c": {
|
2019-06-11 13:12:04 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-f44ce589164e656d231c",
|
2019-06-11 13:12:04 +00:00
|
|
|
Rule: "HostSNI(`bar.com`)",
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-06-11 13:12:04 +00:00
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-f44ce589164e656d231c": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-06-11 13:12:04 +00:00
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
2020-02-26 11:28:05 +00:00
|
|
|
{
|
|
|
|
desc: "One ingress Route with two identical rules",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_two_identical_rules.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2020-02-26 11:28:05 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-02-26 11:28:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-02-26 11:28:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2019-06-11 13:12:04 +00:00
|
|
|
{
|
2019-09-13 18:00:06 +00:00
|
|
|
desc: "One ingress Route with two different services",
|
2019-06-11 13:12:04 +00:00
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_two_services.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-06-11 13:12:04 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
2019-06-11 13:12:04 +00:00
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-09-13 18:00:06 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
2019-09-13 18:44:04 +00:00
|
|
|
Name: "default-test.route-fdd3e9338e47a45efefc-whoamitcp-8000",
|
2019-09-13 18:00:06 +00:00
|
|
|
Weight: func(i int) *int { return &i }(2),
|
|
|
|
},
|
|
|
|
{
|
2019-09-13 18:44:04 +00:00
|
|
|
Name: "default-test.route-fdd3e9338e47a45efefc-whoamitcp2-8080",
|
2019-09-13 18:00:06 +00:00
|
|
|
Weight: func(i int) *int { return &i }(3),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc-whoamitcp-8000": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-06-11 13:12:04 +00:00
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
2019-09-13 18:00:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc-whoamitcp2-8080": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
2019-06-11 13:12:04 +00:00
|
|
|
{
|
|
|
|
Address: "10.10.0.3:8080",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.4:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-09-13 18:00:06 +00:00
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
2020-01-14 11:14:05 +00:00
|
|
|
{
|
|
|
|
desc: "One ingress Route with different services namespaces",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_different_services_ns.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2020-01-14 11:14:05 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2020-01-14 11:14:05 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-test.route-fdd3e9338e47a45efefc-whoamitcp-8000",
|
|
|
|
Weight: func(i int) *int { return &i }(2),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "default-test.route-fdd3e9338e47a45efefc-whoamitcp2-8080",
|
|
|
|
Weight: func(i int) *int { return &i }(3),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "default-test.route-fdd3e9338e47a45efefc-whoamitcp3-8083",
|
|
|
|
Weight: func(i int) *int { return &i }(4),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc-whoamitcp-8000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc-whoamitcp2-8080": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.3:8080",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.4:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc-whoamitcp3-8083": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.7:8083",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.8:8083",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-01-14 11:14:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-01-14 11:14:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2019-06-11 13:12:04 +00:00
|
|
|
{
|
|
|
|
desc: "Ingress class does not match",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/simple.yml"},
|
|
|
|
ingressClass: "tchouk",
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Route with empty rule value is ignored",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_no_rule_value.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TLS",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_tls.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
2019-06-27 21:58:03 +00:00
|
|
|
Certificates: []*tls.CertAndStores{
|
|
|
|
{
|
|
|
|
Certificate: tls.Certificate{
|
2024-01-11 16:06:06 +00:00
|
|
|
CertFile: types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
KeyFile: types.FileOrContent("-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----"),
|
2019-06-27 21:58:03 +00:00
|
|
|
},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-06-11 13:12:04 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
2019-06-11 13:12:04 +00:00
|
|
|
Rule: "HostSNI(`foo.com`)",
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-06-11 13:12:04 +00:00
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TLS with passthrough",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_tls_passthrough.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-06-11 13:12:04 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
2019-06-11 13:12:04 +00:00
|
|
|
Rule: "HostSNI(`foo.com`)",
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
2019-06-11 13:12:04 +00:00
|
|
|
Passthrough: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-06-11 13:12:04 +00:00
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
2019-06-21 15:18:05 +00:00
|
|
|
{
|
|
|
|
desc: "TLS with tls options",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_tls_options.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
2019-06-27 21:58:03 +00:00
|
|
|
Options: map[string]tls.Options{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-foo": {
|
2019-06-27 21:58:03 +00:00
|
|
|
MinVersion: "VersionTLS12",
|
|
|
|
CipherSuites: []string{
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
"TLS_RSA_WITH_AES_256_GCM_SHA384",
|
|
|
|
},
|
2019-07-12 15:50:04 +00:00
|
|
|
ClientAuth: tls.ClientAuth{
|
2024-01-11 16:06:06 +00:00
|
|
|
CAFiles: []types.FileOrContent{
|
|
|
|
types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
2019-06-27 21:58:03 +00:00
|
|
|
},
|
2019-07-12 15:50:04 +00:00
|
|
|
ClientAuthType: "VerifyClientCertIfGiven",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
2022-08-09 15:36:08 +00:00
|
|
|
SniStrict: true,
|
2021-08-20 16:20:06 +00:00
|
|
|
ALPNProtocols: []string{
|
|
|
|
"h2",
|
|
|
|
"http/1.1",
|
|
|
|
"acme-tls/1",
|
|
|
|
},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-06-21 15:18:05 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
2019-06-21 15:18:05 +00:00
|
|
|
Rule: "HostSNI(`foo.com`)",
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
2019-09-13 18:44:04 +00:00
|
|
|
Options: "default-foo",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-06-21 15:18:05 +00:00
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TLS with tls options and specific namespace",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_tls_options_and_specific_namespace.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
2019-06-27 21:58:03 +00:00
|
|
|
Options: map[string]tls.Options{
|
2019-09-13 18:44:04 +00:00
|
|
|
"myns-foo": {
|
2019-06-27 21:58:03 +00:00
|
|
|
MinVersion: "VersionTLS12",
|
|
|
|
CipherSuites: []string{
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
"TLS_RSA_WITH_AES_256_GCM_SHA384",
|
|
|
|
},
|
2019-07-12 15:50:04 +00:00
|
|
|
ClientAuth: tls.ClientAuth{
|
2024-01-11 16:06:06 +00:00
|
|
|
CAFiles: []types.FileOrContent{
|
|
|
|
types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
2019-06-27 21:58:03 +00:00
|
|
|
},
|
2019-07-12 15:50:04 +00:00
|
|
|
ClientAuthType: "VerifyClientCertIfGiven",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
2019-06-27 21:58:03 +00:00
|
|
|
SniStrict: true,
|
2021-08-20 16:20:06 +00:00
|
|
|
ALPNProtocols: []string{
|
|
|
|
"h2",
|
|
|
|
"http/1.1",
|
|
|
|
"acme-tls/1",
|
|
|
|
},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-06-21 15:18:05 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
2019-06-21 15:18:05 +00:00
|
|
|
Rule: "HostSNI(`foo.com`)",
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
2019-09-13 18:44:04 +00:00
|
|
|
Options: "myns-foo",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-06-21 15:18:05 +00:00
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TLS with bad tls options",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_bad_tls_options.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
2019-06-27 21:58:03 +00:00
|
|
|
Options: map[string]tls.Options{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-foo": {
|
2019-06-27 21:58:03 +00:00
|
|
|
MinVersion: "VersionTLS12",
|
|
|
|
CipherSuites: []string{
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
"TLS_RSA_WITH_AES_256_GCM_SHA384",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
2019-07-12 15:50:04 +00:00
|
|
|
ClientAuth: tls.ClientAuth{
|
2024-01-11 16:06:06 +00:00
|
|
|
CAFiles: []types.FileOrContent{
|
|
|
|
types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
2019-06-27 21:58:03 +00:00
|
|
|
},
|
2019-07-12 15:50:04 +00:00
|
|
|
ClientAuthType: "VerifyClientCertIfGiven",
|
2019-06-27 21:58:03 +00:00
|
|
|
},
|
|
|
|
SniStrict: true,
|
2021-08-20 16:20:06 +00:00
|
|
|
ALPNProtocols: []string{
|
|
|
|
"h2",
|
|
|
|
"http/1.1",
|
|
|
|
"acme-tls/1",
|
|
|
|
},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-06-21 15:18:05 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
2019-06-21 15:18:05 +00:00
|
|
|
Rule: "HostSNI(`foo.com`)",
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
2019-09-13 18:44:04 +00:00
|
|
|
Options: "default-foo",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-06-21 15:18:05 +00:00
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TLS with unknown tls options",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_unknown_tls_options.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
2019-06-27 21:58:03 +00:00
|
|
|
Options: map[string]tls.Options{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-foo": {
|
2019-06-27 21:58:03 +00:00
|
|
|
MinVersion: "VersionTLS12",
|
2021-08-20 16:20:06 +00:00
|
|
|
ALPNProtocols: []string{
|
|
|
|
"h2",
|
|
|
|
"http/1.1",
|
|
|
|
"acme-tls/1",
|
|
|
|
},
|
2019-06-27 21:58:03 +00:00
|
|
|
},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-06-21 15:18:05 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
2019-06-21 15:18:05 +00:00
|
|
|
Rule: "HostSNI(`foo.com`)",
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
2019-09-13 18:44:04 +00:00
|
|
|
Options: "default-unknown",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-06-21 15:18:05 +00:00
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TLS with unknown tls options namespace",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_unknown_tls_options_namespace.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
2019-06-27 21:58:03 +00:00
|
|
|
Options: map[string]tls.Options{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-foo": {
|
2019-06-27 21:58:03 +00:00
|
|
|
MinVersion: "VersionTLS12",
|
2021-08-20 16:20:06 +00:00
|
|
|
ALPNProtocols: []string{
|
|
|
|
"h2",
|
|
|
|
"http/1.1",
|
|
|
|
"acme-tls/1",
|
|
|
|
},
|
2019-06-27 21:58:03 +00:00
|
|
|
},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-06-21 15:18:05 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
2019-06-21 15:18:05 +00:00
|
|
|
Rule: "HostSNI(`foo.com`)",
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
2019-09-13 18:44:04 +00:00
|
|
|
Options: "unknown-foo",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-06-21 15:18:05 +00:00
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-06-11 13:12:04 +00:00
|
|
|
{
|
|
|
|
desc: "TLS with ACME",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_tls_acme.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-06-11 13:12:04 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
2019-06-11 13:12:04 +00:00
|
|
|
Rule: "HostSNI(`foo.com`)",
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-06-11 13:12:04 +00:00
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-13 18:00:06 +00:00
|
|
|
{
|
|
|
|
desc: "TCP with terminationDelay",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_termination_delay.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-09-13 18:00:06 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-09-13 18:00:06 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
2019-09-13 18:00:06 +00:00
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2019-09-13 18:00:06 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-09-13 18:00:06 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-09-13 18:00:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-02-24 16:14:06 +00:00
|
|
|
{
|
|
|
|
desc: "TLS with tls Store",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_tls_store.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{
|
|
|
|
"default": {
|
|
|
|
DefaultCertificate: &tls.Certificate{
|
2024-01-11 16:06:06 +00:00
|
|
|
CertFile: types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
KeyFile: types.FileOrContent("-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----"),
|
2020-02-24 16:14:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{},
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2020-02-24 16:14:06 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-02-24 16:14:06 +00:00
|
|
|
},
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2020-02-24 16:14:06 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-02-24 16:14:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-03-10 11:46:05 +00:00
|
|
|
{
|
|
|
|
desc: "Simple Ingress Route, with externalName service",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_externalname.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2020-03-10 11:46:05 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "external.domain:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-03-10 11:46:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-03-10 11:46:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Ingress Route, externalName service with port",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_externalname_with_port.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2020-03-10 11:46:05 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "external.domain:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-03-10 11:46:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-03-10 11:46:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Ingress Route, externalName service without port",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_externalname_without_ports.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
// The router that references the invalid service will be discarded.
|
2020-03-10 11:46:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-03-10 11:46:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-03-10 11:46:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2020-12-04 19:56:04 +00:00
|
|
|
{
|
|
|
|
desc: "Ingress Route with IPv6 backends",
|
|
|
|
paths: []string{
|
|
|
|
"services.yml", "with_ipv6.yml",
|
|
|
|
"tcp/services.yml", "tcp/with_ipv6.yml",
|
|
|
|
"udp/services.yml", "udp/with_ipv6.yml",
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{
|
|
|
|
"default-test.route-0": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-0",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.UDPService{
|
|
|
|
"default-test.route-0": {
|
|
|
|
LoadBalancer: &dynamic.UDPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.UDPServer{
|
|
|
|
{
|
|
|
|
Address: "[fd00:10:244:0:1::3]:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"default-test.route-673acf455cb2dab0b43a": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-673acf455cb2dab0b43a",
|
|
|
|
Rule: "HostSNI(`*`)",
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2020-12-04 19:56:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
|
|
|
"default-test.route-673acf455cb2dab0b43a": {
|
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-test.route-673acf455cb2dab0b43a-whoamitcp-ipv6-8080",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "default-test.route-673acf455cb2dab0b43a-external.service.with.ipv6-8080",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-test.route-673acf455cb2dab0b43a-whoamitcp-ipv6-8080": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "[fd00:10:244:0:1::3]:8080",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "[2001:db8:85a3:8d3:1319:8a2e:370:7348]:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-test.route-673acf455cb2dab0b43a-external.service.with.ipv6-8080": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "[fe80::200:5aee:feaa:20a2]:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-12-04 19:56:04 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test-route-6b204d94623b3df4370c",
|
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-whoami-ipv6-8080": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://[2001:db8:85a3:8d3:1319:8a2e:370:7348]:8080",
|
|
|
|
},
|
|
|
|
},
|
2022-11-16 10:38:07 +00:00
|
|
|
PassHostHeader: Bool(true),
|
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2020-12-04 19:56:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-external-svc-with-ipv6-8080": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://[2001:db8:85a3:8d3:1319:8a2e:370:7347]:8080",
|
|
|
|
},
|
|
|
|
},
|
2022-11-16 10:38:07 +00:00
|
|
|
PassHostHeader: Bool(true),
|
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2020-12-04 19:56:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-ipv6-8080",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "default-external-svc-with-ipv6-8080",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-12-04 19:56:04 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
{
|
|
|
|
desc: "TCP with proxyProtocol Version",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_proxyprotocol.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ProxyProtocol: &dynamic.ProxyProtocol{Version: 2},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TCP with ServersTransport",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_servers_transport.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{
|
|
|
|
"foo-test": {
|
|
|
|
TLS: &dynamic.TLSClientConfig{
|
|
|
|
ServerName: "test",
|
|
|
|
InsecureSkipVerify: true,
|
2024-01-11 16:06:06 +00:00
|
|
|
RootCAs: []types.FileOrContent{"TESTROOTCAS0", "TESTROOTCAS1", "TESTROOTCAS2", "TESTROOTCAS3", "TESTROOTCAS5", "TESTALLCERTS"},
|
2022-12-09 08:58:05 +00:00
|
|
|
Certificates: tls.Certificates{
|
|
|
|
{CertFile: "TESTCERT1", KeyFile: "TESTKEY1"},
|
|
|
|
{CertFile: "TESTCERT2", KeyFile: "TESTKEY2"},
|
|
|
|
{CertFile: "TESTCERT3", KeyFile: "TESTKEY3"},
|
|
|
|
},
|
|
|
|
PeerCertURI: "foo://bar",
|
|
|
|
Spiffe: &dynamic.Spiffe{
|
|
|
|
IDs: []string{
|
|
|
|
"spiffe://foo/buz",
|
|
|
|
"spiffe://bar/biz",
|
|
|
|
},
|
|
|
|
TrustDomain: "spiffe://lol",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
DialTimeout: ptypes.Duration(42 * time.Second),
|
|
|
|
DialKeepAlive: ptypes.Duration(42 * time.Second),
|
|
|
|
TerminationDelay: ptypes.Duration(42 * time.Second),
|
|
|
|
},
|
|
|
|
"default-test": {
|
|
|
|
TLS: &dynamic.TLSClientConfig{
|
|
|
|
ServerName: "test",
|
|
|
|
},
|
|
|
|
DialTimeout: ptypes.Duration(30 * time.Second),
|
|
|
|
DialKeepAlive: ptypes.Duration(15 * time.Second),
|
|
|
|
TerminationDelay: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc-whoamitcp-8000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransport: "default-test",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc-whoamitcp2-8080": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.3:8080",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.4:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransport: "default-default-test",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-test.route-fdd3e9338e47a45efefc-whoamitcp-8000",
|
|
|
|
Weight: Int(1),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "default-test.route-fdd3e9338e47a45efefc-whoamitcp2-8080",
|
|
|
|
Weight: Int(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-06-11 13:30:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-03-07 10:08:07 +00:00
|
|
|
{
|
|
|
|
desc: "Ingress Route, empty service disallowed",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_empty_services.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
// The router that references the invalid service will be discarded.
|
2022-03-07 10:08:07 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2022-03-07 10:08:07 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Ingress Route, empty service allowed",
|
|
|
|
allowEmptyServices: true,
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_empty_services.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2022-03-07 10:08:07 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2019-06-11 13:12:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
test := test
|
2019-06-21 15:18:05 +00:00
|
|
|
|
2019-06-11 13:12:04 +00:00
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
if test.expected == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-03-07 10:08:07 +00:00
|
|
|
p := Provider{
|
|
|
|
IngressClass: test.ingressClass,
|
|
|
|
AllowCrossNamespace: true,
|
|
|
|
AllowExternalNameServices: true,
|
|
|
|
AllowEmptyServices: test.allowEmptyServices,
|
|
|
|
}
|
2020-12-10 13:58:04 +00:00
|
|
|
|
|
|
|
clientMock := newClientMock(test.paths...)
|
|
|
|
conf := p.loadConfigurationFromCRD(context.Background(), clientMock)
|
2019-06-11 13:12:04 +00:00
|
|
|
assert.Equal(t, test.expected, conf)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-14 14:56:06 +00:00
|
|
|
func TestLoadIngressRoutes(t *testing.T) {
|
|
|
|
testCases := []struct {
|
2021-09-16 13:12:13 +00:00
|
|
|
desc string
|
|
|
|
ingressClass string
|
|
|
|
paths []string
|
|
|
|
expected *dynamic.Configuration
|
2022-03-07 10:08:07 +00:00
|
|
|
allowCrossNamespace bool
|
|
|
|
allowEmptyServices bool
|
2019-03-14 14:56:06 +00:00
|
|
|
}{
|
|
|
|
{
|
|
|
|
desc: "Empty",
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple Ingress Route, with foo entrypoint",
|
|
|
|
paths: []string{"services.yml", "simple.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
2019-03-14 14:56:06 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-11-14 18:28:04 +00:00
|
|
|
Service: "default-test-route-6b204d94623b3df4370c",
|
2019-03-14 14:56:06 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-14 14:56:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.1:80",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.2:80",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-09-16 13:12:13 +00:00
|
|
|
desc: "Simple Ingress Route with middleware",
|
2022-03-07 10:08:07 +00:00
|
|
|
allowCrossNamespace: true,
|
2021-09-16 13:12:13 +00:00
|
|
|
paths: []string{"services.yml", "with_middleware.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test2-route-23c7f4c450289ee29016": {
|
2019-03-14 14:56:06 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2019-11-14 18:28:04 +00:00
|
|
|
Service: "default-test2-route-23c7f4c450289ee29016",
|
2019-03-14 14:56:06 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/tobestripped`)",
|
|
|
|
Priority: 12,
|
2021-11-26 11:10:11 +00:00
|
|
|
Middlewares: []string{"default-stripprefix", "default-ratelimit", "foo-addprefix"},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{
|
2021-11-26 11:10:11 +00:00
|
|
|
"default-ratelimit": {
|
|
|
|
RateLimit: &dynamic.RateLimit{
|
|
|
|
Average: 6,
|
|
|
|
Burst: 12,
|
|
|
|
Period: ptypes.Duration(60 * time.Second),
|
|
|
|
SourceCriterion: &dynamic.SourceCriterion{
|
|
|
|
IPStrategy: &dynamic.IPStrategy{
|
|
|
|
ExcludedIPs: []string{"127.0.0.1/32", "192.168.1.7"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-stripprefix": {
|
2019-07-10 07:26:04 +00:00
|
|
|
StripPrefix: &dynamic.StripPrefix{
|
2019-03-14 14:56:06 +00:00
|
|
|
Prefixes: []string{"/tobestripped"},
|
|
|
|
},
|
|
|
|
},
|
2019-09-13 18:44:04 +00:00
|
|
|
"foo-addprefix": {
|
2019-07-10 07:26:04 +00:00
|
|
|
AddPrefix: &dynamic.AddPrefix{
|
2019-03-14 14:56:06 +00:00
|
|
|
Prefix: "/tobeadded",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.Service{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test2-route-23c7f4c450289ee29016": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-06-26 12:14:05 +00:00
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-06-26 12:14:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-06-26 12:14:05 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
2019-06-26 12:14:05 +00:00
|
|
|
},
|
|
|
|
},
|
2021-10-07 13:40:05 +00:00
|
|
|
{
|
|
|
|
desc: "Middlewares in ingress route config are normalized",
|
2022-03-07 10:08:07 +00:00
|
|
|
allowCrossNamespace: true,
|
2021-10-07 13:40:05 +00:00
|
|
|
paths: []string{"services.yml", "with_middleware_multiple_hyphens.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-10-07 13:40:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-test2-route-23c7f4c450289ee29016": {
|
|
|
|
EntryPoints: []string{"web"},
|
|
|
|
Service: "default-test2-route-23c7f4c450289ee29016",
|
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/tobestripped`)",
|
|
|
|
Priority: 12,
|
|
|
|
Middlewares: []string{"default-multiple-hyphens"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{
|
|
|
|
"default-multiple-hyphens": {
|
|
|
|
StripPrefix: &dynamic.StripPrefix{
|
|
|
|
Prefixes: []string{"/tobestripped"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-test2-route-23c7f4c450289ee29016": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
2019-06-26 12:14:05 +00:00
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-06-26 12:14:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-06-26 12:14:05 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
2019-06-26 12:14:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-09-16 13:12:13 +00:00
|
|
|
desc: "Simple Ingress Route with middleware crossprovider",
|
2022-03-07 10:08:07 +00:00
|
|
|
allowCrossNamespace: true,
|
2021-09-16 13:12:13 +00:00
|
|
|
paths: []string{"services.yml", "with_middleware_crossprovider.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-07-10 07:26:04 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test2-route-23c7f4c450289ee29016": {
|
2019-06-26 12:14:05 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2019-11-14 18:28:04 +00:00
|
|
|
Service: "default-test2-route-23c7f4c450289ee29016",
|
2019-06-26 12:14:05 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/tobestripped`)",
|
|
|
|
Priority: 12,
|
2019-09-13 18:44:04 +00:00
|
|
|
Middlewares: []string{"default-stripprefix", "foo-addprefix", "basicauth@file", "redirect@file"},
|
2019-06-26 12:14:05 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-stripprefix": {
|
2019-07-10 07:26:04 +00:00
|
|
|
StripPrefix: &dynamic.StripPrefix{
|
2019-06-26 12:14:05 +00:00
|
|
|
Prefixes: []string{"/tobestripped"},
|
|
|
|
},
|
|
|
|
},
|
2019-09-13 18:44:04 +00:00
|
|
|
"foo-addprefix": {
|
2019-07-10 07:26:04 +00:00
|
|
|
AddPrefix: &dynamic.AddPrefix{
|
2019-06-26 12:14:05 +00:00
|
|
|
Prefix: "/tobeadded",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.Service{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test2-route-23c7f4c450289ee29016": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-14 14:56:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.1:80",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.2:80",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "One ingress Route with two different rules",
|
|
|
|
paths: []string{"services.yml", "with_two_rules.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
2019-03-14 14:56:06 +00:00
|
|
|
EntryPoints: []string{"web"},
|
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
2019-11-14 18:28:04 +00:00
|
|
|
Service: "default-test-route-6b204d94623b3df4370c",
|
2019-03-14 14:56:06 +00:00
|
|
|
Priority: 14,
|
|
|
|
},
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test-route-77c62dfe9517144aeeaa": {
|
2019-03-14 14:56:06 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2019-11-14 18:28:04 +00:00
|
|
|
Service: "default-test-route-77c62dfe9517144aeeaa",
|
2019-03-14 14:56:06 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/foo`)",
|
|
|
|
Priority: 12,
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-14 14:56:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.1:80",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.2:80",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test-route-77c62dfe9517144aeeaa": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-14 14:56:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.1:80",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.2:80",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2019-08-26 08:30:05 +00:00
|
|
|
desc: "One ingress Route with two different services",
|
2019-03-14 14:56:06 +00:00
|
|
|
paths: []string{"services.yml", "with_two_services.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-07-10 07:26:04 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test-route-77c62dfe9517144aeeaa": {
|
2019-03-14 14:56:06 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2019-11-14 18:28:04 +00:00
|
|
|
Service: "default-test-route-77c62dfe9517144aeeaa",
|
2019-03-14 14:56:06 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/foo`)",
|
|
|
|
Priority: 12,
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test-route-77c62dfe9517144aeeaa": {
|
2019-08-26 08:30:05 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
2019-11-14 18:28:04 +00:00
|
|
|
Name: "default-whoami-80",
|
2019-08-26 08:30:05 +00:00
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
{
|
2019-11-14 18:28:04 +00:00
|
|
|
Name: "default-whoami2-8080",
|
2019-08-26 08:30:05 +00:00
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-whoami-80": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-08-26 08:30:05 +00:00
|
|
|
},
|
|
|
|
},
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-whoami2-8080": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.3:8080",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.4:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one kube service (== servers lb) in a services wrr",
|
|
|
|
paths: []string{"with_services_lb0.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-11-14 18:28:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-test-route-77c62dfe9517144aeeaa": {
|
|
|
|
EntryPoints: []string{"web"},
|
|
|
|
Service: "default-wrr1",
|
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/foo`)",
|
|
|
|
Priority: 12,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-wrr1": {
|
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami5-8080",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami5-8080": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.3:8080",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.4:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "traefik service without ingress route",
|
|
|
|
paths: []string{"with_services_only.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-11-14 18:28:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
2019-11-14 18:28:04 +00:00
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-wrr1": {
|
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami5-8080",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami5-8080": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.3:8080",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.4:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "One ingress Route with two different services, each with two services, balancing servers nested",
|
|
|
|
paths: []string{"with_services_lb1.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-11-14 18:28:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-test-route-77c62dfe9517144aeeaa": {
|
|
|
|
EntryPoints: []string{"web"},
|
|
|
|
Service: "default-test-route-77c62dfe9517144aeeaa",
|
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/foo`)",
|
|
|
|
Priority: 12,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-test-route-77c62dfe9517144aeeaa": {
|
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-wrr1",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "default-wrr2",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-wrr1": {
|
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami4-80",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "default-whoami5-8080",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami4-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami5-8080": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.3:8080",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.4:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-wrr2": {
|
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami6-80",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "default-whoami7-8080",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami6-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.5:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.6:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami7-8080": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.7:8080",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.8:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one wrr and one kube service (== servers lb) in a wrr",
|
|
|
|
paths: []string{"with_services_lb2.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-11-14 18:28:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-test-route-77c62dfe9517144aeeaa": {
|
|
|
|
EntryPoints: []string{"web"},
|
|
|
|
Service: "default-wrr1",
|
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/foo`)",
|
|
|
|
Priority: 12,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-wrr1": {
|
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-wrr2",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "default-whoami5-8080",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-wrr2": {
|
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami5-8080",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami5-8080": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.3:8080",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.4:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "services lb, servers lb, and mirror service, all in a wrr",
|
|
|
|
paths: []string{"with_services_lb3.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-11-14 18:28:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-test-route-77c62dfe9517144aeeaa": {
|
|
|
|
EntryPoints: []string{"web"},
|
|
|
|
Service: "default-wrr1",
|
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/foo`)",
|
|
|
|
Priority: 12,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-wrr1": {
|
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-wrr2",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "default-whoami5-8080",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "default-mirror1",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-wrr2": {
|
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami5-8080",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-mirror1": {
|
|
|
|
Mirroring: &dynamic.Mirroring{
|
|
|
|
Service: "default-whoami5-8080",
|
|
|
|
Mirrors: []dynamic.MirrorService{
|
|
|
|
{Name: "default-whoami4-8080", Percent: 50},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami4-8080": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:8080",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami5-8080": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.3:8080",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.4:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-09-16 13:12:13 +00:00
|
|
|
desc: "services lb, servers lb, and mirror service, all in a wrr with different namespaces",
|
2022-03-07 10:08:07 +00:00
|
|
|
allowCrossNamespace: true,
|
2021-09-16 13:12:13 +00:00
|
|
|
paths: []string{"with_namespaces.yml"},
|
2019-11-14 18:28:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-11-14 18:28:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-test-route-77c62dfe9517144aeeaa": {
|
|
|
|
EntryPoints: []string{"web"},
|
|
|
|
Service: "default-test-route-77c62dfe9517144aeeaa",
|
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/foo`)",
|
|
|
|
Priority: 12,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-test-route-77c62dfe9517144aeeaa": {
|
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "baz-whoami6-8080",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "foo-wrr1",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "foo-mirror2",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "foo-mirror3",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "foo-mirror4",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"baz-whoami6-8080": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.5:8080",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.6:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"foo-wrr1": {
|
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "foo-whoami4-8080",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "baz-whoami6-8080",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "foo-mirror1",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "bar-wrr2",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"foo-whoami4-8080": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:8080",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"foo-mirror1": {
|
|
|
|
Mirroring: &dynamic.Mirroring{
|
|
|
|
Service: "foo-whoami5-8080",
|
|
|
|
Mirrors: []dynamic.MirrorService{
|
|
|
|
{Name: "foo-whoami4-8080"},
|
|
|
|
{Name: "baz-whoami6-8080"},
|
|
|
|
{Name: "bar-mirrored"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"foo-whoami5-8080": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.3:8080",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.4:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"bar-mirrored": {
|
|
|
|
Mirroring: &dynamic.Mirroring{
|
|
|
|
Service: "baz-whoami6-8080",
|
|
|
|
Mirrors: []dynamic.MirrorService{
|
|
|
|
{Name: "foo-whoami4-8080", Percent: 50},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"foo-mirror2": {
|
|
|
|
Mirroring: &dynamic.Mirroring{
|
|
|
|
Service: "foo-whoami5-8080",
|
|
|
|
Mirrors: []dynamic.MirrorService{
|
|
|
|
{Name: "foo-whoami4-8080"},
|
|
|
|
{Name: "baz-whoami6-8080"},
|
|
|
|
{Name: "bar-mirrored"},
|
|
|
|
{Name: "foo-wrr1"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"foo-mirror3": {
|
|
|
|
Mirroring: &dynamic.Mirroring{
|
|
|
|
Service: "foo-wrr1",
|
|
|
|
Mirrors: []dynamic.MirrorService{
|
|
|
|
{Name: "foo-whoami4-8080"},
|
|
|
|
{Name: "baz-whoami6-8080"},
|
|
|
|
{Name: "bar-mirrored"},
|
|
|
|
{Name: "foo-wrr1"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"bar-wrr2": {
|
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "foo-whoami5-8080",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"foo-mirror4": {
|
|
|
|
Mirroring: &dynamic.Mirroring{
|
|
|
|
Service: "foo-wrr1",
|
|
|
|
Mirrors: []dynamic.MirrorService{
|
|
|
|
{Name: "foo-whoami4-8080"},
|
|
|
|
{Name: "baz-whoami6-8080"},
|
|
|
|
{Name: "bar-mirrored"},
|
|
|
|
{Name: "foo-wrr1"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one kube service (== servers lb) in a mirroring",
|
|
|
|
paths: []string{"with_mirroring.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-11-14 18:28:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-test-route-77c62dfe9517144aeeaa": {
|
|
|
|
EntryPoints: []string{"web"},
|
|
|
|
Service: "default-mirror1",
|
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/foo`)",
|
|
|
|
Priority: 12,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-mirror1": {
|
|
|
|
Mirroring: &dynamic.Mirroring{
|
|
|
|
Service: "default-whoami5-8080",
|
|
|
|
Mirrors: []dynamic.MirrorService{
|
|
|
|
{Name: "default-whoami4-8080", Percent: 50},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami4-8080": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:8080",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami5-8080": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.3:8080",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.4:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "weighted services in a mirroring",
|
|
|
|
paths: []string{"with_mirroring2.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-11-14 18:28:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-test-route-77c62dfe9517144aeeaa": {
|
|
|
|
EntryPoints: []string{"web"},
|
|
|
|
Service: "default-mirror1",
|
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/foo`)",
|
|
|
|
Priority: 12,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-mirror1": {
|
|
|
|
Mirroring: &dynamic.Mirroring{
|
|
|
|
Service: "default-wrr1",
|
|
|
|
Mirrors: []dynamic.MirrorService{
|
|
|
|
{Name: "default-wrr2", Percent: 30},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-wrr1": {
|
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami4-8080",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-wrr2": {
|
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami5-8080",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami4-8080": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:8080",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-11-14 18:28:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami5-8080": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.3:8080",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.4:8080",
|
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-08-26 08:30:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-08-26 08:30:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "One ingress Route with two different services, with weights",
|
|
|
|
paths: []string{"services.yml", "with_two_services_weight.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-08-26 08:30:05 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-08-26 08:30:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test-route-77c62dfe9517144aeeaa": {
|
2019-08-26 08:30:05 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2019-11-14 18:28:04 +00:00
|
|
|
Service: "default-test-route-77c62dfe9517144aeeaa",
|
2019-08-26 08:30:05 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/foo`)",
|
|
|
|
Priority: 12,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test-route-77c62dfe9517144aeeaa": {
|
2019-08-26 08:30:05 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
2019-11-14 18:28:04 +00:00
|
|
|
Name: "default-whoami-80",
|
2019-08-26 08:30:05 +00:00
|
|
|
Weight: Int(10),
|
|
|
|
},
|
|
|
|
{
|
2019-11-14 18:28:04 +00:00
|
|
|
Name: "default-whoami2-8080",
|
2019-08-26 08:30:05 +00:00
|
|
|
Weight: Int(0),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-whoami-80": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-14 14:56:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.1:80",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.2:80",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
2019-08-26 08:30:05 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-08-26 08:30:05 +00:00
|
|
|
},
|
|
|
|
},
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-whoami2-8080": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
2019-03-14 14:56:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.3:8080",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.4:8080",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Ingress class",
|
|
|
|
paths: []string{"services.yml", "simple.yml"},
|
|
|
|
ingressClass: "tchouk",
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Route with empty rule value is ignored",
|
|
|
|
paths: []string{"services.yml", "with_no_rule_value.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Route with kind not of a rule type (empty kind) is ignored",
|
|
|
|
paths: []string{"services.yml", "with_wrong_rule_kind.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TLS",
|
|
|
|
paths: []string{"services.yml", "with_tls.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
2019-06-27 21:58:03 +00:00
|
|
|
Certificates: []*tls.CertAndStores{
|
|
|
|
{
|
|
|
|
Certificate: tls.Certificate{
|
2024-01-11 16:06:06 +00:00
|
|
|
CertFile: types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
KeyFile: types.FileOrContent("-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----"),
|
2019-06-27 21:58:03 +00:00
|
|
|
},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
2019-03-14 14:56:06 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2019-11-14 18:28:04 +00:00
|
|
|
Service: "default-test-route-6b204d94623b3df4370c",
|
2019-03-14 14:56:06 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTLSConfig{},
|
2019-03-26 10:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-26 10:12:04 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.1:80",
|
2019-03-26 10:12:04 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.2:80",
|
2019-03-26 10:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-03-26 10:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-03-26 10:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-06-21 15:18:05 +00:00
|
|
|
{
|
|
|
|
desc: "TLS with tls options",
|
|
|
|
paths: []string{"services.yml", "with_tls_options.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
2019-06-27 21:58:03 +00:00
|
|
|
Options: map[string]tls.Options{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-foo": {
|
2019-06-27 21:58:03 +00:00
|
|
|
MinVersion: "VersionTLS12",
|
|
|
|
CipherSuites: []string{
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
"TLS_RSA_WITH_AES_256_GCM_SHA384",
|
|
|
|
},
|
2019-07-12 15:50:04 +00:00
|
|
|
ClientAuth: tls.ClientAuth{
|
2024-01-11 16:06:06 +00:00
|
|
|
CAFiles: []types.FileOrContent{
|
|
|
|
types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
2019-06-27 21:58:03 +00:00
|
|
|
},
|
2019-07-12 15:50:04 +00:00
|
|
|
ClientAuthType: "VerifyClientCertIfGiven",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
2022-08-09 15:36:08 +00:00
|
|
|
SniStrict: true,
|
2021-08-20 16:20:06 +00:00
|
|
|
ALPNProtocols: []string{
|
|
|
|
"h2",
|
|
|
|
"http/1.1",
|
|
|
|
"acme-tls/1",
|
|
|
|
},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
2019-06-21 15:18:05 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2019-11-14 18:28:04 +00:00
|
|
|
Service: "default-test-route-6b204d94623b3df4370c",
|
2019-06-21 15:18:05 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTLSConfig{
|
2019-09-13 18:44:04 +00:00
|
|
|
Options: "default-foo",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-06-21 15:18:05 +00:00
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-02-24 16:14:06 +00:00
|
|
|
{
|
|
|
|
desc: "TLS with two default tls options",
|
|
|
|
paths: []string{"services.yml", "with_default_tls_options.yml", "with_default_tls_options_default_namespace.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2020-02-24 16:14:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Options: map[string]tls.Options{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-02-24 16:14:06 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
|
|
|
EntryPoints: []string{"web"},
|
|
|
|
Service: "default-test-route-6b204d94623b3df4370c",
|
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
|
|
|
TLS: &dynamic.RouterTLSConfig{
|
|
|
|
Options: "default-foo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2020-02-24 16:14:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-02-24 16:14:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TLS with default tls options",
|
|
|
|
paths: []string{"services.yml", "with_default_tls_options.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Options: map[string]tls.Options{
|
|
|
|
"default": {
|
|
|
|
MinVersion: "VersionTLS12",
|
|
|
|
CipherSuites: []string{
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
"TLS_RSA_WITH_AES_256_GCM_SHA384",
|
|
|
|
},
|
|
|
|
ClientAuth: tls.ClientAuth{
|
2024-01-11 16:06:06 +00:00
|
|
|
CAFiles: []types.FileOrContent{
|
|
|
|
types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
2020-02-24 16:14:06 +00:00
|
|
|
},
|
|
|
|
ClientAuthType: "VerifyClientCertIfGiven",
|
|
|
|
},
|
2022-08-09 15:36:08 +00:00
|
|
|
SniStrict: true,
|
2021-08-20 16:20:06 +00:00
|
|
|
ALPNProtocols: []string{
|
|
|
|
"h2",
|
|
|
|
"http/1.1",
|
|
|
|
"acme-tls/1",
|
|
|
|
},
|
2020-02-24 16:14:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2020-02-24 16:14:06 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-02-24 16:14:06 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
|
|
|
EntryPoints: []string{"web"},
|
|
|
|
Service: "default-test-route-6b204d94623b3df4370c",
|
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
|
|
|
TLS: &dynamic.RouterTLSConfig{
|
|
|
|
Options: "default-foo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2020-02-24 16:14:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-02-24 16:14:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-06-21 15:18:05 +00:00
|
|
|
{
|
2021-09-20 10:54:05 +00:00
|
|
|
desc: "TLS with tls options and specific namespace",
|
|
|
|
paths: []string{"services.yml", "with_tls_options_and_specific_namespace.yml"},
|
2022-03-07 10:08:07 +00:00
|
|
|
allowCrossNamespace: true,
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
2019-06-27 21:58:03 +00:00
|
|
|
Options: map[string]tls.Options{
|
2019-09-13 18:44:04 +00:00
|
|
|
"myns-foo": {
|
2019-06-27 21:58:03 +00:00
|
|
|
MinVersion: "VersionTLS12",
|
|
|
|
CipherSuites: []string{
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
"TLS_RSA_WITH_AES_256_GCM_SHA384",
|
|
|
|
},
|
2019-07-12 15:50:04 +00:00
|
|
|
ClientAuth: tls.ClientAuth{
|
2024-01-11 16:06:06 +00:00
|
|
|
CAFiles: []types.FileOrContent{
|
|
|
|
types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
2019-06-27 21:58:03 +00:00
|
|
|
},
|
2019-07-12 15:50:04 +00:00
|
|
|
ClientAuthType: "VerifyClientCertIfGiven",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
2019-06-27 21:58:03 +00:00
|
|
|
SniStrict: true,
|
2021-08-20 16:20:06 +00:00
|
|
|
ALPNProtocols: []string{
|
|
|
|
"h2",
|
|
|
|
"http/1.1",
|
|
|
|
"acme-tls/1",
|
|
|
|
},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
2019-06-21 15:18:05 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2019-11-14 18:28:04 +00:00
|
|
|
Service: "default-test-route-6b204d94623b3df4370c",
|
2019-06-21 15:18:05 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTLSConfig{
|
2019-09-13 18:44:04 +00:00
|
|
|
Options: "myns-foo",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-06-21 15:18:05 +00:00
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TLS with bad tls options",
|
|
|
|
paths: []string{"services.yml", "with_bad_tls_options.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
2019-06-27 21:58:03 +00:00
|
|
|
Options: map[string]tls.Options{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-foo": {
|
2019-06-27 21:58:03 +00:00
|
|
|
MinVersion: "VersionTLS12",
|
|
|
|
CipherSuites: []string{
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
"TLS_RSA_WITH_AES_256_GCM_SHA384",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
2019-07-12 15:50:04 +00:00
|
|
|
ClientAuth: tls.ClientAuth{
|
2024-01-11 16:06:06 +00:00
|
|
|
CAFiles: []types.FileOrContent{
|
|
|
|
types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
2019-06-27 21:58:03 +00:00
|
|
|
},
|
2019-07-12 15:50:04 +00:00
|
|
|
ClientAuthType: "VerifyClientCertIfGiven",
|
2019-06-27 21:58:03 +00:00
|
|
|
},
|
|
|
|
SniStrict: true,
|
2021-08-20 16:20:06 +00:00
|
|
|
ALPNProtocols: []string{
|
|
|
|
"h2",
|
|
|
|
"http/1.1",
|
|
|
|
"acme-tls/1",
|
|
|
|
},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
2019-06-21 15:18:05 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2019-11-14 18:28:04 +00:00
|
|
|
Service: "default-test-route-6b204d94623b3df4370c",
|
2019-06-21 15:18:05 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTLSConfig{
|
2019-09-13 18:44:04 +00:00
|
|
|
Options: "default-foo",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-06-21 15:18:05 +00:00
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TLS with unknown tls options",
|
|
|
|
paths: []string{"services.yml", "with_unknown_tls_options.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
2019-06-27 21:58:03 +00:00
|
|
|
Options: map[string]tls.Options{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-foo": {
|
2019-06-27 21:58:03 +00:00
|
|
|
MinVersion: "VersionTLS12",
|
2021-08-20 16:20:06 +00:00
|
|
|
ALPNProtocols: []string{
|
|
|
|
"h2",
|
|
|
|
"http/1.1",
|
|
|
|
"acme-tls/1",
|
|
|
|
},
|
2019-06-27 21:58:03 +00:00
|
|
|
},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
2019-06-21 15:18:05 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2019-11-14 18:28:04 +00:00
|
|
|
Service: "default-test-route-6b204d94623b3df4370c",
|
2019-06-21 15:18:05 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTLSConfig{
|
2019-09-13 18:44:04 +00:00
|
|
|
Options: "default-unknown",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-06-21 15:18:05 +00:00
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-09-20 10:54:05 +00:00
|
|
|
desc: "TLS with unknown tls options namespace",
|
|
|
|
paths: []string{"services.yml", "with_unknown_tls_options_namespace.yml"},
|
2022-03-07 10:08:07 +00:00
|
|
|
allowCrossNamespace: true,
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
2019-06-27 21:58:03 +00:00
|
|
|
Options: map[string]tls.Options{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-foo": {
|
2019-06-27 21:58:03 +00:00
|
|
|
MinVersion: "VersionTLS12",
|
2021-08-20 16:20:06 +00:00
|
|
|
ALPNProtocols: []string{
|
|
|
|
"h2",
|
|
|
|
"http/1.1",
|
|
|
|
"acme-tls/1",
|
|
|
|
},
|
2019-06-27 21:58:03 +00:00
|
|
|
},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
2019-06-21 15:18:05 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2019-11-14 18:28:04 +00:00
|
|
|
Service: "default-test-route-6b204d94623b3df4370c",
|
2019-06-21 15:18:05 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTLSConfig{
|
2019-09-13 18:44:04 +00:00
|
|
|
Options: "unknown-foo",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-06-21 15:18:05 +00:00
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-03-26 10:12:04 +00:00
|
|
|
{
|
|
|
|
desc: "TLS with ACME",
|
|
|
|
paths: []string{"services.yml", "with_tls_acme.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-07-10 07:26:04 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
2019-03-26 10:12:04 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2019-11-14 18:28:04 +00:00
|
|
|
Service: "default-test-route-6b204d94623b3df4370c",
|
2019-03-26 10:12:04 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTLSConfig{},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-14 14:56:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.1:80",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.2:80",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple Ingress Route, defaulting to https for servers",
|
|
|
|
paths: []string{"services.yml", "with_https_default.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-07-10 07:26:04 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
2019-03-14 14:56:06 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-11-14 18:28:04 +00:00
|
|
|
Service: "default-test-route-6b204d94623b3df4370c",
|
2019-03-14 14:56:06 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-14 14:56:06 +00:00
|
|
|
{
|
2019-08-14 16:58:04 +00:00
|
|
|
URL: "https://10.10.0.5:8443",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
{
|
2019-08-14 16:58:04 +00:00
|
|
|
URL: "https://10.10.0.6:8443",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-05 15:24:04 +00:00
|
|
|
{
|
|
|
|
desc: "Simple Ingress Route, explicit https scheme",
|
|
|
|
paths: []string{"services.yml", "with_https_scheme.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-07-10 07:26:04 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
2019-07-05 15:24:04 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-11-14 18:28:04 +00:00
|
|
|
Service: "default-test-route-6b204d94623b3df4370c",
|
2019-07-05 15:24:04 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-07-05 15:24:04 +00:00
|
|
|
{
|
|
|
|
URL: "https://10.10.0.7:8443",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "https://10.10.0.8:8443",
|
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-07-05 15:24:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-07-05 15:24:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-09-05 11:42:04 +00:00
|
|
|
{
|
|
|
|
desc: "Simple Ingress Route, with basic auth middleware",
|
|
|
|
paths: []string{"services.yml", "with_auth.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-09-05 11:42:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-09-05 11:42:04 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
2019-09-05 11:42:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-basicauth": {
|
2019-09-05 11:42:04 +00:00
|
|
|
BasicAuth: &dynamic.BasicAuth{
|
|
|
|
Users: dynamic.Users{"test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"},
|
|
|
|
},
|
|
|
|
},
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-digestauth": {
|
2019-09-05 11:42:04 +00:00
|
|
|
DigestAuth: &dynamic.DigestAuth{
|
|
|
|
Users: dynamic.Users{"test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"},
|
|
|
|
},
|
|
|
|
},
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-forwardauth": {
|
2019-09-05 11:42:04 +00:00
|
|
|
ForwardAuth: &dynamic.ForwardAuth{
|
|
|
|
Address: "test.com",
|
2021-10-26 08:54:11 +00:00
|
|
|
TLS: &types.ClientTLS{
|
2019-09-05 11:42:04 +00:00
|
|
|
CA: "-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----",
|
|
|
|
Cert: "-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----",
|
|
|
|
Key: "-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-09-05 11:42:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-06-20 13:44:08 +00:00
|
|
|
{
|
|
|
|
desc: "Simple Ingress Route, with test middleware read config from secret",
|
|
|
|
paths: []string{"services.yml", "with_plugin_read_secret.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2022-06-20 13:44:08 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{
|
|
|
|
"default-test-secret": {
|
|
|
|
Plugin: map[string]dynamic.PluginConf{
|
|
|
|
"test-secret": map[string]interface{}{
|
|
|
|
"user": "admin",
|
|
|
|
"secret": "this_is_the_secret",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple Ingress Route, with test middleware read config from deep secret",
|
|
|
|
paths: []string{"services.yml", "with_plugin_deep_read_secret.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2022-06-20 13:44:08 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{
|
|
|
|
"default-test-secret": {
|
|
|
|
Plugin: map[string]dynamic.PluginConf{
|
|
|
|
"test-secret": map[string]interface{}{
|
|
|
|
"secret_0": map[string]interface{}{
|
|
|
|
"secret_1": map[string]interface{}{
|
|
|
|
"secret_2": map[string]interface{}{
|
|
|
|
"user": "admin",
|
|
|
|
"secret": "this_is_the_very_deep_secret",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple Ingress Route, with test middleware read config from an array of secret",
|
|
|
|
paths: []string{"services.yml", "with_plugin_read_array_of_secret.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2022-06-20 13:44:08 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{
|
|
|
|
"default-test-secret": {
|
|
|
|
Plugin: map[string]dynamic.PluginConf{
|
|
|
|
"test-secret": map[string]interface{}{
|
|
|
|
"secret": []interface{}{"secret_data1", "secret_data2"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple Ingress Route, with test middleware read config from an array of secret",
|
|
|
|
paths: []string{"services.yml", "with_plugin_read_array_of_map_contain_secret.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2022-06-20 13:44:08 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{
|
|
|
|
"default-test-secret": {
|
|
|
|
Plugin: map[string]dynamic.PluginConf{
|
|
|
|
"test-secret": map[string]interface{}{
|
|
|
|
"users": []interface{}{
|
|
|
|
map[string]interface{}{
|
|
|
|
"name": "admin",
|
|
|
|
"secret": "admin_password",
|
|
|
|
},
|
|
|
|
map[string]interface{}{
|
|
|
|
"name": "user",
|
|
|
|
"secret": "user_password",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple Ingress Route, with test middleware read config from secret that not found",
|
|
|
|
paths: []string{"services.yml", "with_plugin_read_not_exist_secret.yml"},
|
|
|
|
allowCrossNamespace: true,
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2022-06-20 13:44:08 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-09-10 15:24:03 +00:00
|
|
|
{
|
|
|
|
desc: "Simple Ingress Route, with error page middleware",
|
|
|
|
paths: []string{"services.yml", "with_error_page.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-09-10 15:24:03 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-09-10 15:24:03 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
2019-09-10 15:24:03 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-errorpage": {
|
2019-09-10 15:24:03 +00:00
|
|
|
Errors: &dynamic.ErrorPage{
|
|
|
|
Status: []string{"404", "500"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-errorpage-errorpage-service",
|
2019-09-10 15:24:03 +00:00
|
|
|
Query: "query",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-errorpage-errorpage-service": {
|
2019-09-10 15:24:03 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-09-10 15:24:03 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-09-10 15:24:03 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-09-13 14:46:04 +00:00
|
|
|
{
|
|
|
|
desc: "Simple Ingress Route, with options",
|
|
|
|
paths: []string{"services.yml", "with_options.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-09-13 14:46:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-09-13 14:46:04 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
2019-09-13 14:46:04 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-11-14 18:28:04 +00:00
|
|
|
Service: "default-test-route-6b204d94623b3df4370c",
|
2019-09-13 14:46:04 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-11-14 18:28:04 +00:00
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
2019-09-13 14:46:04 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(false),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{FlushInterval: ptypes.Duration(10 * time.Second)},
|
2019-09-13 14:46:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-09-13 14:46:04 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
2020-11-17 12:04:04 +00:00
|
|
|
},
|
|
|
|
},
|
2020-02-24 16:14:06 +00:00
|
|
|
{
|
|
|
|
desc: "TLS with tls store",
|
|
|
|
paths: []string{"services.yml", "with_tls_store.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{
|
|
|
|
"default": {
|
|
|
|
DefaultCertificate: &tls.Certificate{
|
2024-01-11 16:06:06 +00:00
|
|
|
CertFile: types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
KeyFile: types.FileOrContent("-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----"),
|
2020-02-24 16:14:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2020-02-24 16:14:06 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-02-24 16:14:06 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
|
|
|
EntryPoints: []string{"web"},
|
|
|
|
Service: "default-test-route-6b204d94623b3df4370c",
|
2022-05-19 14:42:09 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
|
|
|
TLS: &dynamic.RouterTLSConfig{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2022-05-19 14:42:09 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TLS with tls store containing certificates",
|
|
|
|
paths: []string{"services.yml", "with_tls_store_certificates.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Certificates: []*tls.CertAndStores{
|
|
|
|
{
|
|
|
|
Certificate: tls.Certificate{
|
2024-01-11 16:06:06 +00:00
|
|
|
CertFile: types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
KeyFile: types.FileOrContent("-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----"),
|
2022-05-19 14:42:09 +00:00
|
|
|
},
|
|
|
|
Stores: []string{"default"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Stores: map[string]tls.Store{
|
|
|
|
"default": {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2022-05-19 14:42:09 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
|
|
|
EntryPoints: []string{"web"},
|
|
|
|
Service: "default-test-route-6b204d94623b3df4370c",
|
2020-02-24 16:14:06 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
|
|
|
TLS: &dynamic.RouterTLSConfig{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2020-02-24 16:14:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-02-24 16:14:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TLS with tls store default two times",
|
|
|
|
paths: []string{"services.yml", "with_tls_store.yml", "with_default_tls_store.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2020-02-26 11:28:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2020-02-24 16:14:06 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-02-24 16:14:06 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
|
|
|
EntryPoints: []string{"web"},
|
|
|
|
Service: "default-test-route-6b204d94623b3df4370c",
|
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
|
|
|
TLS: &dynamic.RouterTLSConfig{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2020-02-24 16:14:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-02-24 16:14:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-03-14 14:56:06 +00:00
|
|
|
{
|
|
|
|
desc: "port selected by name (TODO)",
|
|
|
|
},
|
2020-03-10 11:46:05 +00:00
|
|
|
{
|
|
|
|
desc: "Simple Ingress Route, with externalName service",
|
|
|
|
paths: []string{"services.yml", "with_externalname.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-03-10 11:46:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-test-route-6f97418635c7e18853da": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test-route-6f97418635c7e18853da",
|
|
|
|
Rule: "Host(`foo.com`)",
|
2020-07-07 12:42:03 +00:00
|
|
|
},
|
|
|
|
},
|
2020-03-10 11:46:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-test-route-6f97418635c7e18853da": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://external.domain:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2020-03-10 11:46:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-03-10 11:46:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Ingress Route, externalName service with http",
|
|
|
|
paths: []string{"services.yml", "with_externalname_with_http.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-03-10 11:46:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-test-route-6f97418635c7e18853da": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test-route-6f97418635c7e18853da",
|
|
|
|
Rule: "Host(`foo.com`)",
|
2020-07-07 12:42:03 +00:00
|
|
|
},
|
|
|
|
},
|
2020-03-10 11:46:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-test-route-6f97418635c7e18853da": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://external.domain:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2020-03-10 11:46:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-03-10 11:46:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Ingress Route, externalName service with https",
|
|
|
|
paths: []string{"services.yml", "with_externalname_with_https.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-03-10 11:46:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-test-route-6f97418635c7e18853da": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test-route-6f97418635c7e18853da",
|
|
|
|
Rule: "Host(`foo.com`)",
|
2020-07-07 12:42:03 +00:00
|
|
|
},
|
|
|
|
},
|
2020-03-10 11:46:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-test-route-6f97418635c7e18853da": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "https://external.domain:443",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2020-03-10 11:46:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-03-10 11:46:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Ingress Route, externalName service without ports",
|
|
|
|
paths: []string{"services.yml", "with_externalname_without_ports.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-03-10 11:46:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-09-11 13:40:03 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "ServersTransport",
|
|
|
|
paths: []string{"services.yml", "with_servers_transport.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-09-11 13:40:03 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{
|
2021-09-16 13:12:13 +00:00
|
|
|
"foo-test": {
|
2020-09-11 13:40:03 +00:00
|
|
|
ServerName: "test",
|
|
|
|
InsecureSkipVerify: true,
|
2024-01-11 16:06:06 +00:00
|
|
|
RootCAs: []types.FileOrContent{"TESTROOTCAS0", "TESTROOTCAS1", "TESTROOTCAS2", "TESTROOTCAS3", "TESTROOTCAS5", "TESTALLCERTS"},
|
2020-09-11 13:40:03 +00:00
|
|
|
Certificates: tls.Certificates{
|
|
|
|
{CertFile: "TESTCERT1", KeyFile: "TESTKEY1"},
|
|
|
|
{CertFile: "TESTCERT2", KeyFile: "TESTKEY2"},
|
2021-06-14 16:06:10 +00:00
|
|
|
{CertFile: "TESTCERT3", KeyFile: "TESTKEY3"},
|
2020-09-11 13:40:03 +00:00
|
|
|
},
|
|
|
|
MaxIdleConnsPerHost: 42,
|
2021-09-16 10:18:08 +00:00
|
|
|
DisableHTTP2: true,
|
2020-09-11 13:40:03 +00:00
|
|
|
ForwardingTimeouts: &dynamic.ForwardingTimeouts{
|
2021-10-26 08:54:11 +00:00
|
|
|
DialTimeout: ptypes.Duration(42 * time.Second),
|
|
|
|
ResponseHeaderTimeout: ptypes.Duration(42 * time.Second),
|
|
|
|
IdleConnTimeout: ptypes.Duration(42 * time.Millisecond),
|
2021-11-09 11:16:08 +00:00
|
|
|
ReadIdleTimeout: ptypes.Duration(42 * time.Second),
|
|
|
|
PingTimeout: ptypes.Duration(42 * time.Second),
|
2020-09-11 13:40:03 +00:00
|
|
|
},
|
2021-09-17 06:56:07 +00:00
|
|
|
PeerCertURI: "foo://bar",
|
2022-10-14 15:16:08 +00:00
|
|
|
Spiffe: &dynamic.Spiffe{
|
|
|
|
IDs: []string{
|
|
|
|
"spiffe://foo/buz",
|
|
|
|
"spiffe://bar/biz",
|
|
|
|
},
|
|
|
|
TrustDomain: "spiffe://lol",
|
|
|
|
},
|
2020-09-11 13:40:03 +00:00
|
|
|
},
|
2021-09-16 13:12:13 +00:00
|
|
|
"default-test": {
|
|
|
|
ServerName: "test",
|
|
|
|
ForwardingTimeouts: &dynamic.ForwardingTimeouts{
|
2021-10-26 08:54:11 +00:00
|
|
|
DialTimeout: ptypes.Duration(30 * time.Second),
|
|
|
|
IdleConnTimeout: ptypes.Duration(90 * time.Second),
|
2021-11-09 11:16:08 +00:00
|
|
|
PingTimeout: ptypes.Duration(15 * time.Second),
|
2021-09-16 13:12:13 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-test-route-6f97418635c7e18853da": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test-route-6f97418635c7e18853da",
|
|
|
|
Rule: "Host(`foo.com`)",
|
2020-09-11 13:40:03 +00:00
|
|
|
},
|
|
|
|
},
|
2020-03-10 11:46:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
2021-09-16 13:12:13 +00:00
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-external-svc-with-https-443": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "https://external.domain:443",
|
|
|
|
},
|
|
|
|
},
|
2022-11-16 10:38:07 +00:00
|
|
|
PassHostHeader: Bool(true),
|
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2021-09-16 13:12:13 +00:00
|
|
|
ServersTransport: "default-test",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoamitls-443": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "https://10.10.0.5:8443",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "https://10.10.0.6:8443",
|
|
|
|
},
|
|
|
|
},
|
2022-11-16 10:38:07 +00:00
|
|
|
PassHostHeader: Bool(true),
|
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2021-09-16 13:12:13 +00:00
|
|
|
ServersTransport: "default-default-test",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-test-route-6f97418635c7e18853da": {
|
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-external-svc-with-https-443",
|
|
|
|
Weight: Int(1),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "default-whoamitls-443",
|
|
|
|
Weight: Int(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-03-10 11:46:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2022-03-07 10:08:07 +00:00
|
|
|
{
|
|
|
|
desc: "Ingress Route, empty service disallowed",
|
|
|
|
paths: []string{"services.yml", "with_empty_services.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2022-03-07 10:08:07 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Ingress Route, empty service allowed",
|
|
|
|
allowEmptyServices: true,
|
|
|
|
paths: []string{"services.yml", "with_empty_services.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2022-03-07 10:08:07 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test-route-6b204d94623b3df4370c",
|
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
2022-11-23 07:51:49 +00:00
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2022-03-07 10:08:07 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2022-11-22 09:18:04 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2023-05-31 09:40:05 +00:00
|
|
|
{
|
|
|
|
desc: "IngressRoute, service with multiple subsets",
|
|
|
|
allowEmptyServices: true,
|
|
|
|
paths: []string{"services.yml", "with_multiple_subsets.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2023-06-05 09:05:29 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2023-05-31 09:40:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test-route-6b204d94623b3df4370c",
|
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.3:8080",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.4:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2023-06-05 09:05:29 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2023-05-31 09:40:05 +00:00
|
|
|
},
|
2022-03-07 10:08:07 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2022-11-22 09:18:04 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TraefikService, empty service allowed",
|
|
|
|
allowEmptyServices: true,
|
|
|
|
paths: []string{"services.yml", "with_empty_services_ts.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2022-11-22 09:18:04 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Middlewares: []string{"default-test-errorpage"},
|
|
|
|
Service: "default-test-route-6b204d94623b3df4370c",
|
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{
|
|
|
|
"default-test-errorpage": {
|
|
|
|
Errors: &dynamic.ErrorPage{
|
|
|
|
Service: "default-test-errorpage-errorpage-service",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-test-weighted",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "default-test-mirror",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-test-errorpage-errorpage-service": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-23 07:51:49 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2022-11-22 09:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-test-weighted": {
|
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-without-endpoints-subsets-80",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-test-mirror": {
|
|
|
|
Mirroring: &dynamic.Mirroring{
|
|
|
|
Service: "default-whoami-without-endpoints-subsets-80",
|
|
|
|
Mirrors: []dynamic.MirrorService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-without-endpoints-subsets-80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "default-test-weighted",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-without-endpoints-subsets-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-23 07:51:49 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
2022-11-16 10:38:07 +00:00
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2022-03-07 10:08:07 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2019-03-14 14:56:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
test := test
|
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
if test.expected == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-03-07 10:08:07 +00:00
|
|
|
p := Provider{
|
|
|
|
IngressClass: test.ingressClass,
|
|
|
|
AllowCrossNamespace: test.allowCrossNamespace,
|
|
|
|
AllowExternalNameServices: true,
|
|
|
|
AllowEmptyServices: test.allowEmptyServices,
|
|
|
|
}
|
2020-12-10 13:58:04 +00:00
|
|
|
|
|
|
|
clientMock := newClientMock(test.paths...)
|
|
|
|
conf := p.loadConfigurationFromCRD(context.Background(), clientMock)
|
2019-03-14 14:56:06 +00:00
|
|
|
assert.Equal(t, test.expected, conf)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2020-02-26 11:28:05 +00:00
|
|
|
|
|
|
|
func TestLoadIngressRouteUDPs(t *testing.T) {
|
|
|
|
testCases := []struct {
|
2022-03-07 10:08:07 +00:00
|
|
|
desc string
|
|
|
|
ingressClass string
|
|
|
|
paths []string
|
|
|
|
allowEmptyServices bool
|
|
|
|
expected *dynamic.Configuration
|
2020-02-26 11:28:05 +00:00
|
|
|
}{
|
|
|
|
{
|
|
|
|
desc: "Empty",
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-02-26 11:28:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-02-26 11:28:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple Ingress Route, with foo entrypoint",
|
|
|
|
paths: []string{"udp/services.yml", "udp/simple.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{
|
|
|
|
"default-test.route-0": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-0",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.UDPService{
|
|
|
|
"default-test.route-0": {
|
|
|
|
LoadBalancer: &dynamic.UDPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.UDPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-02-26 11:28:05 +00:00
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-02-26 11:28:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "One ingress Route with two different routes",
|
|
|
|
paths: []string{"udp/services.yml", "udp/with_two_routes.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{
|
|
|
|
"default-test.route-0": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-0",
|
|
|
|
},
|
|
|
|
"default-test.route-1": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.UDPService{
|
|
|
|
"default-test.route-0": {
|
|
|
|
LoadBalancer: &dynamic.UDPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.UDPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-test.route-1": {
|
|
|
|
LoadBalancer: &dynamic.UDPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.UDPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.3:8080",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.4:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-02-26 11:28:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-02-26 11:28:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "One ingress Route with two different services",
|
|
|
|
paths: []string{"udp/services.yml", "udp/with_two_services.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{
|
|
|
|
"default-test.route-0": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-0",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.UDPService{
|
|
|
|
"default-test.route-0": {
|
|
|
|
Weighted: &dynamic.UDPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.UDPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-test.route-0-whoamiudp-8000",
|
|
|
|
Weight: func(i int) *int { return &i }(2),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "default-test.route-0-whoamiudp2-8080",
|
|
|
|
Weight: func(i int) *int { return &i }(3),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-test.route-0-whoamiudp-8000": {
|
|
|
|
LoadBalancer: &dynamic.UDPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.UDPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-test.route-0-whoamiudp2-8080": {
|
|
|
|
LoadBalancer: &dynamic.UDPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.UDPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.3:8080",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.4:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-02-26 11:28:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-02-26 11:28:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "One ingress Route with different services namespaces",
|
|
|
|
paths: []string{"udp/services.yml", "udp/with_different_services_ns.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{
|
|
|
|
"default-test.route-0": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-0",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.UDPService{
|
|
|
|
"default-test.route-0": {
|
|
|
|
Weighted: &dynamic.UDPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.UDPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-test.route-0-whoamiudp-8000",
|
|
|
|
Weight: func(i int) *int { return &i }(2),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "default-test.route-0-whoamiudp2-8080",
|
|
|
|
Weight: func(i int) *int { return &i }(3),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "default-test.route-0-whoamiudp3-8083",
|
|
|
|
Weight: func(i int) *int { return &i }(4),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-test.route-0-whoamiudp-8000": {
|
|
|
|
LoadBalancer: &dynamic.UDPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.UDPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-test.route-0-whoamiudp2-8080": {
|
|
|
|
LoadBalancer: &dynamic.UDPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.UDPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.3:8080",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.4:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-test.route-0-whoamiudp3-8083": {
|
|
|
|
LoadBalancer: &dynamic.UDPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.UDPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.7:8083",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.8:8083",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-02-26 11:28:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-02-26 11:28:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2021-01-19 08:30:05 +00:00
|
|
|
{
|
|
|
|
desc: "Simple Ingress Route, with externalName service",
|
|
|
|
paths: []string{"udp/services.yml", "udp/with_externalname.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{
|
|
|
|
"default-test.route-0": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-0",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.UDPService{
|
|
|
|
"default-test.route-0": {
|
|
|
|
LoadBalancer: &dynamic.UDPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.UDPServer{
|
|
|
|
{
|
|
|
|
Address: "external.domain:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-01-19 08:30:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-01-19 08:30:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Ingress Route, externalName service with port",
|
|
|
|
paths: []string{"udp/services.yml", "udp/with_externalname_with_port.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{
|
|
|
|
"default-test.route-0": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-0",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.UDPService{
|
|
|
|
"default-test.route-0": {
|
|
|
|
LoadBalancer: &dynamic.UDPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.UDPServer{
|
|
|
|
{
|
|
|
|
Address: "external.domain:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-01-19 08:30:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-01-19 08:30:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Ingress Route, externalName service without port",
|
|
|
|
paths: []string{"udp/services.yml", "udp/with_externalname_without_ports.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
// The router that references the invalid service will be discarded.
|
2021-01-19 08:30:05 +00:00
|
|
|
Routers: map[string]*dynamic.UDPRouter{
|
|
|
|
"default-test.route-0": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-0",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-01-19 08:30:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-01-19 08:30:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2020-02-26 11:28:05 +00:00
|
|
|
{
|
|
|
|
desc: "Ingress class does not match",
|
|
|
|
paths: []string{"udp/services.yml", "udp/simple.yml"},
|
|
|
|
ingressClass: "tchouk",
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-02-26 11:28:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-09-11 13:40:03 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-02-26 11:28:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2022-03-07 10:08:07 +00:00
|
|
|
{
|
|
|
|
desc: "Ingress Route, empty service disallowed",
|
|
|
|
paths: []string{"udp/services.yml", "udp/with_empty_services.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
// The router that references the invalid service will be discarded.
|
2022-03-07 10:08:07 +00:00
|
|
|
Routers: map[string]*dynamic.UDPRouter{
|
|
|
|
"default-test.route-0": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-0",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2022-03-07 10:08:07 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Ingress Route, empty service allowed",
|
|
|
|
allowEmptyServices: true,
|
|
|
|
paths: []string{"udp/services.yml", "udp/with_empty_services.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{
|
|
|
|
"default-test.route-0": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-0",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.UDPService{
|
|
|
|
"default-test.route-0": {
|
|
|
|
LoadBalancer: &dynamic.UDPServersLoadBalancer{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2022-03-07 10:08:07 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2020-02-26 11:28:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
test := test
|
|
|
|
|
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
if test.expected == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-03-07 10:08:07 +00:00
|
|
|
p := Provider{
|
|
|
|
IngressClass: test.ingressClass,
|
|
|
|
AllowCrossNamespace: true,
|
|
|
|
AllowExternalNameServices: true,
|
|
|
|
AllowEmptyServices: test.allowEmptyServices,
|
|
|
|
}
|
2020-12-10 13:58:04 +00:00
|
|
|
|
|
|
|
clientMock := newClientMock(test.paths...)
|
|
|
|
conf := p.loadConfigurationFromCRD(context.Background(), clientMock)
|
2020-02-26 11:28:05 +00:00
|
|
|
assert.Equal(t, test.expected, conf)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2020-02-28 23:13:44 +00:00
|
|
|
|
2020-02-25 09:12:04 +00:00
|
|
|
func TestParseServiceProtocol(t *testing.T) {
|
|
|
|
testCases := []struct {
|
|
|
|
desc string
|
|
|
|
scheme string
|
|
|
|
portName string
|
|
|
|
portNumber int32
|
|
|
|
expected string
|
|
|
|
expectedError bool
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
desc: "Empty scheme and name",
|
|
|
|
scheme: "",
|
|
|
|
portName: "",
|
|
|
|
portNumber: 1000,
|
|
|
|
expected: "http",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "h2c scheme and emptyname",
|
|
|
|
scheme: "h2c",
|
|
|
|
portName: "",
|
|
|
|
portNumber: 1000,
|
|
|
|
expected: "h2c",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "invalid scheme",
|
|
|
|
scheme: "foo",
|
|
|
|
portName: "",
|
|
|
|
portNumber: 1000,
|
|
|
|
expectedError: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Empty scheme and https name",
|
|
|
|
scheme: "",
|
|
|
|
portName: "https-secure",
|
|
|
|
portNumber: 1000,
|
|
|
|
expected: "https",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Empty scheme and port number",
|
|
|
|
scheme: "",
|
|
|
|
portName: "",
|
|
|
|
portNumber: 443,
|
|
|
|
expected: "https",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "https scheme",
|
|
|
|
scheme: "https",
|
|
|
|
portName: "",
|
|
|
|
portNumber: 1000,
|
|
|
|
expected: "https",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
test := test
|
|
|
|
|
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
protocol, err := parseServiceProtocol(test.scheme, test.portName, test.portNumber)
|
|
|
|
if test.expectedError {
|
|
|
|
assert.Error(t, err)
|
|
|
|
} else {
|
|
|
|
assert.Equal(t, test.expected, protocol)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2020-03-10 11:46:05 +00:00
|
|
|
|
|
|
|
func TestGetServicePort(t *testing.T) {
|
|
|
|
testCases := []struct {
|
|
|
|
desc string
|
|
|
|
svc *corev1.Service
|
2021-01-15 14:54:04 +00:00
|
|
|
port intstr.IntOrString
|
2020-03-10 11:46:05 +00:00
|
|
|
expected *corev1.ServicePort
|
|
|
|
expectError bool
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
desc: "Basic",
|
|
|
|
expectError: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Matching ports, with no service type",
|
|
|
|
svc: &corev1.Service{
|
|
|
|
Spec: corev1.ServiceSpec{
|
|
|
|
Ports: []corev1.ServicePort{
|
|
|
|
{
|
|
|
|
Port: 80,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-01-15 14:54:04 +00:00
|
|
|
port: intstr.FromInt(80),
|
2020-03-10 11:46:05 +00:00
|
|
|
expected: &corev1.ServicePort{
|
|
|
|
Port: 80,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Matching ports 0",
|
|
|
|
svc: &corev1.Service{
|
|
|
|
Spec: corev1.ServiceSpec{
|
|
|
|
Ports: []corev1.ServicePort{
|
|
|
|
{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
expectError: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Matching ports 0 (with external name)",
|
|
|
|
svc: &corev1.Service{
|
|
|
|
Spec: corev1.ServiceSpec{
|
|
|
|
Type: corev1.ServiceTypeExternalName,
|
|
|
|
Ports: []corev1.ServicePort{
|
|
|
|
{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
expectError: true,
|
|
|
|
},
|
2021-01-15 14:54:04 +00:00
|
|
|
{
|
|
|
|
desc: "Matching named port",
|
|
|
|
svc: &corev1.Service{
|
|
|
|
Spec: corev1.ServiceSpec{
|
|
|
|
Ports: []corev1.ServicePort{
|
|
|
|
{
|
|
|
|
Name: "http",
|
|
|
|
Port: 80,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
port: intstr.FromString("http"),
|
|
|
|
expected: &corev1.ServicePort{
|
|
|
|
Name: "http",
|
|
|
|
Port: 80,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Matching named port (with external name)",
|
|
|
|
svc: &corev1.Service{
|
|
|
|
Spec: corev1.ServiceSpec{
|
|
|
|
Type: corev1.ServiceTypeExternalName,
|
|
|
|
Ports: []corev1.ServicePort{
|
|
|
|
{
|
|
|
|
Name: "http",
|
|
|
|
Port: 80,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
port: intstr.FromString("http"),
|
|
|
|
expected: &corev1.ServicePort{
|
|
|
|
Name: "http",
|
|
|
|
Port: 80,
|
|
|
|
},
|
|
|
|
},
|
2020-03-10 11:46:05 +00:00
|
|
|
{
|
|
|
|
desc: "Mismatching, only port(Ingress) defined",
|
|
|
|
svc: &corev1.Service{
|
|
|
|
Spec: corev1.ServiceSpec{},
|
|
|
|
},
|
2021-01-15 14:54:04 +00:00
|
|
|
port: intstr.FromInt(80),
|
|
|
|
expectError: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Mismatching, only named port(Ingress) defined",
|
|
|
|
svc: &corev1.Service{
|
|
|
|
Spec: corev1.ServiceSpec{},
|
|
|
|
},
|
|
|
|
port: intstr.FromString("http"),
|
2020-03-10 11:46:05 +00:00
|
|
|
expectError: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Mismatching, only port(Ingress) defined with external name",
|
|
|
|
svc: &corev1.Service{
|
|
|
|
Spec: corev1.ServiceSpec{
|
|
|
|
Type: corev1.ServiceTypeExternalName,
|
|
|
|
},
|
|
|
|
},
|
2021-01-15 14:54:04 +00:00
|
|
|
port: intstr.FromInt(80),
|
2020-03-10 11:46:05 +00:00
|
|
|
expected: &corev1.ServicePort{
|
|
|
|
Port: 80,
|
|
|
|
},
|
|
|
|
},
|
2021-01-15 14:54:04 +00:00
|
|
|
{
|
|
|
|
desc: "Mismatching, only named port(Ingress) defined with external name",
|
|
|
|
svc: &corev1.Service{
|
|
|
|
Spec: corev1.ServiceSpec{
|
|
|
|
Type: corev1.ServiceTypeExternalName,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
port: intstr.FromString("http"),
|
|
|
|
expectError: true,
|
|
|
|
},
|
2020-03-10 11:46:05 +00:00
|
|
|
{
|
|
|
|
desc: "Mismatching, only Service port defined",
|
|
|
|
svc: &corev1.Service{
|
|
|
|
Spec: corev1.ServiceSpec{
|
|
|
|
Ports: []corev1.ServicePort{
|
|
|
|
{
|
|
|
|
Port: 80,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
expectError: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Mismatching, only Service port defined with external name",
|
|
|
|
svc: &corev1.Service{
|
|
|
|
Spec: corev1.ServiceSpec{
|
|
|
|
Type: corev1.ServiceTypeExternalName,
|
|
|
|
Ports: []corev1.ServicePort{
|
|
|
|
{
|
|
|
|
Port: 80,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
expectError: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Two different ports defined",
|
|
|
|
svc: &corev1.Service{
|
|
|
|
Spec: corev1.ServiceSpec{
|
|
|
|
Ports: []corev1.ServicePort{
|
|
|
|
{
|
|
|
|
Port: 80,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-01-15 14:54:04 +00:00
|
|
|
port: intstr.FromInt(443),
|
|
|
|
expectError: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Two different named ports defined",
|
|
|
|
svc: &corev1.Service{
|
|
|
|
Spec: corev1.ServiceSpec{
|
|
|
|
Ports: []corev1.ServicePort{
|
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
Port: 80,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
port: intstr.FromString("bar"),
|
2020-03-10 11:46:05 +00:00
|
|
|
expectError: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Two different ports defined (with external name)",
|
|
|
|
svc: &corev1.Service{
|
|
|
|
Spec: corev1.ServiceSpec{
|
|
|
|
Type: corev1.ServiceTypeExternalName,
|
|
|
|
Ports: []corev1.ServicePort{
|
|
|
|
{
|
|
|
|
Port: 80,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-01-15 14:54:04 +00:00
|
|
|
port: intstr.FromInt(443),
|
2020-03-10 11:46:05 +00:00
|
|
|
expected: &corev1.ServicePort{
|
|
|
|
Port: 443,
|
|
|
|
},
|
|
|
|
},
|
2021-01-15 14:54:04 +00:00
|
|
|
{
|
|
|
|
desc: "Two different named ports defined (with external name)",
|
|
|
|
svc: &corev1.Service{
|
|
|
|
Spec: corev1.ServiceSpec{
|
|
|
|
Type: corev1.ServiceTypeExternalName,
|
|
|
|
Ports: []corev1.ServicePort{
|
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
Port: 80,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
port: intstr.FromString("bar"),
|
|
|
|
expectError: true,
|
|
|
|
},
|
2020-03-10 11:46:05 +00:00
|
|
|
}
|
|
|
|
for _, test := range testCases {
|
|
|
|
test := test
|
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
actual, err := getServicePort(test.svc, test.port)
|
|
|
|
if test.expectError {
|
|
|
|
assert.Error(t, err)
|
|
|
|
} else {
|
|
|
|
assert.Equal(t, test.expected, actual)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2020-12-10 13:58:04 +00:00
|
|
|
|
|
|
|
func TestCrossNamespace(t *testing.T) {
|
|
|
|
testCases := []struct {
|
|
|
|
desc string
|
|
|
|
allowCrossNamespace bool
|
|
|
|
ingressClass string
|
|
|
|
paths []string
|
|
|
|
expected *dynamic.Configuration
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
desc: "Empty",
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-12-11 09:58:00 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "HTTP middleware cross namespace disallowed",
|
|
|
|
paths: []string{"services.yml", "with_middleware_cross_namespace.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-test-crossnamespace-route-9313b71dbe6a649d5049": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test-crossnamespace-route-9313b71dbe6a649d5049",
|
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bir`)",
|
|
|
|
Priority: 12,
|
|
|
|
Middlewares: []string{"default-test-errorpage"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{
|
|
|
|
"cross-ns-stripprefix": {
|
|
|
|
StripPrefix: &dynamic.StripPrefix{
|
2022-11-25 09:50:06 +00:00
|
|
|
Prefixes: []string{"/stripit"},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-test-crossnamespace-route-9313b71dbe6a649d5049": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "HTTP middleware cross namespace allowed",
|
|
|
|
paths: []string{"services.yml", "with_middleware_cross_namespace.yml"},
|
|
|
|
allowCrossNamespace: true,
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-test-crossnamespace-route-6b204d94623b3df4370c": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test-crossnamespace-route-6b204d94623b3df4370c",
|
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
|
|
|
Middlewares: []string{
|
|
|
|
"cross-ns-stripprefix",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-test-crossnamespace-route-9313b71dbe6a649d5049": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test-crossnamespace-route-9313b71dbe6a649d5049",
|
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bir`)",
|
|
|
|
Priority: 12,
|
|
|
|
Middlewares: []string{"default-test-errorpage"},
|
|
|
|
},
|
2021-08-05 15:42:08 +00:00
|
|
|
"default-test-crossnamespace-route-a1963878aac7331b7950": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test-crossnamespace-route-a1963878aac7331b7950",
|
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bur`)",
|
|
|
|
Priority: 12,
|
|
|
|
Middlewares: []string{"cross-ns-stripprefix@kubernetescrd"},
|
|
|
|
},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{
|
|
|
|
"cross-ns-stripprefix": {
|
|
|
|
StripPrefix: &dynamic.StripPrefix{
|
2022-11-25 09:50:06 +00:00
|
|
|
Prefixes: []string{"/stripit"},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-test-errorpage": {
|
|
|
|
Errors: &dynamic.ErrorPage{
|
|
|
|
Status: []string{"500-599"},
|
|
|
|
Service: "default-test-errorpage-errorpage-service",
|
|
|
|
Query: "/{status}.html",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-test-crossnamespace-route-6b204d94623b3df4370c": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-test-crossnamespace-route-9313b71dbe6a649d5049": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-test-errorpage-errorpage-service": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
|
|
|
},
|
2021-08-05 15:42:08 +00:00
|
|
|
"default-test-crossnamespace-route-a1963878aac7331b7950": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2021-08-05 15:42:08 +00:00
|
|
|
},
|
|
|
|
},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "HTTP cross namespace allowed",
|
|
|
|
paths: []string{"services.yml", "with_cross_namespace.yml"},
|
|
|
|
allowCrossNamespace: true,
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-cross-ns-route-6b204d94623b3df4370c": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-cross-ns-route-6b204d94623b3df4370c",
|
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
|
|
|
},
|
2021-09-16 13:12:13 +00:00
|
|
|
"default-cross-ns-route-1bc3efa892379bb93c6e": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-cross-ns-route-1bc3efa892379bb93c6e",
|
|
|
|
Rule: "Host(`bar.com`) && PathPrefix(`/foo`)",
|
|
|
|
},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-cross-ns-route-6b204d94623b3df4370c": {
|
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "cross-ns-whoami-svc-80",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "default-tr-svc-wrr1",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "cross-ns-tr-svc-wrr2",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "default-tr-svc-mirror1",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "cross-ns-tr-svc-mirror2",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-09-16 13:12:13 +00:00
|
|
|
"default-cross-ns-route-1bc3efa892379bb93c6e": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2022-11-16 10:38:07 +00:00
|
|
|
PassHostHeader: Bool(true),
|
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2021-09-20 10:54:05 +00:00
|
|
|
ServersTransport: "foo-test@kubernetescrd",
|
2021-09-16 13:12:13 +00:00
|
|
|
},
|
|
|
|
},
|
2020-12-10 13:58:04 +00:00
|
|
|
"cross-ns-whoami-svc-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-tr-svc-wrr1": {
|
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "cross-ns-whoami-svc-80",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"cross-ns-tr-svc-wrr2": {
|
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "cross-ns-whoami-svc-80",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-tr-svc-mirror1": {
|
|
|
|
Mirroring: &dynamic.Mirroring{
|
|
|
|
Service: "default-whoami-80",
|
|
|
|
Mirrors: []dynamic.MirrorService{
|
|
|
|
{
|
|
|
|
Name: "cross-ns-whoami-svc-80",
|
|
|
|
Percent: 20,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"cross-ns-tr-svc-mirror2": {
|
|
|
|
Mirroring: &dynamic.Mirroring{
|
|
|
|
Service: "cross-ns-whoami-svc-80",
|
|
|
|
Mirrors: []dynamic.MirrorService{
|
|
|
|
{
|
|
|
|
Name: "cross-ns-whoami-svc-80",
|
|
|
|
Percent: 20,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "HTTP cross namespace disallowed",
|
|
|
|
paths: []string{"services.yml", "with_cross_namespace.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
2020-12-10 13:58:04 +00:00
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"cross-ns-tr-svc-wrr2": {
|
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "cross-ns-whoami-svc-80",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"cross-ns-whoami-svc-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"cross-ns-tr-svc-mirror2": {
|
|
|
|
Mirroring: &dynamic.Mirroring{
|
|
|
|
Service: "cross-ns-whoami-svc-80",
|
|
|
|
Mirrors: []dynamic.MirrorService{
|
|
|
|
{
|
|
|
|
Name: "cross-ns-whoami-svc-80",
|
|
|
|
Percent: 20,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2021-09-20 10:54:05 +00:00
|
|
|
{
|
|
|
|
desc: "HTTP ServersTransport cross namespace allowed",
|
|
|
|
paths: []string{"services.yml", "with_servers_transport_cross_namespace.yml"},
|
|
|
|
allowCrossNamespace: true,
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-09-20 10:54:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test-route-6b204d94623b3df4370c",
|
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2022-11-16 10:38:07 +00:00
|
|
|
PassHostHeader: Bool(true),
|
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2021-09-20 10:54:05 +00:00
|
|
|
ServersTransport: "cross-ns-st-cross-ns@kubernetescrd",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{
|
|
|
|
"cross-ns-st-cross-ns": {
|
|
|
|
ForwardingTimeouts: &dynamic.ForwardingTimeouts{
|
|
|
|
DialTimeout: 30000000000,
|
|
|
|
ResponseHeaderTimeout: 0,
|
|
|
|
IdleConnTimeout: 90000000000,
|
2021-11-09 11:16:08 +00:00
|
|
|
ReadIdleTimeout: 0,
|
|
|
|
PingTimeout: 15000000000,
|
2021-09-20 10:54:05 +00:00
|
|
|
},
|
|
|
|
DisableHTTP2: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "HTTP ServersTransport cross namespace disallowed",
|
|
|
|
paths: []string{"services.yml", "with_servers_transport_cross_namespace.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-09-20 10:54:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{
|
|
|
|
"cross-ns-st-cross-ns": {
|
|
|
|
ForwardingTimeouts: &dynamic.ForwardingTimeouts{
|
|
|
|
DialTimeout: 30000000000,
|
|
|
|
ResponseHeaderTimeout: 0,
|
|
|
|
IdleConnTimeout: 90000000000,
|
2021-11-09 11:16:08 +00:00
|
|
|
ReadIdleTimeout: 0,
|
|
|
|
PingTimeout: 15000000000,
|
2021-09-20 10:54:05 +00:00
|
|
|
},
|
|
|
|
DisableHTTP2: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "HTTP TLSOption cross namespace allowed",
|
|
|
|
paths: []string{"services.yml", "with_tls_options_cross_namespace.yml"},
|
|
|
|
allowCrossNamespace: true,
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-09-20 10:54:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test-route-6b204d94623b3df4370c",
|
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
|
|
|
TLS: &dynamic.RouterTLSConfig{
|
|
|
|
Options: "cross-ns-tls-options-cn",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2021-09-20 10:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Options: map[string]tls.Options{
|
|
|
|
"cross-ns-tls-options-cn": {
|
|
|
|
MinVersion: "VersionTLS12",
|
|
|
|
ALPNProtocols: []string{"h2", "http/1.1", "acme-tls/1"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "HTTP TLSOption cross namespace disallowed",
|
|
|
|
paths: []string{"services.yml", "with_tls_options_cross_namespace.yml"},
|
|
|
|
allowCrossNamespace: false,
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-09-20 10:54:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-test-route-6b204d94623b3df4370c": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2021-09-20 10:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Options: map[string]tls.Options{
|
|
|
|
"cross-ns-tls-options-cn": {
|
|
|
|
MinVersion: "VersionTLS12",
|
|
|
|
ALPNProtocols: []string{"h2", "http/1.1", "acme-tls/1"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
{
|
|
|
|
desc: "TCP middleware cross namespace disallowed",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_middleware_with_cross_namespace.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
2022-10-26 15:16:05 +00:00
|
|
|
Middlewares: []string{"default-ipallowlist"},
|
2021-06-11 13:30:05 +00:00
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{
|
2022-10-26 15:16:05 +00:00
|
|
|
"default-ipallowlist": {
|
|
|
|
IPAllowList: &dynamic.TCPIPAllowList{
|
2021-06-11 13:30:05 +00:00
|
|
|
SourceRange: []string{"127.0.0.1/32"},
|
|
|
|
},
|
|
|
|
},
|
2022-10-26 15:16:05 +00:00
|
|
|
"cross-ns-ipallowlist": {
|
|
|
|
IPAllowList: &dynamic.TCPIPAllowList{
|
2021-06-11 13:30:05 +00:00
|
|
|
SourceRange: []string{"127.0.0.1/32"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.TCPService{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-06-11 13:30:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-06-11 13:30:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TCP middleware cross namespace allowed",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_middleware_with_cross_namespace.yml"},
|
|
|
|
allowCrossNamespace: true,
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
2022-10-26 15:16:05 +00:00
|
|
|
Middlewares: []string{"default-ipallowlist"},
|
2021-06-11 13:30:05 +00:00
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
},
|
|
|
|
"default-test.route-f44ce589164e656d231c": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-f44ce589164e656d231c",
|
2022-10-26 15:16:05 +00:00
|
|
|
Middlewares: []string{"cross-ns-ipallowlist"},
|
2021-06-11 13:30:05 +00:00
|
|
|
Rule: "HostSNI(`bar.com`)",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{
|
2022-10-26 15:16:05 +00:00
|
|
|
"default-ipallowlist": {
|
|
|
|
IPAllowList: &dynamic.TCPIPAllowList{
|
2021-06-11 13:30:05 +00:00
|
|
|
SourceRange: []string{"127.0.0.1/32"},
|
|
|
|
},
|
|
|
|
},
|
2022-10-26 15:16:05 +00:00
|
|
|
"cross-ns-ipallowlist": {
|
|
|
|
IPAllowList: &dynamic.TCPIPAllowList{
|
2021-06-11 13:30:05 +00:00
|
|
|
SourceRange: []string{"127.0.0.1/32"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.TCPService{
|
|
|
|
"default-test.route-f44ce589164e656d231c": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-06-11 13:30:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-06-11 13:30:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2020-12-10 13:58:04 +00:00
|
|
|
{
|
|
|
|
desc: "TCP cross namespace allowed",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_cross_namespace.yml"},
|
|
|
|
allowCrossNamespace: true,
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-12-11 09:58:00 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2020-12-10 13:58:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TCP cross namespace disallowed",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_cross_namespace.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
// The router that references the invalid service will be discarded.
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TCP ServersTransport cross namespace allowed",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_servers_transport_cross_namespace.yml"},
|
|
|
|
allowCrossNamespace: true,
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
Priority: 12,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransport: "cross-ns-st-cross-ns@kubernetescrd",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{
|
|
|
|
"cross-ns-st-cross-ns": {
|
|
|
|
DialTimeout: ptypes.Duration(30 * time.Second),
|
|
|
|
DialKeepAlive: 0,
|
|
|
|
TerminationDelay: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TCP ServersTransport cross namespace disallowed",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_servers_transport_cross_namespace.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
// The router that references the invalid service will be discarded.
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
Priority: 12,
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{
|
|
|
|
"cross-ns-st-cross-ns": {
|
|
|
|
DialTimeout: 30000000000,
|
|
|
|
DialKeepAlive: 0,
|
|
|
|
TerminationDelay: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
|
|
|
},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-12-11 09:58:00 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2021-09-20 10:54:05 +00:00
|
|
|
{
|
|
|
|
desc: "TCP TLSOption cross namespace allowed",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_tls_options_cross_namespace.yml"},
|
|
|
|
allowCrossNamespace: true,
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
|
|
|
Options: "cross-ns-tls-options-cn",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-09-20 10:54:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Options: map[string]tls.Options{
|
|
|
|
"cross-ns-tls-options-cn": {
|
|
|
|
MinVersion: "VersionTLS12",
|
|
|
|
ALPNProtocols: []string{"h2", "http/1.1", "acme-tls/1"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TCP TLSOption cross namespace disallowed",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_tls_options_cross_namespace.yml"},
|
|
|
|
allowCrossNamespace: false,
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-09-20 10:54:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Options: map[string]tls.Options{
|
|
|
|
"cross-ns-tls-options-cn": {
|
|
|
|
MinVersion: "VersionTLS12",
|
|
|
|
ALPNProtocols: []string{"h2", "http/1.1", "acme-tls/1"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-12-10 13:58:04 +00:00
|
|
|
{
|
|
|
|
desc: "UDP cross namespace allowed",
|
|
|
|
paths: []string{"udp/services.yml", "udp/with_cross_namespace.yml"},
|
|
|
|
allowCrossNamespace: true,
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{
|
|
|
|
"default-test.route-0": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-0",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.UDPService{
|
|
|
|
"default-test.route-0": {
|
|
|
|
LoadBalancer: &dynamic.UDPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.UDPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-12-11 09:58:00 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "UDP cross namespace disallowed",
|
|
|
|
paths: []string{"udp/services.yml", "udp/with_cross_namespace.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
// The router that references the invalid service will be discarded.
|
2020-12-10 13:58:04 +00:00
|
|
|
Routers: map[string]*dynamic.UDPRouter{
|
|
|
|
"default-test.route-0": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-0",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2020-12-11 09:58:00 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-12-10 13:58:04 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
test := test
|
|
|
|
|
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
var k8sObjects []runtime.Object
|
|
|
|
var crdObjects []runtime.Object
|
|
|
|
for _, path := range test.paths {
|
2021-03-04 19:08:03 +00:00
|
|
|
yamlContent, err := os.ReadFile(filepath.FromSlash("./fixtures/" + path))
|
2020-12-10 13:58:04 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
objects := k8s.MustParseYaml(yamlContent)
|
|
|
|
for _, obj := range objects {
|
|
|
|
switch o := obj.(type) {
|
|
|
|
case *corev1.Service, *corev1.Endpoints, *corev1.Secret:
|
|
|
|
k8sObjects = append(k8sObjects, o)
|
2023-04-17 08:56:36 +00:00
|
|
|
case *traefikv1alpha1.IngressRoute:
|
2020-12-10 13:58:04 +00:00
|
|
|
crdObjects = append(crdObjects, o)
|
2023-04-17 08:56:36 +00:00
|
|
|
case *traefikv1alpha1.IngressRouteTCP:
|
2020-12-10 13:58:04 +00:00
|
|
|
crdObjects = append(crdObjects, o)
|
2023-04-17 08:56:36 +00:00
|
|
|
case *traefikv1alpha1.IngressRouteUDP:
|
2020-12-10 13:58:04 +00:00
|
|
|
crdObjects = append(crdObjects, o)
|
2023-04-17 08:56:36 +00:00
|
|
|
case *traefikv1alpha1.Middleware:
|
2020-12-10 13:58:04 +00:00
|
|
|
crdObjects = append(crdObjects, o)
|
2023-04-17 08:56:36 +00:00
|
|
|
case *traefikv1alpha1.MiddlewareTCP:
|
2021-06-11 13:30:05 +00:00
|
|
|
crdObjects = append(crdObjects, o)
|
2023-04-17 08:56:36 +00:00
|
|
|
case *traefikv1alpha1.TraefikService:
|
2020-12-10 13:58:04 +00:00
|
|
|
crdObjects = append(crdObjects, o)
|
2023-04-17 08:56:36 +00:00
|
|
|
case *traefikv1alpha1.TLSOption:
|
2020-12-10 13:58:04 +00:00
|
|
|
crdObjects = append(crdObjects, o)
|
2023-04-17 08:56:36 +00:00
|
|
|
case *traefikv1alpha1.TLSStore:
|
2020-12-10 13:58:04 +00:00
|
|
|
crdObjects = append(crdObjects, o)
|
2023-04-17 08:56:36 +00:00
|
|
|
case *traefikv1alpha1.ServersTransport:
|
2021-09-20 10:54:05 +00:00
|
|
|
crdObjects = append(crdObjects, o)
|
2023-04-17 08:56:36 +00:00
|
|
|
case *traefikv1alpha1.ServersTransportTCP:
|
2022-12-09 08:58:05 +00:00
|
|
|
crdObjects = append(crdObjects, o)
|
2020-12-10 13:58:04 +00:00
|
|
|
default:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
kubeClient := kubefake.NewSimpleClientset(k8sObjects...)
|
2023-04-17 08:56:36 +00:00
|
|
|
crdClient := traefikcrdfake.NewSimpleClientset(crdObjects...)
|
2020-12-10 13:58:04 +00:00
|
|
|
|
|
|
|
client := newClientImpl(kubeClient, crdClient)
|
|
|
|
|
|
|
|
stopCh := make(chan struct{})
|
|
|
|
|
|
|
|
eventCh, err := client.WatchAll([]string{"default", "cross-ns"}, stopCh)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
if k8sObjects != nil || crdObjects != nil {
|
|
|
|
// just wait for the first event
|
|
|
|
<-eventCh
|
|
|
|
}
|
|
|
|
|
2021-07-13 10:54:09 +00:00
|
|
|
p := Provider{AllowCrossNamespace: test.allowCrossNamespace}
|
|
|
|
|
|
|
|
conf := p.loadConfigurationFromCRD(context.Background(), client)
|
|
|
|
assert.Equal(t, test.expected, conf)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestExternalNameService(t *testing.T) {
|
|
|
|
testCases := []struct {
|
|
|
|
desc string
|
|
|
|
allowExternalNameService bool
|
|
|
|
ingressClass string
|
|
|
|
paths []string
|
|
|
|
expected *dynamic.Configuration
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
desc: "Empty",
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-07-13 10:54:09 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "HTTP ExternalName services allowed",
|
|
|
|
paths: []string{"services.yml", "with_externalname_with_http.yml"},
|
|
|
|
allowExternalNameService: true,
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-07-13 10:54:09 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-test-route-6f97418635c7e18853da": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test-route-6f97418635c7e18853da",
|
|
|
|
Rule: "Host(`foo.com`)",
|
|
|
|
Priority: 0,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-test-route-6f97418635c7e18853da": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://external.domain:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2021-07-13 10:54:09 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "HTTP Externalname services disallowed",
|
|
|
|
paths: []string{"services.yml", "with_externalname_with_http.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-07-13 10:54:09 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TCP ExternalName services allowed",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_externalname_with_port.yml"},
|
|
|
|
allowExternalNameService: true,
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
2021-07-13 16:12:29 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2021-07-13 10:54:09 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "external.domain:80",
|
|
|
|
Port: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-07-13 10:54:09 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TCP ExternalName services disallowed",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_externalname_with_port.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
// The router that references the invalid service will be discarded.
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-07-13 10:54:09 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "UDP ExternalName services allowed",
|
|
|
|
paths: []string{"udp/services.yml", "udp/with_externalname_service.yml"},
|
|
|
|
allowExternalNameService: true,
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{
|
|
|
|
"default-test.route-0": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-0",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.UDPService{
|
|
|
|
"default-test.route-0": {
|
|
|
|
LoadBalancer: &dynamic.UDPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.UDPServer{
|
|
|
|
{
|
|
|
|
Address: "external.domain:80",
|
|
|
|
Port: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-07-13 10:54:09 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "UDP ExternalName service disallowed",
|
|
|
|
paths: []string{"udp/services.yml", "udp/with_externalname_service.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
// The router that references the invalid service will be discarded.
|
2021-07-13 10:54:09 +00:00
|
|
|
Routers: map[string]*dynamic.UDPRouter{
|
|
|
|
"default-test.route-0": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-0",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-07-13 10:54:09 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
test := test
|
|
|
|
|
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
var k8sObjects []runtime.Object
|
|
|
|
var crdObjects []runtime.Object
|
|
|
|
for _, path := range test.paths {
|
|
|
|
yamlContent, err := os.ReadFile(filepath.FromSlash("./fixtures/" + path))
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
objects := k8s.MustParseYaml(yamlContent)
|
|
|
|
for _, obj := range objects {
|
|
|
|
switch o := obj.(type) {
|
|
|
|
case *corev1.Service, *corev1.Endpoints, *corev1.Secret:
|
|
|
|
k8sObjects = append(k8sObjects, o)
|
2023-04-17 08:56:36 +00:00
|
|
|
case *traefikv1alpha1.IngressRoute:
|
2021-07-13 10:54:09 +00:00
|
|
|
crdObjects = append(crdObjects, o)
|
2023-04-17 08:56:36 +00:00
|
|
|
case *traefikv1alpha1.IngressRouteTCP:
|
2021-07-13 10:54:09 +00:00
|
|
|
crdObjects = append(crdObjects, o)
|
2023-04-17 08:56:36 +00:00
|
|
|
case *traefikv1alpha1.IngressRouteUDP:
|
2021-07-13 10:54:09 +00:00
|
|
|
crdObjects = append(crdObjects, o)
|
2023-04-17 08:56:36 +00:00
|
|
|
case *traefikv1alpha1.Middleware:
|
2021-07-13 10:54:09 +00:00
|
|
|
crdObjects = append(crdObjects, o)
|
2023-04-17 08:56:36 +00:00
|
|
|
case *traefikv1alpha1.TraefikService:
|
2021-07-13 10:54:09 +00:00
|
|
|
crdObjects = append(crdObjects, o)
|
2023-04-17 08:56:36 +00:00
|
|
|
case *traefikv1alpha1.TLSOption:
|
2021-07-13 10:54:09 +00:00
|
|
|
crdObjects = append(crdObjects, o)
|
2023-04-17 08:56:36 +00:00
|
|
|
case *traefikv1alpha1.TLSStore:
|
2021-07-13 10:54:09 +00:00
|
|
|
crdObjects = append(crdObjects, o)
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
kubeClient := kubefake.NewSimpleClientset(k8sObjects...)
|
2023-04-17 08:56:36 +00:00
|
|
|
crdClient := traefikcrdfake.NewSimpleClientset(crdObjects...)
|
2021-07-13 10:54:09 +00:00
|
|
|
|
|
|
|
client := newClientImpl(kubeClient, crdClient)
|
|
|
|
|
|
|
|
stopCh := make(chan struct{})
|
|
|
|
|
|
|
|
eventCh, err := client.WatchAll([]string{"default", "cross-ns"}, stopCh)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
if k8sObjects != nil || crdObjects != nil {
|
|
|
|
// just wait for the first event
|
|
|
|
<-eventCh
|
|
|
|
}
|
|
|
|
|
|
|
|
p := Provider{AllowExternalNameServices: test.allowExternalNameService}
|
2020-12-10 13:58:04 +00:00
|
|
|
|
|
|
|
conf := p.loadConfigurationFromCRD(context.Background(), client)
|
2023-03-20 15:46:05 +00:00
|
|
|
assert.Equal(t, test.expected, conf)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNativeLB(t *testing.T) {
|
|
|
|
testCases := []struct {
|
|
|
|
desc string
|
|
|
|
ingressClass string
|
|
|
|
paths []string
|
|
|
|
expected *dynamic.Configuration
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
desc: "Empty",
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2023-03-21 11:00:46 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
2023-03-20 15:46:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "HTTP with native Service LB",
|
|
|
|
paths: []string{"services.yml", "with_native_service_lb.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2023-03-21 11:00:46 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
2023-03-20 15:46:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-test-route-6f97418635c7e18853da": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test-route-6f97418635c7e18853da",
|
|
|
|
Rule: "Host(`foo.com`)",
|
|
|
|
Priority: 0,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-test-route-6f97418635c7e18853da": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2023-03-21 11:00:46 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{FlushInterval: dynamic.DefaultFlushInterval},
|
2023-03-20 15:46:05 +00:00
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TCP with native Service LB",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_native_service_lb.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2023-03-21 11:00:46 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2023-03-20 15:46:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{
|
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
Port: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "UDP with native Service LB",
|
|
|
|
paths: []string{"udp/services.yml", "udp/with_native_service_lb.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{
|
|
|
|
"default-test.route-0": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "default-test.route-0",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.UDPService{
|
|
|
|
"default-test.route-0": {
|
|
|
|
LoadBalancer: &dynamic.UDPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.UDPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
Port: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2023-03-21 11:00:46 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
2023-03-20 15:46:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
test := test
|
|
|
|
|
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
var k8sObjects []runtime.Object
|
|
|
|
var crdObjects []runtime.Object
|
|
|
|
for _, path := range test.paths {
|
|
|
|
yamlContent, err := os.ReadFile(filepath.FromSlash("./fixtures/" + path))
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
objects := k8s.MustParseYaml(yamlContent)
|
|
|
|
for _, obj := range objects {
|
|
|
|
switch o := obj.(type) {
|
|
|
|
case *corev1.Service, *corev1.Endpoints, *corev1.Secret:
|
|
|
|
k8sObjects = append(k8sObjects, o)
|
2023-04-17 08:56:36 +00:00
|
|
|
case *traefikv1alpha1.IngressRoute:
|
2023-03-20 15:46:05 +00:00
|
|
|
crdObjects = append(crdObjects, o)
|
2023-04-17 08:56:36 +00:00
|
|
|
case *traefikv1alpha1.IngressRouteTCP:
|
2023-03-20 15:46:05 +00:00
|
|
|
crdObjects = append(crdObjects, o)
|
2023-04-17 08:56:36 +00:00
|
|
|
case *traefikv1alpha1.IngressRouteUDP:
|
2023-03-20 15:46:05 +00:00
|
|
|
crdObjects = append(crdObjects, o)
|
2023-04-17 08:56:36 +00:00
|
|
|
case *traefikv1alpha1.Middleware:
|
2023-03-20 15:46:05 +00:00
|
|
|
crdObjects = append(crdObjects, o)
|
2023-04-17 08:56:36 +00:00
|
|
|
case *traefikv1alpha1.TraefikService:
|
2023-03-20 15:46:05 +00:00
|
|
|
crdObjects = append(crdObjects, o)
|
2023-04-17 08:56:36 +00:00
|
|
|
case *traefikv1alpha1.TLSOption:
|
2023-03-20 15:46:05 +00:00
|
|
|
crdObjects = append(crdObjects, o)
|
2023-04-17 08:56:36 +00:00
|
|
|
case *traefikv1alpha1.TLSStore:
|
2023-03-20 15:46:05 +00:00
|
|
|
crdObjects = append(crdObjects, o)
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
kubeClient := kubefake.NewSimpleClientset(k8sObjects...)
|
2023-04-17 08:56:36 +00:00
|
|
|
crdClient := traefikcrdfake.NewSimpleClientset(crdObjects...)
|
2023-03-20 15:46:05 +00:00
|
|
|
|
|
|
|
client := newClientImpl(kubeClient, crdClient)
|
|
|
|
|
|
|
|
stopCh := make(chan struct{})
|
|
|
|
|
|
|
|
eventCh, err := client.WatchAll([]string{"default", "cross-ns"}, stopCh)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
if k8sObjects != nil || crdObjects != nil {
|
|
|
|
// just wait for the first event
|
|
|
|
<-eventCh
|
|
|
|
}
|
|
|
|
|
|
|
|
p := Provider{}
|
|
|
|
|
|
|
|
conf := p.loadConfigurationFromCRD(context.Background(), client)
|
2020-12-10 13:58:04 +00:00
|
|
|
assert.Equal(t, test.expected, conf)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2021-09-14 13:16:11 +00:00
|
|
|
|
|
|
|
func TestCreateBasicAuthCredentials(t *testing.T) {
|
|
|
|
var k8sObjects []runtime.Object
|
|
|
|
yamlContent, err := os.ReadFile(filepath.FromSlash("./fixtures/basic_auth_secrets.yml"))
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
objects := k8s.MustParseYaml(yamlContent)
|
|
|
|
for _, obj := range objects {
|
|
|
|
switch o := obj.(type) {
|
|
|
|
case *corev1.Secret:
|
|
|
|
k8sObjects = append(k8sObjects, o)
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
kubeClient := kubefake.NewSimpleClientset(k8sObjects...)
|
2023-04-03 08:06:06 +00:00
|
|
|
crdClient := traefikcrdfake.NewSimpleClientset()
|
2021-09-14 13:16:11 +00:00
|
|
|
|
|
|
|
client := newClientImpl(kubeClient, crdClient)
|
|
|
|
|
|
|
|
stopCh := make(chan struct{})
|
|
|
|
|
|
|
|
eventCh, err := client.WatchAll([]string{"default"}, stopCh)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2023-04-17 09:34:00 +00:00
|
|
|
if len(k8sObjects) != 0 {
|
2021-09-14 13:16:11 +00:00
|
|
|
// just wait for the first event
|
|
|
|
<-eventCh
|
|
|
|
}
|
|
|
|
|
|
|
|
// Testing for username/password components in basic-auth secret
|
2023-04-17 08:56:36 +00:00
|
|
|
basicAuth, secretErr := createBasicAuthMiddleware(client, "default", &traefikv1alpha1.BasicAuth{Secret: "basic-auth-secret"})
|
2021-09-14 13:16:11 +00:00
|
|
|
require.NoError(t, secretErr)
|
|
|
|
require.Len(t, basicAuth.Users, 1)
|
|
|
|
|
|
|
|
components := strings.Split(basicAuth.Users[0], ":")
|
|
|
|
require.Len(t, components, 2)
|
|
|
|
|
|
|
|
username := components[0]
|
|
|
|
hashedPassword := components[1]
|
|
|
|
|
|
|
|
require.Equal(t, "user", username)
|
|
|
|
require.Equal(t, "{SHA}W6ph5Mm5Pz8GgiULbPgzG37mj9g=", hashedPassword)
|
|
|
|
assert.True(t, auth.CheckSecret("password", hashedPassword))
|
|
|
|
|
|
|
|
// Testing for username/password components in htpasswd secret
|
2023-04-17 08:56:36 +00:00
|
|
|
basicAuth, secretErr = createBasicAuthMiddleware(client, "default", &traefikv1alpha1.BasicAuth{Secret: "auth-secret"})
|
2021-09-14 13:16:11 +00:00
|
|
|
require.NoError(t, secretErr)
|
|
|
|
require.Len(t, basicAuth.Users, 2)
|
|
|
|
|
|
|
|
components = strings.Split(basicAuth.Users[1], ":")
|
|
|
|
require.Len(t, components, 2)
|
|
|
|
|
|
|
|
username = components[0]
|
|
|
|
hashedPassword = components[1]
|
|
|
|
|
2023-11-17 00:50:06 +00:00
|
|
|
assert.Equal(t, "test2", username)
|
|
|
|
assert.Equal(t, "$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0", hashedPassword)
|
2021-09-14 13:16:11 +00:00
|
|
|
assert.True(t, auth.CheckSecret("test2", hashedPassword))
|
|
|
|
}
|