Update ingress creation for multiple host names
Some checks failed
Lint Checks / Run linter (pull_request) Successful in 35s
Smoke Test / Run basic test suite (pull_request) Successful in 1m42s
Webapp Test / Run webapp test suite (pull_request) Successful in 2m14s
Deploy Test / Run deploy test suite (pull_request) Successful in 2m54s
K8s Deployment Control Test / Run deployment control suite on kind/k8s (pull_request) Failing after 3m52s
K8s Deploy Test / Run deploy test suite on kind/k8s (pull_request) Successful in 8m20s

This commit is contained in:
Prathamesh Musale 2025-02-10 10:56:00 +05:30
parent f98e75c81f
commit 9bc8ce4866
2 changed files with 31 additions and 25 deletions

View File

@ -117,19 +117,23 @@ class ClusterInfo:
def get_ingress(self, use_tls=False, certificate=None, cluster_issuer="letsencrypt-prod"): def get_ingress(self, use_tls=False, certificate=None, cluster_issuer="letsencrypt-prod"):
# No ingress for a deployment that has no http-proxy defined, for now # No ingress for a deployment that has no http-proxy defined, for now
http_proxy_info_list = self.spec.get_http_proxy() http_proxy_info_list = self.spec.get_http_proxy()
ingress = None if not http_proxy_info_list:
if http_proxy_info_list: return None
# TODO: handle multiple definitions
http_proxy_info = http_proxy_info_list[0] tls = [] if use_tls else None
rules = []
for http_proxy_info in http_proxy_info_list:
if opts.o.debug: if opts.o.debug:
print(f"http-proxy: {http_proxy_info}") print(f"http-proxy: {http_proxy_info}")
# TODO: good enough parsing for webapp deployment for now # TODO: good enough parsing for webapp deployment for now
host_name = http_proxy_info["host-name"] host_name = http_proxy_info["host-name"]
rules = []
tls = [client.V1IngressTLS( if use_tls:
tls.append(client.V1IngressTLS(
hosts=certificate["spec"]["dnsNames"] if certificate else [host_name], hosts=certificate["spec"]["dnsNames"] if certificate else [host_name],
secret_name=certificate["spec"]["secretName"] if certificate else f"{self.app_name}-tls" secret_name=certificate["spec"]["secretName"] if certificate else f"{self.app_name}-{host_name}-tls"
)] if use_tls else None ))
paths = [] paths = []
for route in http_proxy_info["routes"]: for route in http_proxy_info["routes"]:
path = route["path"] path = route["path"]

View File

@ -230,6 +230,7 @@ class K8sDeployer(Deployer):
http_proxy_info = self.cluster_info.spec.get_http_proxy() http_proxy_info = self.cluster_info.spec.get_http_proxy()
# Note: at present we don't support tls for kind (and enabling tls causes errors) # Note: at present we don't support tls for kind (and enabling tls causes errors)
use_tls = http_proxy_info and not self.is_kind() use_tls = http_proxy_info and not self.is_kind()
# TODO Handle for multiple http_proxy_info
certificate = self._find_certificate_for_host_name(http_proxy_info[0]["host-name"]) if use_tls else None certificate = self._find_certificate_for_host_name(http_proxy_info[0]["host-name"]) if use_tls else None
if opts.o.debug: if opts.o.debug:
if certificate: if certificate:
@ -367,6 +368,7 @@ class K8sDeployer(Deployer):
# Destroy the kind cluster # Destroy the kind cluster
destroy_cluster(self.kind_cluster_name) destroy_cluster(self.kind_cluster_name)
# TODO: Update for multiple host-names
def status(self): def status(self):
self.connect_api() self.connect_api()
# Call whatever API we need to get the running container list # Call whatever API we need to get the running container list