I'm trying to set up a network-based load balancing service on google cloud (compute). The last step to create it is to add a forwarding rule.
My service requires multiple ports to be forwarded, looking at the documentation it seems possible (unless I'm mistaken).
--ports=[PORT | START_PORT-END_PORT],[[PORT | START_PORT-END_PORT],…]
I have tried the following:
gcloud compute forwarding-rules create example-forwarding-rule \
--region europe-west1 \
--ports 80 443 3000-4000 6001 \
--address example-address \
--target-pool example-target-pool
And I get the following error:
ERROR: (gcloud.compute.forwarding-rules.create) Invalid value for [--ports]: Must specify consecutive ports at this time.
I've also tried adding spaces:
gcloud compute forwarding-rules create example-forwarding-rule \
--region europe-west1 \
--ports 80 443 3000-4000 6001 \
--address example-address \
--target-pool example-target-pool
Or removing the comma all together:
gcloud compute forwarding-rules create example-forwarding-rule \
--region europe-west1 \
--ports 80 443 3000-4000 6001 \
--address example-address \
--target-pool example-target-pool
And I get the following error for both:
ERROR: (gcloud.compute.forwarding-rules.create) unrecognized arguments
Is it possible to specify mutliple ports and if so, how?
Unfortunately --ports
flag only supports specifying overlapping or adjacent ranges so gCloud SDK can merge the ranges into a single contiguous range.
See ports
section in https://cloud.google.com/compute/docs/load-balancing/network/forwarding-rules which has more clear explanation.
[Optional] A single port or single contiguous port range, ranging from low to high, for which this forwarding rule matches.