DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Look, Ma! No Pods!
  • Zero-Downtime Deployments for Java Apps on Kubernetes
  • Self-Hosted Inference Doesn’t Have to Be a Nightmare: How to Use GPUStack
  • Smart Deployment Strategies for Modern Applications

Trending

  • Mocking Kafka for Local Spring Development
  • Compliance Automated Standard Solution (COMPASS), Part 10: How OSCAL Mapping Paves the Way for Continuous Compliance Scalability
  • How to Write for DZone Publications: Trend Reports and Refcards
  • A Hands-On ABAP RESTful Programming Model Guide
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Canary and Dark Release Using an Istio Service Mesh on Kubernetes

Canary and Dark Release Using an Istio Service Mesh on Kubernetes

In this article, take a look at a canary and dark release using an Istio service mesh on Kubernetes.

By 
Gaurav Gupta user avatar
Gaurav Gupta
·
May. 11, 20 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
7.9K Views

Join the DZone community and get the full member experience.

Join For Free

Istio Service Mesh on Kubernetes (k8s) cluster brings in quite a few architectural patterns off the shelf. In this article , I want to show you how we can quickly implement Canary Releases and Dark Releases using Istio service mesh

As a developer, it is imperative that you are able to install a k8s cluster and try out. With the latest release of Kops, it is pretty straightforward to fire up a new K8s cluster on AWS. I have created a series of steps and commands in my repo here - Kubernetes-AWS-Istio, which you can follow to create it on AWS. I have also kept istio installation file that you can apply using kubectl to start Istio pods on cluster. You do not need to install Istioctl to install Istio if you use the file provided by me. The Istio installation file on my repo is a standard K8s YAML.

Istio is resource hungry and may require stop-start in case you want to run it on Minikube locally instead of AWS. In my repo, I have also kept a reduced Istio profile for Minikube. You can apply this file using kubectl. You should start Minikube with at least 4096 mb memory.

Canary Release

Canary release is a form of deployment where you want to divert a percentage of traffic to new version to test out the correctness before opening up to all users. In the below picture, we have a message service, which internally calls up another service called “greeting” to get those messages. This greeting service now has new pods labeled risky, which you want to try as canary before releasing it fully.

Diagram of Kubernetes cluster

With this background, let us start configuring Istio.

1. Configure Ingress Gateway

  • Set up Ingress Gateway: Below I have kept the hosts field as * , to respond to all hosts. If You want to set it up for specific hosts, you can do that as well by providing url for that.
YAML
xxxxxxxxxx
1
14
 
1
apiVersion: networking.istio.io/v1alpha3
2
kind: Gateway
3
metadata:
4
  name: ingress-gateway-configuration
5
spec:
6
  selector:
7
    istio: ingressgateway # use Istio default gateway implementation
8
  servers:
9
    - port:
10
        number: 80
11
        name: http
12
        protocol: HTTP
13
      hosts:
14
        - "*"   # Domain name of the external website


  • Set up Virtual Service: Virtual service is where the routing decision happens. In our set up, we want all requests coming to ingress gateway to call up Message Service. You can do a variety of route settings on virtual service based on path and headers etc. which we will see later.
YAML
xxxxxxxxxx
1
15
 
1
kind: VirtualService
2
apiVersion: networking.istio.io/v1alpha3
3
metadata:
4
  name: hello-gateway
5
  namespace: default
6
spec:
7
  hosts:      # which incoming host are we applying the proxy rules to???
8
    - "*"
9
  gateways:
10
    - ingress-gateway-configuration
11
  http:
12
    - route: # CATCH ALL
13
        - destination:
14
            host: message.default.svc.cluster.local
15
            subset: safe


  • Set up Destination Rules: Destination rules can be thought of as load balancing set up for a service. We can apply variety of traffic rules here before actual service is initiated. In this case, we are making a straight call to message service.
YAML
xxxxxxxxxx
1
12
 
1
kind: DestinationRule
2
apiVersion: networking.istio.io/v1alpha3
3
metadata:
4
  name: hello-gateway
5
  namespace: default
