I want to have separate Host address for two namespaces in K8S clusters having same endpoints in both svc

2/15/2020

I am using the Istio sidecar injection. I have two namespaces in my cluster with istio-enabled. Below mentioned are two namespaces i.e bk and abhi. Also, I have a separate gateway for each namespace.

The following is for bk namespace.

I want to Access service by Ingress for bk namespace.

bk.localhost.cluster

Below is Gateway for bk namespace :

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: abhijeet
  namespace: bk
spec:
  selector:
    istio: ingressgateway
  servers:
  - hosts:
    - bk.localhost.cluster
    port:
      name: http
      number: 80
      protocol: HTTP

Below in VirtualService for bk namespace:-

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  generation: 58
  name: bk
  namespace: bk
spec:
  gateways:
  - abhijeet
  hosts:
  - bk.localhost.cluster
  http:
 - match:
      uri:
        prefix: /pune
    route:
    - destination:
        host: wagholi
        port:
          number: 8080
 - match:
      uri:
        prefix: /pune/{location}
    route:
    - destination:
        host: yerwada
        port:
          number: 8080

The following is for abhi namespace.

I want to Access service by Ingress for abhi namespace.

abhi.localhost.cluster

Below is Gateway for abhi namespace :

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: thebk
  namespace: abhi
spec:
  selector:
    istio: ingressgateway
  servers:
  - hosts:
    - abhi.localhost.cluster
    port:
      name: http
      number: 80
      protocol: HTTP

Below in VirtualService for abhi namespace:-

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: abhi
  namespace: abhi
spec:
  gateways:
  - thebk
  hosts:
  - abhi.localhost.cluster
  http:
 - match:
      uri:
        prefix: /pune
    route:
    - destination:
        host: wagholi
        port:
          number: 8080
 - match:
      uri:
        prefix: /pune/{location}
    route:
    - destination:
        host: yerwada
        port:
          number: 8080

I am getting a 404 error in postman.

404 Not Found

-- Balkrishna
gateway
istio
kubernetes
kubernetes-ingress
routing

0 Answers