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

拟墨画扇 提交于 2020-03-05 00:24:09

问题


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

来源:https://stackoverflow.com/questions/60237159/i-want-to-have-separate-host-address-for-two-namespaces-in-k8s-clusters-having-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!