Istio: Route weight traffic to replica pods of a deployment

29 Views Asked by At

I have a deployment with 7 replica pods. In replica pods I give manual some labels version: ${nodeName}. After create virtual services and destination rules,but nothing happens. Also I can not see versioning traffic split in kiali. For destination rules Kiali said that can't find labels for host.

Is there another way to achieve traffic management to replica pods in a deployment?

This is my yaml files

apiVersion: apps/v1
kind: Deployment
metadata:
  name: recommendationservice
  namespace: online-boutique
spec:
  selector:
    matchLabels:
      app: recommendationservice
  replicas: 7
  template:
    metadata:
      labels:
        app: recommendationservice
    spec:
      serviceAccountName: recommendation
      terminationGracePeriodSeconds: 5
      containers:
      - name: server
        image: gcr.io/google-samples/microservices-demo/recommendationservice:v0.3.6
        ports:
        - containerPort: 8080
        readinessProbe:
          periodSeconds: 5
          exec:
            command: ["/bin/grpc_health_probe", "-addr=:8080"]
        livenessProbe:
          periodSeconds: 5
          exec:
            command: ["/bin/grpc_health_probe", "-addr=:8080"]
        env:
        - name: PORT
          value: "8080"
        - name: PRODUCT_CATALOG_SERVICE_ADDR
          value: "productcatalogservice.online-boutique.svc.cluster.local:3550"
        - name: DISABLE_TRACING
          value: "1"
        - name: DISABLE_PROFILER
          value: "1"
        - name: DISABLE_DEBUGGER
          value: "1"
        resources:
          requests:
            cpu: 100m
            memory: 220Mi
          limits:
            cpu: 200m
            memory: 450Mi
---
apiVersion: v1
kind: Service
metadata:
  name: recommendationservice
  namespace: online-boutique
spec:
  type: ClusterIP
  selector:
    app: recommendationservice
  ports:
  - name: grpc
    port: 8080
    targetPort: 8080

---

apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: recommendationservice
  namespace: online-boutique
spec:
  host: recommendationservice
  subsets:
  - labels:
      version: gke-cluster-1-pool-1-9d074513-6x27
    name: gke-cluster-1-pool-1-9d074513-6x27
  - labels:
      version: gke-cluster-1-default-pool-981dc8d2-g640
    name: gke-cluster-1-default-pool-981dc8d2-g640
  - labels:
      version: gke-cluster-1-default-pool-981dc8d2-75cq
    name: gke-cluster-1-default-pool-981dc8d2-75cq

---

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: recommendationservice
  namespace: online-boutique
spec:
  hosts:
    - recommendationservice
  http:
      - route:
        - destination:
              host: recommendationservice
              subset: gke-cluster-1-pool-1-9d074513-6x27
          weight: 10
        - destination:
              host: recommendationservice
              subset: gke-cluster-1-default-pool-981dc8d2-g640
          weight: 10
        - destination:
              host: recommendationservice
              subset: gke-cluster-1-default-pool-981dc8d2-75cq
          weight: 80


0

There are 0 best solutions below