Skip to content

Commit

Permalink
fix issue compumike#17
Browse files Browse the repository at this point in the history
  • Loading branch information
bernatvadell committed May 20, 2023
1 parent 10ef5fd commit e5339ba
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions hairpin-proxy-controller/src/main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class HairpinProxyController
COMMENT_LINE_SUFFIX = "# Added by hairpin-proxy"
DNS_REWRITE_DESTINATION = "hairpin-proxy.hairpin-proxy.svc.cluster.local"
POLL_INTERVAL = ENV.fetch("POLL_INTERVAL", "15").to_i.clamp(1..)
INGRESS_CLASS = ENV.fetch("INGRESS_CLASS", nil)

# Kubernetes <= 1.18 puts Ingress in "extensions/v1beta1"
# Kubernetes >= 1.19 puts Ingress in "networking.k8s.io/v1"
Expand All @@ -33,6 +34,10 @@ def fetch_ingress_hosts
[]
end
}.flatten
# Filtrar los Ingress por la anotación "kubernetes.io/ingress.class" si INGRESS_CLASS está definida
if INGRESS_CLASS
all_ingresses.filter! { |ingress| ingress.metadata.annotations&.[]("kubernetes.io/ingress.class") == INGRESS_CLASS }
end
all_tls_blocks = all_ingresses.map { |r| r.spec.tls }.flatten.compact
hosts = all_tls_blocks.map(&:hosts).flatten.compact
hosts.filter! { |host| /\A[A-Za-z0-9.\-_]+\z/.match?(host) }
Expand Down

0 comments on commit e5339ba

Please sign in to comment.