1
0
Fork 0

Fix minor things

This commit is contained in:
Joao Gilberto Magalhaes 2022-08-26 00:50:00 -05:00
parent 912be51399
commit 0d16c117cb
2 changed files with 10 additions and 4 deletions

View file

@ -16,6 +16,7 @@ def start():
processor_obj.save_certs(Consts.certs_haproxy) processor_obj.save_certs(Consts.certs_haproxy)
letsencrypt_certs_found = processor_obj.get_letsencrypt_hosts() letsencrypt_certs_found = processor_obj.get_letsencrypt_hosts()
Functions.log(Functions.EASYHAPROXY_LOG, Functions.DEBUG, 'Found hosts: %s' % ", ".join(processor_obj.get_hosts())) # Needs to after save_config Functions.log(Functions.EASYHAPROXY_LOG, Functions.DEBUG, 'Found hosts: %s' % ", ".join(processor_obj.get_hosts())) # Needs to after save_config
Functions.log(Functions.EASYHAPROXY_LOG, Functions.TRACE, 'Object Found: %s' % (processor_obj.get_parsed_object()))
old_haproxy = None old_haproxy = None
haproxy = DaemonizeHAProxy() haproxy = DaemonizeHAProxy()
@ -33,6 +34,7 @@ def start():
processor_obj.refresh() processor_obj.refresh()
if DeepDiff(old_parsed, processor_obj.get_parsed_object()) != {} or not haproxy.is_alive(): if DeepDiff(old_parsed, processor_obj.get_parsed_object()) != {} or not haproxy.is_alive():
Functions.log(Functions.EASYHAPROXY_LOG, Functions.DEBUG, 'New configuration found. Reloading...') Functions.log(Functions.EASYHAPROXY_LOG, Functions.DEBUG, 'New configuration found. Reloading...')
Functions.log(Functions.EASYHAPROXY_LOG, Functions.TRACE, 'Object Found: %s' % (processor_obj.get_parsed_object()))
processor_obj.save_config(Consts.haproxy_config) processor_obj.save_config(Consts.haproxy_config)
processor_obj.save_certs(Consts.certs_haproxy) processor_obj.save_certs(Consts.certs_haproxy)
letsencrypt_certs_found = processor_obj.get_letsencrypt_hosts() letsencrypt_certs_found = processor_obj.get_letsencrypt_hosts()

View file

@ -132,7 +132,7 @@ class Swarm(ProcessorInterface):
class Kubernetes(ProcessorInterface): class Kubernetes(ProcessorInterface):
def __init__(self, filename = None): def __init__(self, filename = None):
config.load_incluster_config() config.load_incluster_config()
#config.verify_ssl=False config.verify_ssl = False
self.api_instance = client.CoreV1Api() self.api_instance = client.CoreV1Api()
self.v1 = client.NetworkingV1Api() self.v1 = client.NetworkingV1Api()
self.cert_cache = {} self.cert_cache = {}
@ -163,6 +163,8 @@ class Kubernetes(ProcessorInterface):
data["resource_version"] = ingress.metadata.resource_version data["resource_version"] = ingress.metadata.resource_version
data["namespace"] = ingress.metadata.namespace data["namespace"] = ingress.metadata.namespace
ingress_name = ingress.metadata.namespace
if ingress.spec.tls is not None: if ingress.spec.tls is not None:
for tls in ingress.spec.tls: for tls in ingress.spec.tls:
try: try:
@ -179,7 +181,9 @@ class Kubernetes(ProcessorInterface):
ssl_hosts.extend(tls.hosts) ssl_hosts.extend(tls.hosts)
except Exception as e: except Exception as e:
pass Functions.log("EASYHAPROXY", Functions.WARN, "Ingress %s - Get secret failed: '%s'" % (ingress_name, e))
Functions.log("EASYHAPROXY", Functions.TRACE, "Ingress %s - SSL Hosts found '%s'" % (ingress_name, ssl_hosts))
for rule in ingress.spec.rules: for rule in ingress.spec.rules:
rule_data = {} rule_data = {}
@ -197,13 +201,13 @@ class Kubernetes(ProcessorInterface):
if redirect is not None: if redirect is not None:
rule_data["%s.redirect" % (definition)] = redirect rule_data["%s.redirect" % (definition)] = redirect
service_name = rule.http.paths[0].backend.service.name service_name = rule.http.paths[0].backend.service.ingress_name
try: try:
api_response = self.api_instance.read_namespaced_service(service_name, ingress.metadata.namespace) api_response = self.api_instance.read_namespaced_service(service_name, ingress.metadata.namespace)
cluster_ip = api_response.spec.cluster_ip cluster_ip = api_response.spec.cluster_ip
except ApiException as e: except ApiException as e:
cluster_ip = None cluster_ip = None
# print("Exception when calling CoreV1Api->read_namespaced_service: %s\n" % e) Functions.log("EASYHAPROXY", Functions.WARN, "Ingress %s - Service %s - Failed: '%s'" % (ingress_name, service_name, e))
if cluster_ip is not None: if cluster_ip is not None:
if cluster_ip not in self.parsed_object.keys(): if cluster_ip not in self.parsed_object.keys():