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

Scoping the generated ingress unique identifiers to namespaces #2224

Closed
wants to merge 1 commit into from
Closed
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
12 changes: 6 additions & 6 deletions python/ambassador/config/resourcefetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ def handle_k8s_ingress(self, k8s_object: AnyDict) -> HandlerResult:

ingress_tls = ingress_spec.get('tls', [])
for tls_count, tls in enumerate(ingress_tls):
tls_unique_identifier = f"{ingress_name}-{tls_count}"
tls_unique_identifier = f"{ingress_name}-{ingress_namespace}-{tls_count}"

tls_secret = tls.get('secretName', None)

Expand All @@ -524,15 +524,15 @@ def handle_k8s_ingress(self, k8s_object: AnyDict) -> HandlerResult:
if tls_hosts is not None:
ingress_tls_context['spec']['hosts'] = tls_hosts

self.logger.info(f"Generated TLS Context from ingress {ingress_name}: {ingress_tls_context}")
self.logger.info(f"Generated TLS Context from ingress {ingress_name}.{ingress_namespace}: {ingress_tls_context}")
self.handle_k8s_crd(ingress_tls_context)

# parse ingress.spec.backend
default_backend = ingress_spec.get('backend', {})
db_service_name = default_backend.get('serviceName', None)
db_service_port = default_backend.get('servicePort', None)
if db_service_name is not None and db_service_port is not None:
db_mapping_identifier = f"{ingress_name}-default-backend"
db_mapping_identifier = f"{ingress_name}-{ingress_namespace}-default-backend"

default_backend_mapping = {
'apiVersion': 'getambassador.io/v2',
Expand All @@ -551,7 +551,7 @@ def handle_k8s_ingress(self, k8s_object: AnyDict) -> HandlerResult:
if metadata_labels:
default_backend_mapping['metadata']['labels'] = metadata_labels

self.logger.info(f"Generated mapping from Ingress {ingress_name}: {default_backend_mapping}")
self.logger.info(f"Generated mapping from Ingress {ingress_name}.{ingress_namespace}: {default_backend_mapping}")
self.handle_k8s_crd(default_backend_mapping)

# parse ingress.spec.rules
Expand All @@ -573,7 +573,7 @@ def handle_k8s_ingress(self, k8s_object: AnyDict) -> HandlerResult:
continue

unique_suffix = f"{rule_count}-{path_count}"
mapping_identifier = f"{ingress_name}-{unique_suffix}"
mapping_identifier = f"{ingress_name}-{ingress_namespace}-{unique_suffix}"

path_mapping: Dict[str, Any] = {
'apiVersion': 'getambassador.io/v2',
Expand All @@ -595,7 +595,7 @@ def handle_k8s_ingress(self, k8s_object: AnyDict) -> HandlerResult:
if rule_host is not None:
path_mapping['spec']['host'] = rule_host

self.logger.info(f"Generated mapping from Ingress {ingress_name}: {path_mapping}")
self.logger.info(f"Generated mapping from Ingress {ingress_name}.{ingress_namespace}: {path_mapping}")
self.handle_k8s_crd(path_mapping)

# let's make arrangements to update Ingress' status now
Expand Down