Services DevOps DevSecOps Cloud Consulting Infrastructure Automation Managed Services AIOps MLOps DataOps Microservices 🔐 Private AINEW Solutions DevOps Transformation CI/CD Automation Platform Engineering Security Automation Zero Trust Security Compliance Automation Cloud Migration Kubernetes Migration Cloud Cost Optimisation AI-Powered Operations Data Platform Modernisation SRE & Observability Legacy Modernisation Managed IT Services 🔐 Private AI DeploymentNEW Products ✨ ZippyOPS AINEW 🛡️ ArmorPlane 🔒 DevSecOpsAsService 🖥️ LabAsService 🤝 Collab 🧪 SandboxAsService 🎬 DemoAsService Bootcamp 🔄 DevOps Bootcamp ☁️ Cloud Engineering 🔒 DevSecOps 🛡️ Cloud Security ⚙️ Infrastructure Automation 📡 SRE & Observability 🤖 AIOps & MLOps 🧠 AI Engineering 🎓 ZOLS — Free Learning Company About Us Projects Careers Get in Touch

Blue/Green Deployment with Istio in Kubernetes

Blue/Green Deployment with Istio: Streamline Kubernetes Updates

In today’s fast-paced development world, ensuring seamless updates and minimizing downtime are critical. One powerful way to achieve this in Kubernetes is by using Blue/Green deployment strategies with Istio. This service mesh simplifies traffic management, making communication between microservices secure and transparent. Istio also provides tools that enhance both operational efficiency and security.

In this guide, we will walk you through setting up Blue/Green deployments using Istio, leveraging Kubernetes’ native features alongside Istio’s traffic management capabilities. At ZippyOPS, we specialize in DevOps, Cloud, and AIOps solutions, offering consulting, implementation, and managed services to help you build scalable infrastructure using the latest technologies.

Kubernetes Blue/Green Deployment with Istio traffic management

What is Blue/Green Deployment?

Blue/Green deployment is a method that reduces downtime during application updates. By running two parallel environments—Blue and Green—you can switch traffic between them without disrupting the user experience. This is especially useful for microservices running on Kubernetes, where Istio plays a key role in managing and securing traffic.

Setting Up the Blue Deployment

The first step in implementing Blue/Green deployment is creating the “Blue” deployment. In Kubernetes, deployments are defined by YAML files that specify replicas, containers, and other configurations. Here is an example of the YAML for the Blue deployment:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nginx-1.10
spec:
  replicas: 2
  template:
    metadata:
      labels:
        name: nginx
        version: "1.10"
    spec:
      containers:
        - name: nginx
          image: nginx:1.10
          ports:
            - name: http
              containerPort: 80

Once you’ve saved this configuration as blue.yaml, deploy it with the following command:

kubectl apply -f blue.yaml

This creates a Deployment with two replicas running NGINX version 1.10.

Exposing the Blue Deployment with a Service

After creating the deployment, you need to expose it via a service. Kubernetes services allow you to decouple applications from the pods running them. Here’s an example of the service definition:

apiVersion: v1
kind: Service
metadata:
  name: nginx
  labels:
    run: nginx
spec:
  type: NodePort
  ports:
    - port: 8080
      targetPort: 80
      protocol: TCP
      name: http
    - port: 443
      protocol: TCP
      name: https
  selector:
    run: nginx
    version: "1.10"
  type: LoadBalancer

Apply this configuration with the command:

kubectl apply -f service.yaml

This creates a LoadBalancer that allows external access to the Blue deployment.

Creating the Green Deployment

Next, you can create the Green deployment, which typically runs a new version of the application. Here’s an example of the YAML for the Green deployment:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-1.11
spec:
  selector:
    matchLabels:
      run: nginx-1.11
  replicas: 2
  template:
    metadata:
      labels:
        run: nginx-1.11
    spec:
      containers:
        - name: nginx
          image: nginx:1.11
          ports:
            - name: http
              containerPort: 80

Deploy the Green version by running:

kubectl apply -f green.yaml

Updating the Service for the Green Deployment

To switch traffic from the Blue to the Green deployment, update the service selector in the service definition. Modify the version label to point to the Green deployment version, as shown below:

apiVersion: v1
kind: Service
metadata:
  name: nginx
  labels:
    run: nginx
spec:
  type: NodePort
  ports:
    - port: 8080
      targetPort: 80
      protocol: TCP
      name: http
    - port: 443
      protocol: TCP
      name: https
  selector:
    run: nginx
    version: "1.11"
  type: LoadBalancer

Apply the changes:

kubectl apply -f service.yaml

Configuring Traffic with Istio

To manage traffic between the Blue and Green deployments efficiently, Istio can be used to configure advanced routing. The key resources involved include the Gateway, DestinationRule, and VirtualService.

  1. Gateway: Defines the load balancer at the edge of the mesh. Example: apiVersion: networking.istio.io/v1alpha3 kind: Gateway metadata: name: app-gateway spec: selector: istio: ingressgateway servers: - port: number: 80 name: http protocol: HTTP hosts: - "*"
  2. DestinationRule: Specifies policies for traffic after routing occurs. Example: apiVersion: networking.istio.io/v1alpha3 kind: DestinationRule metadata: name: myapp spec: host: myapp subsets: - name: v1 labels: version: v1 - name: v2 labels: version: v2
  3. VirtualService: Defines traffic routing rules and weights. Example: apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: myapp spec: hosts: - "*" gateways: - app-gateway http: - route: - destination: host: myapp subset: v1 weight: 50 - destination: host: myapp subset: v2 weight: 50

Combine these configurations into a single YAML file and apply it with:

kubectl apply -f app-gateway.yaml

Verifying the Deployment

Once the Blue/Green deployment and Istio configurations are in place, you can access the service and verify that traffic is evenly distributed between the Blue and Green versions. If you’re using Minikube with NodePort, get the ingress host and port as follows:

export INGRESS_HOST=$(minikube ip)
export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].nodePort}')

By accessing the service in your browser, you should see the traffic split between the two versions, ensuring smooth updates.

Why ZippyOPS Can Help

At ZippyOPS, we offer a comprehensive suite of services tailored to help businesses implement DevOps, DevSecOps, and other cloud-native strategies. Our expertise spans across automated operations, microservices, infrastructure management, and security—ideal for optimizing Kubernetes deployments like Blue/Green. If you’re looking for guidance or need assistance in setting up your infrastructure, contact ZippyOPS for professional consulting, implementation, and managed services.

Conclusion: Achieve Seamless Blue/Green Deployment on Kubernetes with Istio

Blue/Green deployments, when combined with Istio’s traffic management capabilities, provide a robust and reliable solution for updating applications in Kubernetes. This strategy minimizes downtime, ensures high availability, and improves the overall user experience. By integrating Istio, ZippyOPS can help you optimize these deployments while enhancing security and performance.

For more insights on advanced cloud-native solutions like AIOps, MLOps, and automated operations, check out our products and services.

Ready to get started? Contact us at sales@zippyops.com for a tailored consultation!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top