I’m implementing server side tagging for Google Tag Manager through my GKE Gateway API.
I was successfully able to configure server side tag manager in same domain and GET https://www.example.com/metrics/healthy to return OK. Below is my gateway configuration.
kind: Gateway
apiVersion: gateway.networking.k8s.io/v1
metadata:
name: http-gateway
spec:
gatewayClassName: gke-l7-global-external-managed
listeners:
- name: http
protocol: HTTP
port: 80
allowedRoutes:
kinds:
- kind: HTTPRoute
namespaces:
from: Selector
selector:
matchLabels:
otherInfra: httpToHttps
- name: https
protocol: HTTPS
port: 443
tls:
mode: Terminate
options:
networking.gke.io/pre-shared-certs: http-ssl
addresses:
- type: NamedAddress
value: gke-http
---
kind: HTTPRoute
apiVersion: gateway.networking.k8s.io/v1
metadata:
name: nginx
spec:
parentRefs:
- name: http-gateway
hostnames:
- "www.example.com"
rules:
- backendRefs:
- name: nginx
port: 80
---
kind: HTTPRoute
apiVersion: gateway.networking.k8s.io/v1
metadata:
name: metrics
spec:
parentRefs:
- name: http-gateway
hostnames:
- "www.example.com"
rules:
- matches:
- path:
type: PathPrefix
value: /metrics
backendRefs:
- name: metrics
port: 8080
Above configuration can forward all /metrics traffic to server side tag. Now to serve first-party “script” requests to Google servers, I’m following the below document (Serve scripts with a CDN).
https://developers.google.com/tag-platform/tag-manager/server-side/dependency-serving?option=cdn
It says:
-
Collection path (e.g. /metrics) → Forwards events to your tagging server
-
Script path (e.g. /scripts) → Forwards first-party script requests to Google servers
Step 1 is already completed. How can I achieve step 2? I followed the below document to setup Google tag gateway. But my Load Balancer created using GKE Gateway API. I cannot modify it in Google Cloud Console. But I was able to setup backend service (Internet NEG) mentioned in the document.
https://developers.google.com/tag-platform/tag-manager/gateway/setup-guide?setup=manual#setup-type
Is there a way I can link this backend with my Gateway API through HTTPRoute or any other resource?
Or is there any other way to achive this?