Ingress gateway routing

I have a cluster on AKS. I want to access my discovery server via the Ingress gateway.
Here are my discovery server’s deployment and service manifests :

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert
kompose.version: 1.16.0 (0c01309)
creationTimestamp: null
labels:
io.kompose.service: discovery-server
name: discovery-server
spec:
replicas: 1
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
io.kompose.service: discovery-server
spec:
containers:

  • env:
  • name: JAEGER_SERVICE_NAME
    value: discovery-server
  • name: JAEGER_PROPAGATION
    value: b3
    image: medhedho/discovery_zi
    name: discovery-server
    ports:
  • containerPort: 8761
    resources: {}
    restartPolicy: Always
    status: {}

apiVersion: v1
kind: Service
metadata:
annotations:
kompose.cmd: kompose convert
kompose.version: 1.16.0 (0c01309)
creationTimestamp: null
labels:
io.kompose.service: discovery-server
name: discovery-server
spec:
ports:

  • name: “http”
    port: 8761
    targetPort: 8761
    selector:
    io.kompose.service: discovery-server
    status:
    loadBalancer: {}

I deployed Istio on the cluster, and enabled the automatic sidecar injection.
Here are my virtual service and gateway manifests :

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: school-gateway
spec:
selector:
istio: ingressgateway # use istio default controller
servers:

  • port:
    number: 80
    name: http
    protocol: HTTP
    hosts:
  • “*”

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: school
spec:
hosts:

  • “*”
    gateways:
  • school-gateway
    http:
  • match:
    • uri:
      exact: /discovery-server
      route:
    • destination:
      host: discovery-server
      port:
      number: 8761

The URL ($GATEWAY_URL/discovery-server) gives me a 404 error.

does your backed pod have “/discovery-server”? if not then you will get 404 error.

if backend works on “/” path then try https://istio.io/docs/reference/config/networking/virtual-service/#HTTPRewrite to send /discovery-server as “/” to the backend

    - match:
        - uri:
            prefix: /discovery-server
      rewrite:
        uri: /

It works. Thank you :grinning:

1 Like