append suffix to ingress hosts

This commit is contained in:
florian 2021-08-14 23:52:03 +02:00
parent 0be1da18a6
commit bc46fc3d4c
No known key found for this signature in database
GPG Key ID: 3D80806F12602A7C
3 changed files with 6 additions and 6 deletions

View File

@ -47,7 +47,7 @@ class IngressController(Controller.Controller) :
env[prefix + annotation.replace("bunkerized-nginx.", "", 1)] = annotations[annotation] env[prefix + annotation.replace("bunkerized-nginx.", "", 1)] = annotations[annotation]
return env return env
def __rules_to_env(self, rules) : def __rules_to_env(self, rules, namespace="default") :
env = {} env = {}
first_servers = [] first_servers = []
for rule in rules : for rule in rules :
@ -61,7 +61,7 @@ class IngressController(Controller.Controller) :
for path in rule["http"]["paths"] : for path in rule["http"]["paths"] :
env[prefix + "USE_REVERSE_PROXY"] = "yes" env[prefix + "USE_REVERSE_PROXY"] = "yes"
env[prefix + "REVERSE_PROXY_URL"] = path["path"] env[prefix + "REVERSE_PROXY_URL"] = path["path"]
env[prefix + "REVERSE_PROXY_HOST"] = "http://" + path["backend"]["service_name"] + ":" + str(path["backend"]["service_port"]) env[prefix + "REVERSE_PROXY_HOST"] = "http://" + path["backend"]["service_name"] + "." + namespace + ".svc.cluster.local:" + str(path["backend"]["service_port"])
env["SERVER_NAME"] = " ".join(first_servers) env["SERVER_NAME"] = " ".join(first_servers)
return env return env
@ -76,7 +76,7 @@ class IngressController(Controller.Controller) :
if "SERVER_NAME" in env and env["SERVER_NAME"] != "" : if "SERVER_NAME" in env and env["SERVER_NAME"] != "" :
first_servers.extend(env["SERVER_NAME"].split(" ")) first_servers.extend(env["SERVER_NAME"].split(" "))
for ingress in ingresses : for ingress in ingresses :
env.update(self.__rules_to_env(ingress.spec.rules)) env.update(self.__rules_to_env(ingress.spec.rules, namespace=ingress.metadata.namespace))
if ingress.spec.tls : if ingress.spec.tls :
for tls_entry in ingress.spec.tls : for tls_entry in ingress.spec.tls :
for host in tls_entry.hosts : for host in tls_entry.hosts :

View File

@ -53,9 +53,9 @@ if __name__ == "__main__" :
# Remove old files # Remove old files
files = glob.glob(args.output + "/*") files = glob.glob(args.output + "/*")
for file in files : for file in files :
if file.endswith(".conf") and os.path.isfile(file) : if file.endswith(".conf") and os.path.isfile(file) and not os.path.islink(file) :
os.remove(file) os.remove(file)
elif os.path.isdir(file) : elif os.path.isdir(file) and not os.path.islink(file) :
shutil.rmtree(file, ignore_errors=False) shutil.rmtree(file, ignore_errors=False)
# Generate the files from templates and config # Generate the files from templates and config

View File

@ -1248,7 +1248,7 @@
"env": "DNS_RESOLVERS", "env": "DNS_RESOLVERS",
"id": "dns-resolvers", "id": "dns-resolvers",
"label": "DNS Resolvers", "label": "DNS Resolvers",
"regex": "^(\\d+.\\d+.\\d+.\\d+ ?)*$", "regex": "^([a-z\\-0-9]+\\.? ?)*$",
"type": "text" "type": "text"
}, },
{ {