Inject cert-manager annotations and TLS configuration into Ingress resources

This commit is contained in:
2025-03-15 09:56:32 +08:00
parent 5dc4290337
commit 3892da3ced
2 changed files with 28 additions and 6 deletions
+23 -3
View File
@@ -12,9 +12,6 @@ httpServiceRender = lambda h: HTTPService {
kind = "Ingress"
metadata = {
name = h.service
annotations = {
"cert-manager.io/issuer": "letsencrypt"
}
}
spec = {
rules = [{
@@ -38,3 +35,26 @@ httpServiceRender = lambda h: HTTPService {
}
[ingress]
}
certInjector = lambda input: networkingv1.Ingress | any {
"""Inject cert to Ingress"""
_result: any = {}
if input.kind != "Ingress":
_result = input
else:
ingress: networkingv1.Ingress = input as networkingv1.Ingress
print(ingress)
ingress.metadata.annotations = {"cert-manager.io/issuer" = "letsencrypt"}
ingress.spec.tls = [{
hosts = [r.host for r in ingress.spec.rules]
secretName = "tls-" + ingress.metadata.name
}]
_result = ingress
_result
}
httpServiceRefine = lambda h: HTTPService {
ingress = httpServiceRender(h)
ingress2 = certInjector(ingress[0])
ingress2
}