Could we have a complete TrafficSplit example?

Meash documentation does provide an example for TrafficSplit over here: https://docs.mae.sh/configuration/#traffic-splitting. But this example does not cover the prior deployments and services required. We don't get to know what must be the configurations of the Service named server and server-v1 etc. It would be really helpful if we had the app deployment yaml too in the example.

Hello @kanishkarj,

Thanks for your interest in Maesh and your feedback :smiley:

You're right, maybe it can help to show how services and pods are deployed. In the case of a TrafficSplit there is nothing special to do. The only requirement as explained in the SMI specification is that:

There must be a match between a port on the root service and a port on every destination backend service.

The following example deploys a TrafficSplit with two services:

---
apiVersion: split.smi-spec.io/v1alpha2
kind: TrafficSplit
metadata:
  name: whoami-split
spec:
  service: whoami-service
  backends:
    - service: whoami-service-v1
      weight: 1
    - service: whoami-service-v2
      weight: 1

---
apiVersion: v1
kind: Service
metadata:
  name: whoami-service
spec:
  selector:
    app: whoami
  ports:
    - port: 80
      targetPort: http

---
apiVersion: v1
kind: Service
metadata:
  name: whoami-service-v1
spec:
  selector:
    app: whoami
    version: v1
  ports:
    - port: 80
      targetPort: http

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: whoami-v1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: whoami
      version: v1
  template:
    metadata:
      labels:
        app: whoami
        version: v1
    spec:
      containers:
        - name: whoami
          image: containous/whoami:v1.5.0
          ports:
            - name: http
              containerPort: 80

---
apiVersion: v1
kind: Service
metadata:
  name: whoami-service-v2
spec:
  selector:
    app: whoami
    version: v2
  ports:
    - port: 80
      targetPort: http

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: whoami-v2
spec:
  replicas: 1
  selector:
    matchLabels:
      app: whoami
      version: v2
  template:
    metadata:
      labels:
        app: whoami
        version: v2
    spec:
      containers:
        - name: whoami
          image: containous/whoami:v1.5.0
          ports:
            - name: http
              containerPort: 80

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: client
spec:
  selector:
    matchLabels:
      app: client
  template:
    metadata:
      labels:
        app: client
    spec:
      containers:
        - name: client
          image: giantswarm/tiny-tools:3.9
          command:
            - "sleep"
            - "3600"

Then, you can send a request to the root service from a pod with the following command:

kubectl exec deployment/client -- curl whoami-service.default.maesh

Hope this help!