Google Cloud CDN, storage and container issue with backend service

I have a specific use case that I cannot solve.

Typical gcloud setup:

  • K8S Cluster

  • Gcloud storage container

  • Gcloud balancer

I managed to get my domain https://cdn.foobar.com/uploads/ to point to the backend for google storage without any problems: I can access the files. Its a backend service that fails.

I would like the CDN act as a cache when an HTTP request hits it, for example https://cdn.foobar.com/assets/x.jpg , if it does not have a copy of the asset, it should request another https://foobar.com/assets/x.jpg domain https://foobar.com/assets/x.jpg .

I realized that there were backend-service load balancers for this. (Right?)

backend-service points to a group of k8s cluster instances and requires a port. I guessed that I need to allow the firewall to expose Nodeport my web application service so that the loadbalancer can request it.

Cdn cloud

enter image description here

enter image description here

Load balancing

Failure health checks.

enter image description here

The backend service points to a group of k8s cluster instances and requires that some ports (80 by default) 80 fail. I guessed that I need to allow the firewall to expose 32231 Nodeport my web application service so that the loadbalancer can request it. This has not succeeded since 502.

?> kubectl describe svc Name: backoffice-service Namespace: default Labels: app=backoffice Selector: app=backoffice Type: NodePort IP: 10.7.xxx.xxx Port: http 80/TCP NodePort: http 32231/TCP Endpoints: 10.4.xx:8500,10.4.xx:8500 Session Affinity: None No events.

enter image description here

At that moment, I ran out of ideas. Any hints in the right direction would be greatly appreciated.

+5
source share
1 answer

When you deploy a service as a NodePort type , you expose the service on every Node IP address, but the service does not have access to appearance, so you need to expose your service as a "LoadBalancer"

Since you want to use the HTTP (S) Load Balancer, I recommend using the Kubernetes Ingress resource . This resource will be responsible for configuring HTTP (s) load balancing and the required ports that your service uses, as well as verifying the health of the specified port.

Since you are protecting your application, you need to set up secret to protect Ingress .

This example will help you get started with Ingress with the completion of TLS.

+1
source

Source: https://habr.com/ru/post/1266422/


All Articles