mirror of
https://github.com/containous/traefik.git
synced 2024-12-22 13:34:03 +03:00
Disable IngressClass lookup when disableClusterScopeResources is enabled
This commit is contained in:
parent
e62f8af23b
commit
c02b72ca51
@ -219,7 +219,7 @@ func (p *Provider) loadConfigurationFromIngresses(ctx context.Context, client Cl
|
||||
|
||||
var ingressClasses []*netv1.IngressClass
|
||||
|
||||
if !p.DisableIngressClassLookup {
|
||||
if !p.DisableIngressClassLookup && !p.DisableClusterScopeResources {
|
||||
ics, err := client.GetIngressClasses()
|
||||
if err != nil {
|
||||
log.Ctx(ctx).Warn().Err(err).Msg("Failed to list ingress classes")
|
||||
|
@ -31,6 +31,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
||||
expected *dynamic.Configuration
|
||||
allowEmptyServices bool
|
||||
disableIngressClassLookup bool
|
||||
disableClusterScopeResources bool
|
||||
}{
|
||||
{
|
||||
desc: "Empty ingresses",
|
||||
@ -1335,6 +1336,38 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
// Duplicate test case with the same fixture as the one above, but with the disableClusterScopeResources option to true.
|
||||
// Showing that disabling the ingressClass discovery still allow the discovery of ingresses with ingress annotation.
|
||||
desc: "Ingress with ingress annotation",
|
||||
disableClusterScopeResources: true,
|
||||
expected: &dynamic.Configuration{
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
},
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing-service1-80": {
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
PassHostHeader: Bool(true),
|
||||
ResponseForwarding: &dynamic.ResponseForwarding{
|
||||
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
||||
},
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "Ingress with ingressClass",
|
||||
expected: &dynamic.Configuration{
|
||||
@ -1377,6 +1410,19 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
// Duplicate test case with the same fixture as the one above, but with the disableClusterScopeResources option to true.
|
||||
// Showing that disabling the ingressClass discovery avoid discovering Ingresses with an IngressClass.
|
||||
desc: "Ingress with ingressClass",
|
||||
disableClusterScopeResources: true,
|
||||
expected: &dynamic.Configuration{
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{},
|
||||
Services: map[string]*dynamic.Service{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "Ingress with named port",
|
||||
expected: &dynamic.Configuration{
|
||||
@ -1458,6 +1504,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
||||
IngressClass: test.ingressClass,
|
||||
AllowEmptyServices: test.allowEmptyServices,
|
||||
DisableIngressClassLookup: test.disableIngressClassLookup,
|
||||
DisableClusterScopeResources: test.disableClusterScopeResources,
|
||||
}
|
||||
conf := p.loadConfigurationFromIngresses(context.Background(), clientMock)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user