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 selector = ./selector.dhall
|
|
|
|
|
|
|
|
let podSpec
|
|
|
|
: Config.Type → kubernetes.PodSpec.Type
|
|
|
|
= λ(config : Config.Type)
|
2020-01-25 18:54:21 +00:00
|
|
|
→ let rootContainer =
|
|
|
|
[ kubernetes.Container::{
|
|
|
|
, name = "web"
|
2020-01-31 20:16:03 +00:00
|
|
|
, env = Some config.envVars
|
2020-01-25 18:54:21 +00:00
|
|
|
, image = Some config.image
|
|
|
|
, imagePullPolicy = Some "Always"
|
2020-01-31 20:16:03 +00:00
|
|
|
, ports = Some
|
|
|
|
[ kubernetes.ContainerPort::{
|
|
|
|
, containerPort = config.appPort
|
|
|
|
}
|
|
|
|
]
|
2020-01-25 18:54:21 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
let other = config.otherContainers
|
|
|
|
|
|
|
|
let combined = rootContainer # other
|
|
|
|
|
|
|
|
in kubernetes.PodSpec::{
|
|
|
|
, containers = combined
|
2020-01-31 20:16:03 +00:00
|
|
|
, imagePullSecrets = Some
|
|
|
|
[ kubernetes.LocalObjectReference::{ name = Some "regcred" } ]
|
2020-01-23 23:33:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
let spec =
|
|
|
|
λ(config : Config.Type)
|
|
|
|
→ kubernetes.DeploymentSpec::{
|
|
|
|
, selector = kubernetes.LabelSelector::{
|
2020-01-31 20:16:03 +00:00
|
|
|
, matchLabels = Some (selector config.name)
|
2020-01-23 23:33:52 +00:00
|
|
|
}
|
2020-01-25 18:54:21 +00:00
|
|
|
, replicas = Some config.replicas
|
2020-01-23 23:33:52 +00:00
|
|
|
, template = kubernetes.PodTemplateSpec::{
|
|
|
|
, metadata = kubernetes.ObjectMeta::{
|
|
|
|
, name = config.name
|
2020-01-31 20:16:03 +00:00
|
|
|
, labels = Some (selector config.name)
|
2020-01-23 23:33:52 +00:00
|
|
|
}
|
|
|
|
, spec = Some (podSpec config)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let deployment =
|
|
|
|
λ(config : Config.Type)
|
|
|
|
→ kubernetes.Deployment::{
|
2020-01-23 23:55:38 +00:00
|
|
|
, metadata = kubernetes.ObjectMeta::{
|
|
|
|
, name = config.name
|
2020-01-24 00:00:52 +00:00
|
|
|
, namespace = Some "apps"
|
2020-01-23 23:55:38 +00:00
|
|
|
}
|
2020-01-23 23:33:52 +00:00
|
|
|
, spec = Some (spec config)
|
|
|
|
}
|
|
|
|
|
|
|
|
in deployment
|