When creating a TCP load balancer in the web console, I can add multiple backend services (see image below). I got everything working and now I'm trying to replicate it with Cloud Deployment Manager, but I can't figure out how to set multiple backend services to a TCP load balancer.
The Cloud Deployment Manager ForwardingRule documentation only seems to allow a single target
. Maybe a single target is all I need and instead I just need to connect multiple instance group managers to a single target pool?
The problem with that, for me, is my instance group managers were created by Kubernetes and I don't see a way to connect an instance group manager to a target pool without redefining the instance group manager.
Is there a way to add multiple backends/instance groups to a forwarding rule when the instance groups weren't created with deployment manager?
First of all, if you are creating a cluster making use of Kubernetes and you are willing to make the containers running in the nodes reachable through a single entrance point you have to create a service of type loadbalancer.
However it is possible to create a TCP load balancer redirecting the traffic to more than one backend also in the case of the Cloud Deployment Manager.
In order to check the needed underlying components I suggest you to create a temporary TCP Load balancer through the Developers Console and check from the advanced setting all the components created. It turns out that you need to create a ForwardingRule pointing to a TargetPool having several managed instance groups in the same region attached to it.
Therefore you need to modify the managed instance groups and set the target pool for each of them. You can use the following YAML to update an existing managed instance group named test:
resources:
- name: test
type: compute.v1.instanceGroupManager
properties:
zone: europe-west1-c
targetSize: 2
targetPools:
- https://www.googleapis.com/compute/v1/projects/<<projectID>>/regions/europe-west1/targetPools/mytargetpool
baseInstanceName: <<baseName>>
instanceTemplate: https://www.googleapis.com/compute/v1/projects/<<projectID>>/global/instanceTemplates/<<instanceTemplateName>>
You’ll need a similar structure for each of the managed instance groups.
On the other hand you can create the Target pool with the following snippet:
resources:
- name: mytargetpool
type: compute.v1.targetPool
properties:
region: europe-west1