kubermemes/k8s/http/service.dhall

47 lines
1.3 KiB
Plaintext
Raw Normal View History

2020-01-23 23:33:52 +00:00
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::{
2020-01-31 20:16:03 +00:00
, selector = Some (selector config.name)
2020-01-23 23:33:52 +00:00
, type = Some "ClusterIP"
2020-01-31 20:16:03 +00:00
, ports = Some
[ kubernetes.ServicePort::{
, targetPort = Some (kubernetes.IntOrString.Int config.appPort)
, port = config.appPort
}
]
2020-01-23 23:33:52 +00:00
}
let service
: Config.Type → kubernetes.Service.Type
= λ(config : Config.Type)
→ kubernetes.Service::{
, metadata = kubernetes.ObjectMeta::{
2020-01-24 00:00:52 +00:00
, namespace = Some "apps"
2020-01-23 23:33:52 +00:00
, name = config.name
2020-01-31 20:16:03 +00:00
, labels = Some [ kv "app" config.name ]
, annotations = Some (annotations config)
2020-01-23 23:33:52 +00:00
}
, spec = Some (spec config)
}
in service