istio-virtualservice-merger

command module
v0.0.0-...-35f65b5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

README

istio-virtualservice-merger

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

Installation

Install the CRD
kubectl apply -f https://raw.githubusercontent.com/monimesl/istio-virtualservice-merger/master/manifest/crd.yaml
Deploy the operator
kubectl apply -f https://raw.githubusercontent.com/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"
Create a review VirtualServiceMerge
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"
Create a product VirtualServiceMerge
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 # 0 is the precedence
      route:
        - destination:
            port:
              number: 8080
            host: "review-service"
    - match:
        - uri:
            prefix: "/products"
      # 1 is the precedence, 'product-routes' route will appear before any routes with lesser 
      # precedence that were merged onto the target even if they're from a different patch.      
      name: product-routes-1
      route:
        - destination:
            port:
              number: 8080
            host: "product-service"
The merging works for TCP and TLS routes as well

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
api
v1alpha1
Package v1alpha1 contains API Schema definitions +kubebuilder:object:generate=true +groupName=istiomerger.monime.sl
Package v1alpha1 contains API Schema definitions +kubebuilder:object:generate=true +groupName=istiomerger.monime.sl
tests
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL