Public floating IP address in a PostgreSQL cluster
Public floating IP addresses are static IP addresses that can be attached to cluster nodes in a private network to configure access to them from the internet. A separate address is attached to each cluster node.
An address is considered floating (Floating IP) because it can automatically switch when a role changes from replica to master and vice versa. When switching, the address is not changed or deleted.
To attach a public floating IP address, a cloud router with internet access is used. The public floating IP address is associated with the private IP address of the cluster node. Inbound traffic is processed by the cloud router — the router performs 1:1 NAT through an external IP address allocated when connecting the router to the internet. Inbound traffic can be filtered using a cloud firewall or a security group.
You can attach a public floating IP address:
-
when creating a cluster in an existing private subnet, if the subnet meets the requirements. If the subnet does not meet the requirements, prepare it for attaching a public floating IP address before creating the cluster or attach a public floating IP address after creating the cluster;
-
or in an existing cluster, even if the private subnet does not meet the requirements.
If necessary, you can detach the public floating IP address.
Private subnet requirements for attaching a public floating IP address
- the subnet must have a cloud router with an internet connection;
- the IP address of the cloud router must be the default gateway in the cluster subnet.
If the router is already connected to the cluster subnet, but its IP address does not match the gateway, you cannot attach a public floating IP address. In this case, disconnect the subnet from the cloud router, and then reconnect it and specify the subnet gateway address.
Prepare a private subnet for attaching a public floating IP address
1. Create a cloud router with an internet connection
- In the control panel, in the top menu, click Products and select Cloud Servers.
- Go to Network → Cloud Routers.
- Click Create router.
- Select the location where the cloud router will be created.
- Select a router type.
- Enter the router name.
- Select the Connect router to internet checkbox — a public IP address will be allocated for the router.
- Click Create.
2. Connect a private subnet to the cloud router
- In the control panel, from the top menu, click Products and select Cloud Servers.
- Go to the Network section → Cloud Routers tab.
- Open the router card.
- Click Connect subnet.
- Select a private subnet.
- Optional: enter the router IP address. If you do not specify an IP address, it will be automatically selected from available subnet addresses. The cloud router IP address must match the default gateway of the private subnet. You can check the gateway in the control panel: from the top menu, click Products → Cloud Servers → Network → the Private Networks tab → network page → the Subnets tab → subnet card → the Automatic network configuration block → the Subnet gateway field.
- Click Connect.
Attach a public floating IP address to an existing cluster
-
In the Control Panel, from the top menu, click Products and select Cloud Databases.
-
Go to the Active tab.
-
Go to the database cluster page → Settings tab.
-
In the Node addresses and statuses block, on the node line, click Connect public IP.
-
If the cluster subnet meets the requirements, click Connect.
-
If the cluster subnet does not meet the requirements:
6.1.Select an existing cloud router or create a new one. The cluster subnet will be connected to the router. If you select an existing router without internet access or a new router, it will be automatically connected to the internet.
6.2.Click Connect router and address.
Detach a public floating IP address
- In the Control Panel, in the top menu, click Products and select Cloud Databases.
- Open the tab Active.
- Open the database cluster page → tab Settings.
- In the Node addresses and statuses block, in the node row, click .
- Click Delete.