hapostgres / pg_auto_failover

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

FATAL Failed to find a local IP address #948

Closed lkgGitHub closed 1 year ago

lkgGitHub commented 1 year ago

The image I built with the Dockerfile you provided. I start the container in kubernetes and it failed. This is a failure log.

13:07:14 27 INFO  Using default --ssl-mode "require"
13:07:14 27 INFO  Using --ssl-self-signed: pg_autoctl will create self-signed certificates, allowing for encrypted network traffic
13:07:14 27 WARN  Self-signed certificates provide protection against eavesdropping; this setup does NOT protect against Man-In-The-Middle attacks nor Impersonation attacks.
13:07:14 27 WARN  See https://www.postgresql.org/docs/current/libpq-ssl.html for details
13:07:16 27 FATAL Failed to find a local IP address, please provide --hostname.
13:07:16 27 FATAL Failed to auto-detect the hostname of this machine, please provide one via --hostname

Running hostname in the pod can return the hostname of the pod. I don't know what to do next. I sincerely hope to get your help

DimCitus commented 1 year ago

Hi @lkgGitHub ;

It might be that your network can't connect to an external service such as 8.8.8.8; which we do to determine the IP address to use (the one that matches with the default route). Try using the pg_autoctl do show commands to debug your situation.

$ PG_AUTOCTL_DEBUG=1 pg_autoctl do show ipaddr 
$ PG_AUTOCTL_DEBUG=1 pg_autoctl do show hostname

If your environment makes it hard for pg_autoctl to find the IP address of the default routing interface, please use --hostname with either an IP address or a DNS entry. I realise we could probably make it possible to provide with a service name other than 8.8.8.8 to use to determine the default IP address, though: contributions welcome!

lkgGitHub commented 1 year ago

Thanks for your advice