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
|
2020-01-31 20:16:03 +00:00
|
|
|
, labels = Some [ kv "app" config.name ]
|
|
|
|
, annotations = Some (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::{
|
2020-01-31 20:16:03 +00:00
|
|
|
, hosts = Some [ config.domain ]
|
2020-01-23 23:33:52 +00:00
|
|
|
, 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::{
|
2020-01-31 20:16:03 +00:00
|
|
|
, tls = Some [ tls config ]
|
|
|
|
, rules = Some [ rule config ]
|
2020-01-23 23:33:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
in ingress
|