Istio destination rule not working


#1
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: echo-vsvc
spec:
  hosts:
  - echo-svc.default.svc.cluster.local
  http:
  - match:
    - uri:
        prefix: "/v1"
    route:
    - destination:
        host: echo-svc.default.svc.cluster.local
        subset: v1
  - route:
    - destination:
        host: echo-svc.default.svc.cluster.local
        subset: v1
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: echo-destination
spec:
  host: echo-svc.default.svc.cluster.local
  subsets:
  - name: v1
    labels:
      version: "1"
  - name: v2
    labels:
      version: "2"

Trying to call this service from a virtualservice from flask app:

@app.route("/e1")
def f1():
    tracking_headers = getForwardHeaders(request)
    return requests.get('http://echo-svc.default.svc.cluster.local/v1', headers=tracking_headers).content


@app.route("/e2")
def f2():
    tracking_headers = getForwardHeaders(request)
    return requests.get('http://echo-svc.default.svc.cluster.local', headers=tracking_headers).content

Service is not getting routed to v1 version, it’s getting on both v1 and v2 version.

If I do istioctl proxy-config routes $(k get pods -l app=frontend -o=jsonpath='{.items[*].metadata.name}') -o json, I see not routes related to echo-service and everything proxy-status says everything is in sync.

Deployed pod status

$ > k get pods --show-labels
NAME                              READY   STATUS    RESTARTS   AGE     LABELS
echo-deploy-v1-7468d898b8-64zcp   2/2     Running   0          5m35s   app=echo-app,pod-template-hash=7468d898b8,version=1
echo-deploy-v2-b65565566-5xsxv    2/2     Running   0          5m3s    app=echo-app,pod-template-hash=b65565566,version=2
frontend-v2-7b9bd94b49-xhdgh      2/2     Running   0          19m     app=frontend,pod-template-hash=7b9bd94b49,vm=v2

Not sure what I’m missing over help, any pointers will be helpful


#2

After pulling my hairs for days, playing with all permuation and combinations. Found my mistake at: https://github.com/istio/istio/issues/9696.

It was related to service named port. I had named it just “web”, updating it to “http-web”, worked for me, and everything else worked fine.

Stackoverflow answer link : https://stackoverflow.com/questions/54197734/istio-destination-rule-subsets-not-working/54209833#54209833.