This document details how the k8s claimer server performs its lease and release operations in accordance with the guarantees it gives.
Each cluster is assigned a unique name, and the GKE API/backend stores those names (along with other metadata). However, each cluster name, its UUID and its lease expiration time is stored as a key/value pair (one k/v pair per cluster) in annotations on the k8s-server service. Specifically, a single key/value pair looks like the following:
UUID => (cluster_name, lease_expiration_time)
- Download the annotations from the service and list the container clusters in GKE
- If a cluster exists in GKE that's not in the annotations, set that to
found
- Otherwise, look for a cluster that has passed its lease expiration time.
If there is one, set that to
found
- If
found
is empty, return409
(until #9 is done) - Otherwise, add/overwrite an annotation with a new UUID and the new lease expiration time.
- Save the annotation. If the save failed, go back to 1 for a (statically configurable) number of retries
- Return the UUID set in (5) to the client
- Download the annotations from the service
- Look for the given token (in the URL Path) in the annotation keys
- If none found, return
401
- the given token is not a valid lease - Otherwise, remove the annotation
- Save the annotations. If the save failed, go back to 1 for a (statically configurable) number of retries
- Return
200 OK
to the client