I have a Kubernetes service without a selector for which I would like to manually manage the Endpoints by having the endpoint servers register/heartbeat themselves.
Is there a way to specify a TTL for Endpoints when I POST them to the Kubernetes API server, so that they will timeout and be deleted automatically if my endpoint server terminates and stops heartbeating?
If not, would it be reasonable if I add the Endpoints to the registry by POSTing directly to the underlying Etcd, instead of going through the Kubernetes API, or will that cause other problems?
You do not need to modify kubernetes to do this.
Here is how to do it yourself.
Here are specific commands to do this for endpoints.
Add an annotation to an endpoint with expiration time one minute from now:
Script to list endpoints, and delete those with expires-at after now:
A pod is a great place to run the above script. It will have automatic access to the API and with a replication controller, it will run forever.
There is no TTL or heartbeat built into the endpoints API objects. You really don't want to write directly to etcd though… that will bite you eventually