hapostgres / pg_auto_failover

Postgres extension and service for automated failover and high-availability
Other
1.09k stars 114 forks source link

pg_autoctl create postgres should exit after initial registration #833

Closed redbaron closed 2 years ago

redbaron commented 2 years ago

Right now it seems not possible to just register node on pg_autoctl create postgres and exit. This makes it less conventient to run it in container in Kubernetes, because command to run differs depending whether it is the first time node starts or not.

Compare it with pg_autoctl create monitor which allows initialization and subsequent run with pg_autoctl run. It would be great if create postgres allowed similar mode of operation

DimCitus commented 2 years ago

Hi @redbaron. I don't understand your question: it seems to me that we support both of the options you're asking for. Both pg_autoctl create monitor|postgres commands have the option --run. When not using the option, we initialise the local node (and register it when it's a postgres instance, not a monitor). When using the --run option, we also start the service.

It means that you can integrate with Kubernetes as you see fit. It might be that pg_autoctl create postgres --run ... is all you need. When done over an already initialised (and registered) setup, the command does the same thing as pg_autoctl run, it just spends some time making sure everything is in order first.

Closing for triage reasons, feel free to ask more questions and get back with more details (such as “what happens when you try?”) ; even consider opening this issue again if you feel that's needed.

rheaton commented 2 years ago

@redbaron Could you use an initContainer that checks for pgaf configuration and runs if it's not there?

redbaron commented 2 years ago

it seems to me that we support both of the options you're asking for

Indeed, I meessed up my entrypoint and didn't notice how pg_autoctl create exits and pg_autoctl run picks up. Thanks for a prompt response