kubermemes/k8s/http/ingress.dhall

65 lines
1.7 KiB
Plaintext
Raw Normal View History

2020-01-23 23:33:52 +00:00
let Prelude = ../Prelude.dhall
let kubernetes = ../kubernetes.dhall
let kv = Prelude.JSON.keyText
let Config = ../app/config.dhall
let annotations
: Config.Type → List { mapKey : Text, mapValue : Text }
= λ(config : Config.Type)
→ [ kv "kubernetes.io/ingress.class" "nginx"
, kv
"certmanager.k8s.io/cluster-issuer"
"letsencrypt-${config.leIssuer}"
]
let metadata
: Config.Type → kubernetes.ObjectMeta.Type
= λ(config : Config.Type)
→ kubernetes.ObjectMeta::{
, name = config.name
, labels = [ kv "app" config.name ]
, annotations = annotations config
2020-01-24 00:00:52 +00:00
, namespace = Some "apps"
2020-01-23 23:33:52 +00:00
}
let tls
: Config.Type → kubernetes.IngressTLS.Type
= λ(config : Config.Type)
→ kubernetes.IngressTLS::{
, hosts = [ config.domain ]
, secretName = Some "${config.leIssuer}-certs-${config.name}"
}
let rule
: Config.Type → kubernetes.IngressRule.Type
= λ(config : Config.Type)
→ kubernetes.IngressRule::{
, host = Some config.domain
, http = Some kubernetes.HTTPIngressRuleValue::{
, paths =
[ kubernetes.HTTPIngressPath::{
, backend = kubernetes.IngressBackend::{
, serviceName = config.name
, servicePort = kubernetes.IntOrString.Int config.appPort
}
}
]
}
}
let ingress
: Config.Type → kubernetes.Ingress.Type
= λ(config : Config.Type)
→ kubernetes.Ingress::{
, metadata = metadata config
, spec = Some kubernetes.IngressSpec::{
, tls = [ tls config ]
, rules = [ rule config ]
}
}
in ingress