0

I have a nextjs fronted application and a api hosted inside a kubernetes cluster. I am using istio for this implementation. So what I want to do now is whenever I do ssr I want to be able to get data from internal network without reaching out to my actual domain which I have exposed the API though Gateway.

Basically when from the server-side if I call api.example.com I want it to resolve to api.namespace.cluster.local so that my rendering and data fetching from server side will be lot faster and efficient

What is a good approach I can take in this scenario. Note that I have exposed this api service using gateway resolve to api.example.com too for client side rendering

z9fr
  • 384
  • 5
  • 10

1 Answers1

0

The way to achieve this is by creating a ServiceEntry. For example:

apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
  name: se-api-example-com
spec:
  hosts:
  - api.example.com
  location: MESH_INTERNAL
  ports:
  - name: http
    number: 80
    # target port of your k8s service
    targetPort: 8000
    protocol: HTTP
  resolution: DNS
  endpoints:
    - address: api.namespace.svc.cluster.local

This entry will effectively "translate" any requests made to api.example.com to go to api.namespace.svc.cluster.local:8000.

For more information on the ServiceEntry, check the Istio docs.

peterj
  • 103
  • 6