1

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.

enter image description here

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?

1 Answer 1

0

Kubernetes

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.

Google Cloud Deployment Manager

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
2
  • 1
    Thanks for the answer! I want to use NodePort instead of LoadBalancer which is why I'm routing traffic directly to the Kubernetes minions. I used the Kubernetes kube-up.sh script which created the managed instance groups. If I create an entry in my deployment manager yaml to add the target pool to these managed instance groups, will that "merge" or "replace"? I'm scared that doing this will destroy some settings that kube-up.sh set. Commented Nov 7, 2017 at 0:29
  • It replaces it if a target pool entry was already present. However if you are scared to compromise your enviroment, the best practise is to proceed in a test one and check that all the functionality that you expect are still working after the changes. By the way if you are willing to only associate a target pool to a instance group I would make use of the following Cloud SDK command rather than the DM: $ gcloud compute instance-groups managed set-target-pools [...] Commented Nov 7, 2017 at 11:10

Not the answer you're looking for? Browse other questions tagged or ask your own question.