You are looking for the leader election pattern. This can be implemented in many different ways. It typically means that an instance take a lock in some form of persistent storage, e.g. a PostgreSQL database, Redis or in etcd itself.
Also see Java Leader Election Pattern and Leader Election in distributed systems