<p>I am trying to learn the basics about istio so I have gone through the official documentation <a href="https://istio.io/latest/docs/concepts/traffic-management/" rel="nofollow noreferrer">here</a> in order to create a 80/20 canary deployment, I have also follow this guide from digitalocean which explains it very easy for a simple deployment <a href="https://www.digitalocean.com/community/tutorials/how-to-do-canary-deployments-with-istio-and-kubernetes" rel="nofollow noreferrer">https://www.digitalocean.com/community/tutorials/how-to-do-canary-deployments-with-istio-and-kubernetes</a>.</p>
<p>I have created a simple app with 2 different messages on the homepage, and then created the virtualService, Gateway and the destination rules. I (as mentioned in the guide) get the external ip with <code>kubectl -n istio-system  get svc</code> and the try to navigate to that address but I get a 503 error. It seems very simple but I have to be missing something. These are my 3 files (as far as I understand there are no more necessary files):</p>
<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  namespace: istio
  name: flask-gateway
spec:
  selector:
    istio: ingressgateway
  servers:
  - hosts:
    - &quot;*&quot;
    port:
      name: http
      number: 80
      protocol: HTTP
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: flask-app
  namespace: istio
spec:
  hosts:
  - &quot;*&quot;
  gateways:
  - flask-gateway
  http:
  - route:
    - destination:
        host: flask-app
        subset: v1
      weight: 80
    - destination:
        host: flask-app
        subset: v2
      weight: 20
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: flask-app
  namespace: istio
spec:
  host: flask-app
  subsets:
  - name: v1
    labels:
      version: v1
  - name: v2
    labels:
      version: v2

</code></pre>
<p>Here are the yaml with deployment and services for v1 and v2:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    version: v1
  name: flask-deployment-v1
  namespace: istio
spec:
  replicas: 1
  selector:
    matchLabels:
      app: flask-app
  template:
    metadata:
      labels:
        version: v1
        app: flask-app
    spec:
      containers:
      - name: flask-app
        image: latalavera/flask-app:1.3
        ports:
          - containerPort: 5000
        resources:
          requests:
            cpu: 100m
            memory: 128Mi
          limits:
            cpu: 250m
            memory: 256Mi

---
apiVersion: v1
kind: Service
metadata:
  name: flask-service
  namespace: istio
spec:
  selector:
    app: flask-app
  ports:
  - port: 5000
    protocol: TCP
    targetPort: 5000
  type: ClusterIP


</code></pre>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    version: v2
  name: flask-deployment-v2
  namespace: istio
spec:
  replicas: 1
  selector:
    matchLabels:
      app: flask-app
  template:
    metadata:
      labels:
        app: flask-app
        version: v2
    spec:
      containers:
      - name: flask-app
        image: latalavera/flask-app:2.0
        ports:
          - containerPort: 5000
        resources:
          requests:
            cpu: 100m
            memory: 128Mi
          limits:
            cpu: 250m
            memory: 256Mi

---
apiVersion: v1
kind: Service
metadata:
  name: flask-service2
  namespace: istio
spec:
  selector:
    app: flask-app
  ports:
  - port: 5000
    protocol: TCP
    targetPort: 5000
  type: ClusterIP

</code></pre>
<p>I have added the labels <code>version: v1 </code>and <code>version: v2 </code>to my deployments, and I have also used the <code>kubectl label ns istio istio-injection=enabled </code> command, but they are not working anyways</p>

Jesus Fernandez
<p>You named the service <code>flask-service</code> and set the <code>host</code> in your <code>VirtualService</code> to <code>flask-app</code>.</p>
<p>The <code>host</code> field is not a selector but the <code>FQDN</code> of the service you want to route the traffic to. So it should be called <code>flask-service</code> or better <code>flask-service.istio.svc.cluster.local</code>:</p>
<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: flask-app
  namespace: istio
spec:
  hosts:
  - &quot;*&quot;
  gateways:
  - flask-gateway
  http:
  - route:
    - destination:
        host: flask-service.istio.svc.cluster.local
        subset: v1
      weight: 80
    - destination:
        host: flask-service.istio.svc.cluster.local
        subset: v2
      weight: 20
</code></pre>
<p>Alternatively you could just call the service <code>flask-app</code> like the <code>Deployment</code>. But using the full <code>FQDN</code> <code>&lt;service-name&gt;.&lt;namespace-name&gt;.svc.cluster.local</code> is recommended in any case. From docs:</p>
<blockquote>
<p>Note for Kubernetes users: When short names are used (e.g. “reviews” instead of “reviews.default.svc.cluster.local”), Istio will interpret the short name based on the namespace of the rule, not the service. A rule in the “default” namespace containing a host “reviews” will be interpreted as “reviews.default.svc.cluster.local”, irrespective of the actual namespace associated with the reviews service. To avoid potential misconfigurations, it is recommended to always use fully qualified domain names over short names.</p>
</blockquote>
<p><a href="https://istio.io/latest/docs/reference/config/networking/virtual-service/#VirtualService" rel="nofollow noreferrer">https://istio.io/latest/docs/reference/config/networking/virtual-service/#VirtualService</a> -&gt; hosts</p>
<p>You btw don't need 2 services, just one. Your service has a <code>selector</code> for <code>app: flask-app</code> so it can route traffic to v1 and v2. How the traffic is routed is defined by the <code>VirtualService</code> and <code>DestionationRule</code>. I would recommand to remove service <code>flask-service2</code>. If you need to route the traffic inside the mesh, add <code>mesh</code> as <code>gateways</code> in the <code>VirtualService</code> or create a new one for mesh internal traffic, to reach both versions. More on that topic:</p>
<p><a href="https://istio.io/latest/docs/reference/config/networking/virtual-service/#VirtualService" rel="nofollow noreferrer">https://istio.io/latest/docs/reference/config/networking/virtual-service/#VirtualService</a> -&gt; gateways</p>
