'How to integrate GCP CDN with GKE NGINX ingress

We are using NGINX ingress in our GKE setup, which means that GCP is using TCP load balancer to route the traffic to Kubernetes NGINX ingress.

We serve static content from kubernetes and would like to benefit from GCP CDN for this purpose. However, as far as I know, setting up CDN is not possible with TCP load balancer. How can we incorporate the GCP CDN into the setup? What possibilities there are?



Solution 1:[1]

You are correct that an Google Cloud external HTTP(S) load balancer is required in order to leverage CDN functionality. The only options I can think of:

  1. Replace NGINX ingress with GKE ingress. You can then use a BackendConfig to enable CDN. (I assume you don't want to do this)

  2. Use an HTTP(S) load balancer in front of NGINX in place of the TCP load balancer. You'd basically need to configure a standalone NEG for the NGINX service and then attach an HTTP(S) load balancer (and you'd enable CDN for the load balancer).

  3. Store you static content in a Google Cloud Storage bucket and configure the bucket to be the origin server for CDN. You'd of course have to update any links to the static content to the new URL(s).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1