Hi Lou,
You’re right, both strategies currently accomplish the same thing.
The problem with running etcdctl in the ExecStartPost is that it’s dumb. It will announce that the container is running as soon as the systemd unit starts. If the container isn’t cached locally and must be pulled, you just announced your app was ready for traffic before it can serve any. While that doesn’t sound ideal, its simplicity can be valuable.
Using a sidekick allows you to manage and version the logic for the service registration separately from the app. This makes sense when you’re running an application that doesn’t speak etcd natively and isn’t going to be modified. The sidekick method allows you to start a service registration container that can run more complicated logic. It could read the docker API can make sure the container is actually up and running before announcing it. It could curl /health and read a status code. It could check connectivity to another dependent container.
If you end up tweaking the strategy or create something cool, please share!
- Rob