47 lines
1.3 KiB
Plaintext
47 lines
1.3 KiB
Plaintext
let Prelude = ../Prelude.dhall
|
|
|
|
let Config = ../app/config.dhall
|
|
|
|
let kubernetes = ../kubernetes.dhall
|
|
|
|
let kv = Prelude.JSON.keyText
|
|
|
|
let annotations
|
|
: Config.Type → List { mapKey : Text, mapValue : Text }
|
|
= λ(config : Config.Type)
|
|
→ [ kv "external-dns.alpha.kubernetes.io/hostname" config.domain
|
|
, kv "external-dns.alpha.kubernetes.io/ttl" "120"
|
|
, kv "external-dns.alpha.kubernetes.io/cloudflare-proxied" "false"
|
|
]
|
|
|
|
let selector = ./selector.dhall
|
|
|
|
let spec
|
|
: Config.Type → kubernetes.ServiceSpec.Type
|
|
= λ(config : Config.Type)
|
|
→ kubernetes.ServiceSpec::{
|
|
, selector = Some (selector config.name)
|
|
, type = Some "ClusterIP"
|
|
, ports = Some
|
|
[ kubernetes.ServicePort::{
|
|
, targetPort = Some (kubernetes.IntOrString.Int config.appPort)
|
|
, port = config.appPort
|
|
}
|
|
]
|
|
}
|
|
|
|
let service
|
|
: Config.Type → kubernetes.Service.Type
|
|
= λ(config : Config.Type)
|
|
→ kubernetes.Service::{
|
|
, metadata = kubernetes.ObjectMeta::{
|
|
, namespace = Some "apps"
|
|
, name = config.name
|
|
, labels = Some [ kv "app" config.name ]
|
|
, annotations = Some (annotations config)
|
|
}
|
|
, spec = Some (spec config)
|
|
}
|
|
|
|
in service
|