Adding path matcher creates two competing rules

569 views
Skip to first unread message

Colin Hawkett

unread,
Oct 26, 2015, 7:49:57 PM10/26/15
to gce-discussion
Hi,

As an initial step, I have configured a load balancer with a default back end, and when visiting https://console.developers.google.com/networking/loadbalancing/http/urlMaps/details/<url-map-name> it shows the following:

Host                      Path                       Backend Service
--------------------------------------------------------------------
Any Unmatched (default)   Any Unmatched (default)    default-backend

I would like to add a second backend and a host/path matcher configuration to this load balancer. Having created the new backend service, I used the following command to create the host/path:

gcloud compute url-maps add-path-matcher primary-url-map --default-service default-backend --new-hosts images.mydomain.com --path-matcher-name all-paths --path-rules '/*=secondary-backend'

The outcome of this in the above console view is:

Host                      Path                       Backend Service
----------------------------------------------------------------------
Any Unmatched (default)   Any Unmatched (default)    default-backend
images.mydomain.com       /*                         default-backend
images.mydomain.com       /*                         secondary-backend

Is this expected? It seems like the system is trying to protect against unmatched paths (the reason why default-service is a required param if I understand correctly), however the first line already achieves this outcome. The configurations that were added look like they will conflict - is that the case? Thanks,

Colin




Faizan (Google Cloud Support)

unread,
Oct 29, 2015, 12:01:59 PM10/29/15
to gce-dis...@googlegroups.com
Hello Colin,

Your assumption regarding the unmatched paths is correct. If you add the path matcher via the gcloud command using the command you have specified, then a rule will be made to match /* (regardless of if you're defining /* as the path to be matched).

Interestingly, in the UI through Developer console, you must specify these rules manually, which avoids this automatic rule creation. The correct choice here is to simply leave off the last part of the command you specified, and replace the service specified by --default-service with the correct backend service:

gcloud compute url-maps add-path-matcher primary-url-map --default-service secondary-backend --new-hosts images.mydomain.com --path-matcher-name all-paths

I hope that helps.

Faizan
Reply all
Reply to author
Forward
0 new messages