For providing high availability to your services, you can build two or more nodes with identical services and perform loadbalancing between them.
GCloud platform offers LoadBalancer service which is managed on "Loadbalancers" tab in "Networking" section. (see Img. 1)
To start Loadbalancer creation process, click on "Add Loadbalancer" button and follow the form steps.
First step is to provide name for Loadbalancer and choose if this loadbalancer will have public IP address or local network IP address. (see Img. 2)
If you choose Loadbalancer to have local network IP address you need to select local network and optionally provide IP address from this network, which will be assigned to Loadbalancer. (Img. 3)
Also, you need to select the size and HA capability of loadbalancer. (see Img. 4)
Next step is to provide parameters for loadbalancer's listener. (Img. 5)
Provide name for loadbalancer's listener and select the protocol and corresponding port to which listener will listen. (Img. 6)
If you select HTTP protocol, you can optionally select which headers should be inserted to incoming connections. (Img. 7)
If TERMINATED_HTTPS protocol is selected, then you need to select which SSL Certificate will be used to terminate HTTPS connections (Img. 8). SSL certificates can be managed from "Certificates" tab.
Next step is to provide parameters for loadbalancer's pool (Img. 9), which will balance connections between it's pool members.
Pool name, algorithm and protocol are mandatory. Optionally, if you need to maintain session persistence, you can choose prefered Session Persistence type from the list shown in Img. 10.
Next you need to select or create pool members. If your pool member is outside of GCloud platform, you need to create it, but if it is already in GCloud platform, then you need to select from existing list. (Img. 11, 12)
Select IP address of pool member and port number, also you can provide weight and optionally monitoring address and port.
Last step is to provide Health Monitor parameters of the pool. Provide name, type and other health monitor parameters as shown in Img. 13 and 14
After submitting the form new loadbalancer creation process will be started. It may take several minutes to be built and enabled.
All parameters of new loadbalancer can be viewed on loadbalancers details screen as shown in Img. 15
You can review per hour and monthly payment for created loadbalancer as well as perform additional actions such as public IP address associate and more by clicking on "Add" button (see Img 16)
As you see, you can add more listeners, pools, pool members, health monitors as well as new Level 7 Policy and it's policy rules to specific loadbalancer.
Level 7 policy manages loadbalancer's listener's behavior. When you create L7 policy, you need to select, to which listener it belongs and what action should listener perform (see Img. 17)
After creating L7 policy, you can add L7 policy rules to it.
Click on "Add" -> "L7 Policy Rule", select L7 policy, type, compare type and compare value in L7 policy rule creation form. (see Img. 18, 19, 20)
In given example you can see that L7 policy rule corresponds to hostname which contains value of "myhost"
If you check "Invert L7 Policy Rule" checkbox, the rule will be inverted. For above example it will mean that the rule will work for those requests, which hostnames do not contain value "myhost"
If you created loadbalancer with private IP address and then decided to add Internet access to it, you'll need to associate public IP address to loadbalancer.
You can do it by clicking on "Associate Public Static IP Address" link alongside loadbaancer's name in loadbalancer's details screen.
If you've got the following alert (see Img. 21)
It means that you have not requested any static public IP address yet. You can do it by following the link provided in alert and then come back and try to associate the address again.
In case you have already requested static public IP address, you'll get popup form, from which you can select IP address to be associated. (see Img. 22)
Note, that there are several prerequisits to be met, for static public IP address to be associated to loadbalancer.
First, you need to verify that for the network from which IP address is assigned to loadbalancer, Default Gateway is enabled. You can verify this by going to "Networks" tab and in subnet details tab of specific network see if default gateway address is reserved for the network (see Img. 23)
If you see that no default gateway is enabled (Img. 24)
You'll need to edit the network and provide default gateway IP address in edit form. (see Img. 25)
Next step is to confirm that at least one router with Internet access is created and at least one interface of this router belongs to the same network to which loadbalancer's virtual IP address belongs.
To verify this go to "Routers" tab, select desired router and verify that it has Internet access as shown in Img. 26
Also, verify that the same router has interface in local network as described above. (see Img. 27)
If all prerequisits are met, you can select one of static public IP address from the list provided in IP address associate form and it will be associated to loadbalancer.