Public IP address in a ClickHouse cluster
A public IP address is a static public IP address assigned to a node to provide access to it in a private network from the internet. External traffic is routed through the public IP address and processed by a cloud router, which performs 1:1 NAT.
The private subnet where a public IP address can be assigned must comply with the requirements — before adding a public IP address, prepare the subnet.
A public IP address can be assigned:
- when creating a cluster in an existing private subnet;
- or in an existing cluster.
In a ClickHouse cluster, public IP addresses are connected to all shard nodes simultaneously. Each shard node has a separate public IP address. If you add a node to a shard where all nodes already have IP addresses, the new node will also be assigned a public IP address.
If necessary, you can detach a public IP address for the entire shard.
Requirements for a private subnet
- The subnet must have a cloud router with internet access;
- The cloud router IP address must be the default gateway in the subnet.
If the subnet does not meet the requirements, prepare it for connecting a public IP address.
Prepare a private subnet for connecting a public IP address
1. Create a cloud router with internet access
A cloud router allows you to route traffic between private networks.
The router can be used to set up internet access from a private network or to access a device in a private subnet from the internet via a public IP address.
- In the Control panel, on the top menu, click Products and select Cloud Servers.
- Go to the Network section → Cloud Routers tab.
- Click Create Router.
- Select the location where the cloud router will be created.
- Enter the router name.
- Select the Connect router to internet checkbox — an external IP address will be allocated for the router.
- Click Create.
2. Connect a private network to the cloud router
- In the Control panel, on the top menu, click Products and select Cloud Servers.
- Go to the Network section → Cloud Routers tab.
- Open the router card.
- Click Add 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 the available subnet addresses. The cloud router IP address must match the default gateway of the private subnet. The gateway can be viewed in the Control Panel: in the top menu click Products → Cloud Servers → Network → tab Private Networks → network page → tab Subnets → subnet card → block Automatic network settings → field Subnet gateway.
- Click Add subnet.
Connect a public IP address
Public IP addresses are connected to all shard nodes simultaneously. Each shard node has a separate public IP address.
- Ensure that the cluster is in a private subnet that complies with the requirements.
- In the Control panel, on the top menu, click Products and select Managed Databases.
- Open the Active tab.
- Open the database cluster page → tab Settings.
- In the shard card, in the Public access row, click .
- Click Connect.
Detach a public IP address
Public IP addresses are detached from all nodes of a shard simultaneously.
- In the Control panel, on the top menu, click Products and select Managed Databases.
- Open the Active tab.
- Open the database cluster page → tab Settings.
- In the shard card, in the Public access row, click .
- Click Disable.