Fix log msgs about label selector
This commit is contained in:
parent
c4b7e8f288
commit
f99a473436
2 changed files with 12 additions and 12 deletions
|
@ -65,7 +65,7 @@ type clientWrapper struct {
|
||||||
factoriesCrd map[string]externalversions.SharedInformerFactory
|
factoriesCrd map[string]externalversions.SharedInformerFactory
|
||||||
factoriesKube map[string]informers.SharedInformerFactory
|
factoriesKube map[string]informers.SharedInformerFactory
|
||||||
|
|
||||||
ingressLabelSelector labels.Selector
|
labelSelector labels.Selector
|
||||||
|
|
||||||
isNamespaceAll bool
|
isNamespaceAll bool
|
||||||
watchedNamespaces k8s.Namespaces
|
watchedNamespaces k8s.Namespaces
|
||||||
|
@ -202,7 +202,7 @@ func (c *clientWrapper) GetIngressRoutes() []*v1alpha1.IngressRoute {
|
||||||
var result []*v1alpha1.IngressRoute
|
var result []*v1alpha1.IngressRoute
|
||||||
|
|
||||||
for ns, factory := range c.factoriesCrd {
|
for ns, factory := range c.factoriesCrd {
|
||||||
ings, err := factory.Traefik().V1alpha1().IngressRoutes().Lister().List(c.ingressLabelSelector)
|
ings, err := factory.Traefik().V1alpha1().IngressRoutes().Lister().List(c.labelSelector)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Failed to list ingresses in namespace %s: %s", ns, err)
|
log.Errorf("Failed to list ingresses in namespace %s: %s", ns, err)
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,7 @@ func (c *clientWrapper) GetMiddlewares() []*v1alpha1.Middleware {
|
||||||
var result []*v1alpha1.Middleware
|
var result []*v1alpha1.Middleware
|
||||||
|
|
||||||
for ns, factory := range c.factoriesCrd {
|
for ns, factory := range c.factoriesCrd {
|
||||||
ings, err := factory.Traefik().V1alpha1().Middlewares().Lister().List(c.ingressLabelSelector)
|
ings, err := factory.Traefik().V1alpha1().Middlewares().Lister().List(c.labelSelector)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Failed to list ingresses in namespace %s: %s", ns, err)
|
log.Errorf("Failed to list ingresses in namespace %s: %s", ns, err)
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ func (c *clientWrapper) GetMiddlewares() []*v1alpha1.Middleware {
|
||||||
func (c *clientWrapper) GetIngresses() []*extensionsv1beta1.Ingress {
|
func (c *clientWrapper) GetIngresses() []*extensionsv1beta1.Ingress {
|
||||||
var result []*extensionsv1beta1.Ingress
|
var result []*extensionsv1beta1.Ingress
|
||||||
for ns, factory := range c.factoriesKube {
|
for ns, factory := range c.factoriesKube {
|
||||||
ings, err := factory.Extensions().V1beta1().Ingresses().Lister().List(c.ingressLabelSelector)
|
ings, err := factory.Extensions().V1beta1().Ingresses().Lister().List(c.labelSelector)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Failed to list ingresses in namespace %s: %s", ns, err)
|
log.Errorf("Failed to list ingresses in namespace %s: %s", ns, err)
|
||||||
}
|
}
|
||||||
|
@ -320,7 +320,7 @@ func (c *clientWrapper) newResourceEventHandler(events chan<- interface{}) cache
|
||||||
// Ignore Ingresses that do not match our custom label selector.
|
// Ignore Ingresses that do not match our custom label selector.
|
||||||
if ing, ok := obj.(*extensionsv1beta1.Ingress); ok {
|
if ing, ok := obj.(*extensionsv1beta1.Ingress); ok {
|
||||||
lbls := labels.Set(ing.GetLabels())
|
lbls := labels.Set(ing.GetLabels())
|
||||||
return c.ingressLabelSelector.Matches(lbls)
|
return c.labelSelector.Matches(lbls)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
|
|
|
@ -39,17 +39,17 @@ type Provider struct {
|
||||||
CertAuthFilePath string `description:"Kubernetes certificate authority file path (not needed for in-cluster client)"`
|
CertAuthFilePath string `description:"Kubernetes certificate authority file path (not needed for in-cluster client)"`
|
||||||
DisablePassHostHeaders bool `description:"Kubernetes disable PassHost Headers" export:"true"`
|
DisablePassHostHeaders bool `description:"Kubernetes disable PassHost Headers" export:"true"`
|
||||||
Namespaces k8s.Namespaces `description:"Kubernetes namespaces" export:"true"`
|
Namespaces k8s.Namespaces `description:"Kubernetes namespaces" export:"true"`
|
||||||
LabelSelector string `description:"Kubernetes Ingress label selector to use" export:"true"`
|
LabelSelector string `description:"Kubernetes label selector to use" export:"true"`
|
||||||
IngressClass string `description:"Value of kubernetes.io/ingress.class annotation to watch for" export:"true"`
|
IngressClass string `description:"Value of kubernetes.io/ingress.class annotation to watch for" export:"true"`
|
||||||
lastConfiguration safe.Safe
|
lastConfiguration safe.Safe
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Provider) newK8sClient(ctx context.Context, ingressLabelSelector string) (*clientWrapper, error) {
|
func (p *Provider) newK8sClient(ctx context.Context, labelSelector string) (*clientWrapper, error) {
|
||||||
ingLabelSel, err := labels.Parse(ingressLabelSelector)
|
labelSel, err := labels.Parse(labelSelector)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("invalid ingress label selector: %q", ingressLabelSelector)
|
return nil, fmt.Errorf("invalid label selector: %q", labelSelector)
|
||||||
}
|
}
|
||||||
log.FromContext(ctx).Infof("ingress label selector is: %q", ingLabelSel)
|
log.FromContext(ctx).Infof("label selector is: %q", labelSel)
|
||||||
|
|
||||||
withEndpoint := ""
|
withEndpoint := ""
|
||||||
if p.Endpoint != "" {
|
if p.Endpoint != "" {
|
||||||
|
@ -70,7 +70,7 @@ func (p *Provider) newK8sClient(ctx context.Context, ingressLabelSelector string
|
||||||
}
|
}
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
client.ingressLabelSelector = ingLabelSel
|
client.labelSelector = labelSel
|
||||||
}
|
}
|
||||||
|
|
||||||
return client, err
|
return client, err
|
||||||
|
@ -95,7 +95,7 @@ func (p *Provider) Provide(configurationChan chan<- config.Message, pool *safe.P
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Debugf("Using Ingress label selector: %q", p.LabelSelector)
|
logger.Debugf("Using label selector: %q", p.LabelSelector)
|
||||||
k8sClient, err := p.newK8sClient(ctxLog, p.LabelSelector)
|
k8sClient, err := p.newK8sClient(ctxLog, p.LabelSelector)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in a new issue