apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: cluster-gateway
spec:
  selector:
    istio: ingressgateway # use istio default controller
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*"

---

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: demo-vs
spec:
  hosts:
  - "demo.example.com"
  gateways:
  - cluster-gateway
  http:
  - match:
    - headers:
        stage:
          exact: dev
    route:
    - destination:
        host: demo-service
        subset: v3
        port:
          number: 8080
  - match:
    route:
    - destination:
        host: demo-service
        subset: v1
        port:
          number: 8080
      weight: 80
    - destination:
        host: demo-service
        subset: v2
        port:
          number: 8080
      weight: 20



---

apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: demo-destinationrule
spec:
  host: demo-service
  subsets:
  - name: v1
    labels:
      version: v1
  - name: v2
    labels:
      version: v2
  - name: v3
    labels:
      version: v3
