Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue #17 #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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