There are four different types of resources in your setup:
- instance is a virtual machine
- a target pool is a pool of instances used only for the purpose of L3 (e.g. IP) level network load balancing
- managed instance group is a group of instances, used among others as a target for your autoscaler
- autoscaler looks at a managed instance group and adds/deletes instances in this group as appropriate according to load (and your policy)
To make sure that all the instances in your managed instance group (that is all the instances in your autoscaling group) are automatically in your target pool, you need to tell the managed instance group about the target pool.
As @Faizan correctly mentioned, the command to do it is:
gcloud compute instance-groups managed set-target-pools instance-group-name --target-pools your-target-pool
The help page for this command seems more useful than the online documentation:
gcloud compute instance-groups managed set-target-pools --help
Please note that this help page seems to be out of date though. Setting a new target pool now DOES apply to existing instances in the group (when using the API version v1
or later). It was not the case in the beta versions (v1beta2
).