providers/proxy: implement Ingress diff checking

This commit is contained in:
Jens Langhammer 2020-10-18 21:34:45 +02:00
parent 8b09cf55a2
commit e87d52a76b
1 changed files with 23 additions and 4 deletions

View File

@ -39,10 +39,29 @@ class IngressReconciler(KubernetesObjectReconciler[NetworkingV1beta1Ingress]):
def reconcile(
self, current: NetworkingV1beta1Ingress, reference: NetworkingV1beta1Ingress
):
if len(current.spec.ports) != len(reference.spec.ports):
# Create a list of all expected host and tls hosts
expected_hosts = []
expected_hosts_tls = []
for proxy_provider in ProxyProvider.objects.filter(
outpost__in=[self.controller.outpost]
):
proxy_provider: ProxyProvider
external_host_name = urlparse(proxy_provider.external_host)
expected_hosts.append(external_host_name.hostname)
if external_host_name.scheme == "https":
expected_hosts_tls.append(external_host_name.hostname)
expected_hosts.sort()
expected_hosts_tls.sort()
have_hosts = [rule.host for rule in reference.spec.rules]
have_hosts.sort()
have_hosts_tls = reference.spec.tls.hosts
have_hosts_tls.sort()
if have_hosts != expected_hosts:
raise NeedsUpdate()
for port in reference.spec.ports:
if port not in current.spec.ports:
if have_hosts_tls != expected_hosts_tls:
raise NeedsUpdate()
def get_reference_object(self) -> NetworkingV1beta1Ingress: