4.10. Configuring the virtual IP management resource agent
The gcp-vpc-move-vip resource agent attaches a secondary IP address (alias IP) to a running instance. You can assign this floating IP address between different nodes in the cluster.
# pcs resource describe gcp-vpc-move-vip
You can configure the resource agent to use a primary subnet address range or a secondary subnet address range.
4.10.1. Configuring the primary subnet address range 复制链接链接已复制到粘贴板!
If you need to automate or manage the assigned IP addresses allocation for VM or other resources within a subnet, you can use the primary subnet address range. It ensures that the primary address range is correctly set and configure to use as stable IP addresses for the primary virtual private network (VPC) subnet.
Procedure
Create the
aliasipresource by including an unused internal IP address and the CIDR block:# pcs resource create aliasip gcp-vpc-move-vip alias_ip=UnusedIPaddress/CIDRblockExample:
[root@rhel81-node-01 ~]# pcs resource create aliasip gcp-vpc-move-vip alias_ip=10.10.10.200/32Create an
IPaddr2resource for managing the IP on the node:# pcs resource create vip IPaddr2 nic=interface ip=AliasIPaddress cidr_netmask=32Example:
[root@rhel81-node-01 ~]# pcs resource create vip IPaddr2 nic=eth0 ip=10.10.10.200 cidr_netmask=32Group the network resources under
vipgrp:# pcs resource group add vipgrp aliasip vip
Verification
Verify the active resources and under the
vipgrpgroup:# pcs statusVerify the movable resources across the nodes:
# pcs resource move vip NodeExample:
[root@rhel81-node-01 ~]# pcs resource move vip rhel81-node-03Verify if the
vipsuccessfully started on a different node:# pcs status
4.10.2. Configuring the secondary subnet address range 复制链接链接已复制到粘贴板!
You can use the secondary subnet address range if you need to assign IP addresses from additional and predefined range within the same subnet, without creating a new subnet. It is useful for specific purposes such as custom routing. With secondary subnet address range, you can manage network traffic in a single subnet with multiple IP address ranges.
Prerequisites
- You have created a custom network and a subnet
Optional: You have installed Google Cloud SDK. For instructions, see Installing the Google Cloud SDK.
注意You can also use the
gcloudcommands in the following procedure in the terminal that you can activate in the Google Cloud web console.
Procedure
Create a secondary subnet address range:
# gcloud compute networks subnets update SubnetName --region RegionName --add-secondary-ranges SecondarySubnetName=SecondarySubnetRangeExample:
# gcloud compute networks subnets update range0 --region us-west1 --add-secondary-ranges range1=10.10.20.0/24Create the
aliasipresource with an unused internal IP address in the secondary subnet address range and the CIDR block:# pcs resource create aliasip gcp-vpc-move-vip alias_ip=UnusedIPaddress/CIDRblockExample:
[root@rhel81-node-01 ~]# pcs resource create aliasip gcp-vpc-move-vip alias_ip=10.10.20.200/32Create an
IPaddr2resource for managing the IP on the node:# pcs resource create vip IPaddr2 nic=interface ip=AliasIPaddress cidr_netmask=32Example:
[root@rhel81-node-01 ~]# pcs resource create vip IPaddr2 nic=eth0 ip=10.10.20.200 cidr_netmask=32Group the network resources under
vipgrp:# pcs resource group add vipgrp aliasip vip
Verification
Verify that the active resources are under the
vipgrpgroup:# pcs statusVerify that the movable resources across different nodes:
# pcs resource move vip NodeExample:
[root@rhel81-node-01 ~]# pcs resource move vip rhel81-node-03Verify that the
vipsuccessfully started on a different node:# pcs status