Traffic Management Using Istio

Learn how CD-as-a-Service implements traffic management using Istio.

Before you begin

How CD-as-a-Service shapes traffic

In the following example, you define a CD-as-a-Service deployment that uses a VirtualService and DestinationRoute:

CD-as-a-Service Deployment (deploy.yaml) Istio Resources (istio-resources.yaml)
version: v1
kind: kubernetes
application: reviews
targets: 
  dev:
    account: dev
    namespace: istiodemo
		strategy: strategy1 
manifests:
  - path: manifests/reviews.yaml
  - path: manifests/istio-resources.yaml
strategies:
  strategy1:
    canary: 
      steps:
        - setWeight:
            weight: 10
        - pause:
            untilApproved: true
        - setWeight:
            weight: 90
        - pause:
            untilApproved: true
trafficManagement:
  - targets: ["dev"]
    istio:
    - virtualService: 
        name: reviews 
        httpRouteName: http-route-reviews
      destinationRule: 
        name: reviews 
        activeSubsetName: stable
        canarySubsetName: canary # does not exist yet
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: reviews
spec:
  hosts:
    - reviews
  http:
  - route:
    - destination:
        host: reviews.istiodemo.svc.cluster.local
        subset: stable
    name: http-route-reviews
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: reviews
spec:
  host: reviews.istiodemo.svc.cluster.local
  subsets:
  - name: stable
    labels:
      app: reviews

Mapping

Deployment Field (deploy.yaml) Deploy Line Istio Resources Field (istio-resources.yaml) Istio Line
virtualService.name 28 VirtualService.metadata.name 4
virtualService.httpRouteName 29 VirtualService.http.route.name 13
destinationRule.name 31 DestinationRule.metadata.name 18
destinationRule.activeSubsetName 32 VirtualService.http.route.destination.subset 12

When you deploy your app, CD-as-a-Service modifies your VirtualService and DestinationRule, setting weights for stable and canary subsets based on the weights specified in your deployment strategy. CD-as-a-Service also adds the armory-pod-template-hash label to the DestinationRule subsets for routing traffic to the pods of each ReplicaSet.

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: reviews
spec:
  hosts:
    - reviews
  http:
  - route:
    - destination:
        host: reviews.istiodemo.svc.cluster.local
        subset: stable
      weight: 10
    - destination: 
        host: reviews.istiodemo.svc.cluster.local
        subset: canary
      weight: 90
    name: http-route-reviews
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: reviews
spec:
  host: reviews.istiodemo.svc.cluster.local
  subsets:
  - name: stable
    labels:
      app: reviews
      armory-pod-template-hash: gc6647
  - name: canary
    labels:
      app: reviews
      armory-pod-template-hash: cd6648

At the end of the deployment, CD-as-a-Service removes the lines it added so the resources look the same as before the deployment began.

Additional capabilities

  • You have two options for deploying your VirtualService and DestinationRule Istio resources:

    1. Separately, before your CD-as-a-Service deployment
    2. As part of your CD-as-a-Service deployment, included in the same directory as your app manifest
  • You can use a VirtualService that has more than one route as long as the route is named within the resource and specified in your deployment file.

  • CD-as-a-Service supports both FQDN and short names in the host fields.

What’s next


Last modified January 13, 2023: (d790310a)