65 lines
1.8 KiB
Plaintext
65 lines
1.8 KiB
Plaintext
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 = Some [ kv "app" config.name ]
|
|
, annotations = Some (annotations config)
|
|
, namespace = Some "apps"
|
|
}
|
|
|
|
let tls
|
|
: Config.Type → kubernetes.IngressTLS.Type
|
|
= λ(config : Config.Type)
|
|
→ kubernetes.IngressTLS::{
|
|
, hosts = Some [ 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 = Some [ tls config ]
|
|
, rules = Some [ rule config ]
|
|
}
|
|
}
|
|
|
|
in ingress
|