Setting up Dynamic Routing

If Services have the capability to propagate request headers from incoming to outgoing requests, Signadot can dynamically route requests to specific versions of Services in Workspaces. These headers are automatically set on requests that go through Signadot Preview URLs. Multi-Service Workspaces are implemented using lightweight sidecars or by integrating with a service mesh. Among service meshes, currently Istio is supported.

You would need to opt-in each service to Signadot workspace routing. Routing ensures that requests made to Preview URLs reach the customized versions of Services in Workspaces.

Setting up routing using Signadot sidecar

If your app is not running in Istio, you can enable workspace routing by opting each service into Signadot sidecar injection. This can be done by adding an annotation to the Pod template of each service's Deployment as shown below.

apiVersion: apps/v1
kind: Deployment
metadata:
  ...
spec:
  template:
    metadata:
      annotations:
        # Set the value to "http" or "grpc" based on
        # the protocol that this service uses.
        sidecar.signadot.com/inject: http

In order to add the inject annotation to a particular deployment, you can run the following kubectlcommand.

kubectl -n <namespace> patch deployment <deployment-name> -p '{
   "spec":{
      "template":{
         "metadata":{
            "annotations":{
               "sidecar.signadot.com/inject": "http"
            }
         }
      }
   }
}'

If Signadot is already installed in the cluster, the Pods will have a proxy sidecar container injected, which will perform workspace routing based on metadata in each request.

Setting up routing using Istio

If your app is running in an Istio mesh, the only requirement to enable workspace routing is that each Service has a matching VirtualService in the same namespace. If you don't already have a VirtualService defined, you just need to create a basic one with a default route. For example, here is a basic VirtualService for a Service called my-svc in namespace ns-1:

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: my-svc
  namespace: ns-1
spec:
  hosts:
  - my-svc.ns-1.svc.cluster.local
  http:
  - name: default
    route:
    - destination:
        host: my-svc.ns-1.svc.cluster.local

Signadot will then add and remove routes in the VirtualService as needed to configure workspace routing.


Did this page help you?