istio service entry example

ServiceEntry allow us to register service to Istio so that istio would be able to route it correctly. In this example, we will take a request from a client and then forwards it to an external service entry called "portquiz.net". 

So let's create a service entry, virtual service and ingress gateway

apiVersion: networking.istio.io/v1

kind: ServiceEntry
metadata:
  name: portquiz-net
spec:
  hosts:
  - portquiz.net
  location: MESH_EXTERNAL
  ports:
  - number: 80
    name: http
    protocol: HTTP
  resolution: DNS
---
apiVersion: networking.istio.io/v1
kind: Gateway
metadata:
  name: example-gateway
spec:
  selector:
    istio: ingressgateway # use the default Istio ingress
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*"
---
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
  name: forward-to-example
spec:
  hosts:
  - "*" # accept any host (localhost)
  gateways:
  - example-gateway
  http:
  - match:
    - uri:
        prefix: /
    rewrite:
      uri: /  
    route:
    - destination:
        host: portquiz.net
        port:
          number: 80
     

The configuration is quite simple. The only catch is the portquiz.net or any other host for that matter
will tend to look for host headers too.

So we need to pass this information along

curl -v -H "Host: portquiz.net" http://localhost:80

We will get output "Port test successful" as shown below:-


And then doing a log of our ingress

kubectl logs istio-ingressgateway-6c5b69ccf5-jl6nb -n istio-system -f

We will get similiar outputs:-






















Comments

Popular posts from this blog

gemini cli getting file not defined error

NodeJS: Error: spawn EINVAL in window for node version 20.20 and 18.20

vllm : Failed to infer device type