0

I tried to follow istio traffic-management https://istio.io/latest/docs/concepts/traffic-management/ to split my traffic and rout them to different versions of a service. But what ever weight I changed to, traffic was only routed to one version, it could be ran v1 or v2. Looks like weight and destination configuration didn't work. Here is my yaml file :

---
apiVersion: v1
kind: Service
metadata:
  name: my-app
spec:
  type: ClusterIP
  ports:
    - port: 443
      targetPort: 9091
      protocol: TCP
      name: my-app
  selector:
    app: my-app
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app-v1
  labels:
    app: my-app
    version: v1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
        version: v1
---
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
  name: my-app
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: my-app
  minReplicas: 1
  maxReplicas: 2
  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 50
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: my-app
spec:
  host: my-app.com
  trafficPolicy:
    loadBalancer:
      simple: RANDOM
  subsets:
    - name: v1
      labels:
        version: v1
    - name: v2
      labels:
        version: v2
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: my-app-gateway
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      name: https
      number: 443
      protocol: HTTPS
    tls:
      mode: PASSTHROUGH
    hosts:
    - "my-app.com"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: my-app-virtual-service
spec:
  gateways:
  - my-app-gateway
  hosts:
  - my-app.com
  tls:
  - match:
    - port: 443
      sniHosts:
      - my-app.com
    route:
    - destination:
        host: my-app.com
        port:
          number: 443
        subset: v1
      weight: 50
    - destination:
        host: my-app.com
        port:
          number: 443
        subset: v2
      weight: 50

Couldn't tell what's wrong...

0 Answers0