6
spec:
7
  host: message.default.svc.cluster.local
8
  subsets:
9
    - labels: # SELECTOR.
10
        app: message # find mesage service pods
11
      name: safe
12

          


2. Configure Message Service

Message Service calls up greeting service internally. However, the call to greeting service is intercepted by Istio-proxy and this is how Istio is able to offer various patterns. In this case, greeting service intercepted by Istio can now be set up to bifurcate traffic among our safe and risky pods, thus a canary release

  • Set up Virtual Service: Virtual service is where routing decision happens. We want to route 80 percent of traffic to safe or existing pods and 20 percent of traffic to canary or risky pods.
YAML
 
xxxxxxxxxx
1
18
 
1
kind: VirtualService
2
apiVersion: networking.istio.io/v1alpha3
3
metadata:
4
  name: greeting
5
  namespace: default
6
spec:
7
  hosts:      # incoming host are we applying the proxy rules to
8
    - greeting.default.svc.cluster.local # Copy the value in the gateway hosts - usually a Domain Name
9
  http:
10
    - route:
11
        - destination:
12
            host: greeting.default.svc.cluster.local # The Target DNS name
13
            subset: safe  # The name defined in the DestinationRule
14
          weight: 80
15
        - destination:
16
            host: greeting.default.svc.cluster.local # The Target DNS name
17
            subset: risky  # The name defined in the DestinationRule
18
          weight: 20


  • Set up Destination Rule: This is where you load balance your service. Here we have divided based on pod labels. All new canary pods are labeled risky and existing running pods are labeled safe.
YAML
xxxxxxxxxx
1
14
 
1
kind: DestinationRule
2
apiVersion: networking.istio.io/v1alpha3
3
metadata:
4
  name: greeting
5
  namespace: default
6
spec:
7
  host: greeting.default.svc.cluster.local
8
  subsets:
9
    - labels:   # SELECTOR.
10
        version: safe # find pods with label "safe"
11
      name: safe
12
    - labels:  # SELECTOR.
13
        version: risky # find pods with label "risky"
14
      name: risky


DARK Release

Dark release is when you want only specific users to be able to access the service. Istio is powerful and configurable. If instead of Canary release, you wanted to do a dark release then you can set up proxy configurations.

In my example, I have decided that all user requests which carry extra header - “ x-my-header” with value as dark, would go to newly deployed risky pod. Rest other requests, which do not carry this header, would continue on safe existing pods.

  • Set up Virtual Service: Virtual service is where routing decision happens. Here we have configured our service to match headers in the request and then called up Dark Release pod set up in Destination Rule.

YAML
x
21
 
1
kind: VirtualService
2
apiVersion: networking.istio.io/v1alpha3
3
metadata:
4
  name: hello-kubernetes
5
  namespace: default
6
spec:
7
  hosts:      # which incoming host are we applying the proxy rules to???
8
    - greeting.default.svc.cluster.local # Copy the value in the gateway hosts - usually a Domain Name
9
  http:
10
    - match:
11
        - headers: # Match header
12
            x-my-header: # header that we decided for dark release
13
              exact: dark # exact match
14
      route:
15
        - destination:
16
            host: greeting.default.svc.cluster.local # The Target DNS name for dark release
17
            subset: risky # The name defined in the DestinationRule
18
    - route:
19
        - destination:
20
            host: greeting.default.svc.cluster.local # The Target DNS name
21
            subset: safe  # The name defined in the DestinationRule


  • Set up Destination Rule: This remains the same as in Canary Release

We could also do mirroring of requests as well using Istio. That implies that you can make a service live and keep pushing user requests to it to generate output, which you can then compare with the live running system.

You can follow instructions in my repo Kubernetes-AWS-Istio to run this as a live example.

Happy coding!

Release (computing) Kubernetes

Opinions expressed by DZone contributors are their own.

Related

  • Look, Ma! No Pods!
  • Zero-Downtime Deployments for Java Apps on Kubernetes
  • Self-Hosted Inference Doesn’t Have to Be a Nightmare: How to Use GPUStack
  • Smart Deployment Strategies for Modern Applications

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook