/dhall-kubernetes-1.15-v4.0.0/examples/ingress.dhall

Copy path to clipboard

Source

let Prelude =
../Prelude.dhall sha256:771c7131fc87e13eb18f770a27c59f9418879f7e230ba2a50e46f4461f43ec69

let map = Prelude.List.map

let kubernetes =
../package.dhall sha256:96adaf0e4d051af1cc05917f0fa8cc1e0251c642d7a8e30775560cfd6eef2d6c

let Service = { name : Text, host : Text, version : Text }

let services = [ { name = "foo", host = "foo.example.com", version = "2.3" } ]

let makeTLS
: Servicekubernetes.IngressTLS.Type
= λ(service : Service)
→ { hosts = Some [ service.host ]
, secretName = Some "${service.name}-certificate"
}

let makeRule
: Servicekubernetes.IngressRule.Type
= λ(service : Service)
→ { host = Some service.host
, http = Some
{ paths =
[ { backend =
{ serviceName = service.name
, servicePort = kubernetes.IntOrString.Int 80
}
, path = None Text
}
]
}
}

let mkIngress
: List Servicekubernetes.Ingress.Type
= λ(inputServices : List Service)
→ let annotations =
toMap
{ `kubernetes.io/ingress.class` = "nginx"
, `kubernetes.io/ingress.allow-http` = "false"
}

let defaultService =
{ name = "default"
, host = "default.example.com"
, version = " 1.0"
}

let ingressServices = inputServices # [ defaultService ]

let spec =
kubernetes.IngressSpec::{
, tls = Some
( map
Service
kubernetes.IngressTLS.Type
makeTLS
ingressServices
)
, rules = Some
( map
Service
kubernetes.IngressRule.Type
makeRule
ingressServices
)
}

in kubernetes.Ingress::{
, metadata = kubernetes.ObjectMeta::{
, name = "nginx"
, annotations = Some annotations
}
, spec = Some spec
}

in mkIngress services