1

On Google Cloud Platform I need to create two virtual machines that will act as the main server and replication server (as a database).

It happens that I will have several applications that will connect to the main server, which requires me to define in these applications the local network IP (VPC) of this main machine.

My problem occurs when there is some failure on the main machine or even an emergency/maintenance reboot. This type of operation will require me to urgently change all applications to use the replication machine's VPC IP instead of the main one.

Is there any way I can have one IP that can be dedicated to connect to the main machine, but when necessary, change its destination to be the replication machine?

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
Tom
  • 641
  • 2
  • 8
  • 21

1 Answers1

3

Instead use an internal L7 load balancer. See the comparision in order to decide if this is suitable. This PDF explains the stack - and envoyproxy.io is the load balancer. Andromeda even implements round robin, but for NIC instead of IP.

Also see: Patterns for using floating IP addresses in Compute Engine

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
  • This LoadBalancer is not for what I need. For example, I will have two machines to run a database, eg PostgreSQL (Server 1: Main - Server2: Replica), if PostgreSQL Main goes down I would point that IP (floating/proxy/dynamic) to access the machine of PostgreSQL Replica, without having to change all my applications on multiple VMs to connect to the real IP of the replica VM. – Tom May 17 '22 at 02:24
  • I'd suggest to first read the HA manual: https://www.postgresql.org/docs/current/high-availability.html ... – Martin Zeitler May 17 '22 at 02:39
  • I need to use this IP model for other types of servers like NodeJS+Socket.IO, MongoDB and Redis. All running within the same VPC. – Tom May 17 '22 at 13:27
  • This would be the TCP/UDP variant. In case there are people working on there, maybe first try to configure it in a separate project, in order to learn it and to reduce the eventual down-time. – Martin Zeitler May 19 '22 at 00:53
  • @Tom Please check the link which I've added; just found it by chance... and I've also learned, that one can actually use Cloud DNS for internal IP addresses, which was a misconception on my side. – Martin Zeitler May 28 '22 at 19:57