Add HTTPService rendering for Ingress configuration

This commit is contained in:
suyiiyii 2025-03-14 19:59:36 +08:00
parent 6edd214baf
commit 98e324c586
Signed by: suyiiyii
GPG Key ID: 044704CB29B8AD85
2 changed files with 42 additions and 0 deletions

37
base/ingress.k Normal file
View File

@ -0,0 +1,37 @@
import k8s.api.networking.v1 as networkingv1
schema HTTPService:
"""http service"""
service: str
domain: str
httpServiceRender = lambda h: HTTPService {
"""Render http service to Ingress"""
ingress = networkingv1.Ingress {
apiVersion = "networking.k8s.io/v1"
kind = "Ingress"
metadata = {
name = h.service
}
spec = {
rules = [{
host = h.domain
http = {
paths = [{
path = "/"
pathType = "Prefix"
backend = {
service = {
name = h.service
port = {
number = 80
}
}
}
}]
}
}]
}
}
[ingress]
}

5
main.k
View File

@ -24,6 +24,11 @@ envs = base.Envs {
}
}
https = base.HTTPService {
service = "nginxxx"
domain = "nginxxx.suyiiyii.top"
}
deploys = sum([base.appRender(a) for a in apps], [])
# print(yaml.encode(deploys))
apps_manifests = [base.envInjector(envs, deploy) for deploy in deploys]