@@ -574,12 +574,19 @@ func challengeHostnameIndexFunc(obj interface{}) ([]string, error) {
574
574
}
575
575
576
576
func checkServiceHostnameAnnotation (annotation string , service * core.Service ) (string , bool ) {
577
+ var res string
578
+
577
579
if annotationValue , exists := service .Annotations [annotation ]; exists {
580
+ // Looking for wildcard hostname
581
+ if strings .HasPrefix (annotationValue , "*." ) {
582
+ res = "*."
583
+ annotationValue = strings .TrimPrefix (annotationValue , "*." )
584
+ }
578
585
// checking the hostname length limits
579
586
if _ , ok := dns .IsDomainName (annotationValue ); ok {
580
587
// checking RFC 1123 conformance (same as metadata labels)
581
588
if valid := isdns1123Hostname (annotationValue ); valid {
582
- return strings .ToLower (annotationValue ), true
589
+ return res + strings .ToLower (annotationValue ), true
583
590
} else {
584
591
log .Infof ("RFC 1123 conformance failed for FQDN: %s" , annotationValue )
585
592
}
@@ -630,8 +637,21 @@ func lookupServiceIndex(ctrl cache.SharedIndexInformer) func([]string) []interfa
630
637
return func (indexKeys []string ) (result []interface {}) {
631
638
var objs []interface {}
632
639
for _ , key := range indexKeys {
633
- obj , _ := ctrl .GetIndexer ().ByIndex (serviceHostnameIndex , strings .ToLower (key ))
640
+ key := strings .ToLower (key )
641
+
642
+ obj , _ := ctrl .GetIndexer ().ByIndex (serviceHostnameIndex , key )
634
643
objs = append (objs , obj ... )
644
+
645
+ for len (objs ) == 0 {
646
+ _ , after , found := strings .Cut (key , "." )
647
+ if ! found {
648
+ // No more wildcard recursion
649
+ break
650
+ }
651
+ key = after
652
+ obj , _ := ctrl .GetIndexer ().ByIndex (serviceHostnameIndex , "*." + key )
653
+ objs = append (objs , obj ... )
654
+ }
635
655
}
636
656
log .Debugf ("Found %d matching Service objects" , len (objs ))
637
657
for _ , obj := range objs {
@@ -665,8 +685,21 @@ func lookupVirtualServerIndex(ctrl cache.SharedIndexInformer) func([]string) []i
665
685
return func (indexKeys []string ) (result []interface {}) {
666
686
var objs []interface {}
667
687
for _ , key := range indexKeys {
668
- obj , _ := ctrl .GetIndexer ().ByIndex (virtualServerHostnameIndex , strings .ToLower (key ))
688
+ key := strings .ToLower (key )
689
+
690
+ obj , _ := ctrl .GetIndexer ().ByIndex (virtualServerHostnameIndex , key )
669
691
objs = append (objs , obj ... )
692
+
693
+ for len (objs ) == 0 {
694
+ _ , after , found := strings .Cut (key , "." )
695
+ if ! found {
696
+ // No more wildcard recursion
697
+ break
698
+ }
699
+ key = after
700
+ obj , _ := ctrl .GetIndexer ().ByIndex (virtualServerHostnameIndex , "*." + key )
701
+ objs = append (objs , obj ... )
702
+ }
670
703
}
671
704
log .Debugf ("Found %d matching VirtualServer objects" , len (objs ))
672
705
for _ , obj := range objs {
@@ -688,8 +721,21 @@ func lookupHttpRouteIndex(http, gw cache.SharedIndexInformer) func([]string) []i
688
721
return func (indexKeys []string ) (result []interface {}) {
689
722
var objs []interface {}
690
723
for _ , key := range indexKeys {
691
- obj , _ := http .GetIndexer ().ByIndex (httpRouteHostnameIndex , strings .ToLower (key ))
724
+ key := strings .ToLower (key )
725
+
726
+ obj , _ := http .GetIndexer ().ByIndex (httpRouteHostnameIndex , key )
692
727
objs = append (objs , obj ... )
728
+
729
+ for len (objs ) == 0 {
730
+ _ , after , found := strings .Cut (key , "." )
731
+ if ! found {
732
+ // No more wildcard recursion
733
+ break
734
+ }
735
+ key = after
736
+ obj , _ := http .GetIndexer ().ByIndex (httpRouteHostnameIndex , "*." + key )
737
+ objs = append (objs , obj ... )
738
+ }
693
739
}
694
740
log .Debugf ("Found %d matching httpRoute objects" , len (objs ))
695
741
@@ -707,8 +753,21 @@ func lookupTLSRouteIndex(tls, gw cache.SharedIndexInformer) func([]string) []int
707
753
return func (indexKeys []string ) (result []interface {}) {
708
754
var objs []interface {}
709
755
for _ , key := range indexKeys {
710
- obj , _ := tls .GetIndexer ().ByIndex (tlsRouteHostnameIndex , strings .ToLower (key ))
756
+ key := strings .ToLower (key )
757
+
758
+ obj , _ := tls .GetIndexer ().ByIndex (tlsRouteHostnameIndex , key )
711
759
objs = append (objs , obj ... )
760
+
761
+ for len (objs ) == 0 {
762
+ _ , after , found := strings .Cut (key , "." )
763
+ if ! found {
764
+ // No more wildcard recursion
765
+ break
766
+ }
767
+ key = after
768
+ obj , _ := tls .GetIndexer ().ByIndex (tlsRouteHostnameIndex , "*." + key )
769
+ objs = append (objs , obj ... )
770
+ }
712
771
}
713
772
log .Debugf ("Found %d matching tlsRoute objects" , len (objs ))
714
773
@@ -726,8 +785,21 @@ func lookupGRPCRouteIndex(grpc, gw cache.SharedIndexInformer) func([]string) []i
726
785
return func (indexKeys []string ) (result []interface {}) {
727
786
var objs []interface {}
728
787
for _ , key := range indexKeys {
729
- obj , _ := grpc .GetIndexer ().ByIndex (grpcRouteHostnameIndex , strings .ToLower (key ))
788
+ key := strings .ToLower (key )
789
+
790
+ obj , _ := grpc .GetIndexer ().ByIndex (grpcRouteHostnameIndex , key )
730
791
objs = append (objs , obj ... )
792
+
793
+ for len (objs ) == 0 {
794
+ _ , after , found := strings .Cut (key , "." )
795
+ if ! found {
796
+ // No more wildcard recursion
797
+ break
798
+ }
799
+ key = after
800
+ obj , _ := grpc .GetIndexer ().ByIndex (grpcRouteHostnameIndex , "*." + key )
801
+ objs = append (objs , obj ... )
802
+ }
731
803
}
732
804
log .Debugf ("Found %d matching grpcRoute objects" , len (objs ))
733
805
@@ -741,11 +813,7 @@ func lookupGRPCRouteIndex(grpc, gw cache.SharedIndexInformer) func([]string) []i
741
813
}
742
814
}
743
815
744
- func lookupGateways (
745
- gw cache.SharedIndexInformer ,
746
- refs []gatewayapi_v1.ParentReference ,
747
- ns string ,
748
- ) (result []interface {}) {
816
+ func lookupGateways (gw cache.SharedIndexInformer , refs []gatewayapi_v1.ParentReference , ns string ) (result []interface {}) {
749
817
for _ , gwRef := range refs {
750
818
751
819
if gwRef .Namespace != nil {
@@ -769,10 +837,6 @@ func lookupIngressIndex(ctrl cache.SharedIndexInformer) func([]string) []interfa
769
837
var objs []interface {}
770
838
for _ , key := range indexKeys {
771
839
key := strings .ToLower (key )
772
- // Ingress is not responsible for _acme-challenge.* FQDN
773
- if strings .HasPrefix (key , "_acme-challenge." ) {
774
- continue
775
- }
776
840
777
841
obj , _ := ctrl .GetIndexer ().ByIndex (ingressHostnameIndex , key )
778
842
objs = append (objs , obj ... )
@@ -881,9 +945,7 @@ func fetchServiceLoadBalancerIPs(ingresses []core.LoadBalancerIngress) (results
881
945
return
882
946
}
883
947
884
- func fetchIngressLoadBalancerIPs (
885
- ingresses []networking.IngressLoadBalancerIngress ,
886
- ) (results []interface {}) {
948
+ func fetchIngressLoadBalancerIPs (ingresses []networking.IngressLoadBalancerIngress ) (results []interface {}) {
887
949
for _ , address := range ingresses {
888
950
if address .Hostname != "" {
889
951
log .Debugf ("Looking up hostname %s" , address .Hostname )
0 commit comments