design/ingress-status-loadbalancer.md
Status: Draft
This proposal describes how to add support for the ingress.status.loadBalancer field to Contour.
networking.k8s.io/v1beta.Ingress objects managed by Contour.networking.k8s.io/v1beta.Ingress objects.The Kubernetes Ingress object provides a field on the object's status to record address details for how access the ingresses virtualhosts from outside the cluster. This is known as the status loadbalancer information after the name of the fields on the Ingress Object.
Details from the Kubernetes spec are here.
There are two components to this solution
The former, the discovery will need to support
While the hard coded name approach sounds simpler, and is, it will likely not be the common use case, nor will it be the default. This is for several reasons.
The configuration will likely go into Contour's configuration file.
These restrictions (which are administrative, not ones we've placed on the solution) make this bookkeeping expensive, prohibitively in the case of a highly dynamic cluster.
The far more common case will be dynamic load balancer discovery. In this model Contour will track a service document (default to projectcontour/envoy, but configurable) and use those details as the list of IP addresses to write back to the ingress' status.
The nginx controller goes to some lengths to try to dynamically figure out what it's status document as well as other side channels to discover the address if that fails. For this first implementation I propose we stick to the discovery methods outlined above.
The latter, writing the status to valid ingress objects, waits to be elected the leader then updates the status document on all of the ingress objects within Contour's class.
As new ingress objects arrive they will need to be updated.
Note: there appears to be no requirement that if Contour is shutting down we delete the status field on the ingress on the way out. Initially this feels wrong but consider the scenarios:
I think the design should involve two goroutines added to cmd/contour's workgroup. The first will be responsible for load balancer discovery, the second will be responsible for updating status documents.
The discovery worker should look something like this pseudocode:
Open question: if the service document goes away, should we transmit an empty set of addresses to the status worker to indicate it should remove the status.loadbalancer details?
The send from the discovery worker to the status worker will be over an unbuffered channel so the discovery worker cannot send until the status worker has been elected leader and is ready to receive IP details. Care should be taken to ensure the discovery worker can respond to the group's shutdown signal.
The status worker should look something like this pseudocode:
The open question is how to deal with the discovery worker sending a new set of addresses after the initial pass. It feels like we need to keep a side cache of ingress objects we have previously seen to go back and bulk update all the ingresses' seen so far.
n/a