A Rollout is a type of Kubernetes workload resource that functions similarly to a Kubernetes Deployment object. It is designed to replace a Deployment in situations where more sophisticated deployment or progressive delivery capabilities are required. A Rollout offers several features that a standard Kubernetes Deployment does not provide:
Blue-green deployment is a technique that reduces downtime and risk by running two identical production environments, referred to as Blue and Green. One environment (e.g., Blue) is live and serving all production traffic, while the other (Green) is idle. During an update, the new version of the application is deployed to the idle environment (Green). Once the deployment is successful and validated, traffic is switched from the live environment (Blue) to the new environment (Green). This allows for seamless transitions and easy rollbacks if necessary.
In the context of Argo Rollouts, blue-green deployment is managed by defining a strategy in a Rollout resource. Here’s how it works step-by-step:
activeService
): The Kubernetes Service that routes traffic to the active environment (Blue or Green).previewService
): The Kubernetes Service that points to the new environment (Green) during the deployment process.autoPromotionEnabled
): Controls whether the new version is automatically promoted to the active environment once deployed. If set to false
, manual intervention is required to switch traffic to the new environment.autoPromotionEnabled
is true
) switch the Active Service to the new ReplicaSet, effectively routing all traffic to the new version.Using Argo Rollouts for blue-green deployments provides a controlled and manageable way to deploy updates with minimal downtime and risk, ensuring a smooth transition between application versions.
helm repo add argo https://argoproj.github.io/argo-helm
helm repo update
dashboard:
# -- Deploy dashboard server
enabled: true
# -- Set cluster role to readonly
readonly: true
# -- Value of label `app.kubernetes.io/component`
component: rollouts-dashboard
ingress:
enabled: true
annotations: {}
labels: {}
ingressClassName: "nginx"
hosts:
- ARGO-DASHBOARD-SUB-DOMAIN # Replace with your domain
helm install argo-rollouts -n argo-rollouts argo/argo-rollouts -f values.yaml
curl -LO https://github.com/argoproj/argo-rollouts/releases/latest/download/kubectl-argo-rollouts-linux-amd64
chmod +x ./kubectl-argo-rollouts-linux-amd64
sudo mv ./kubectl-argo-rollouts-linux-amd64 /usr/local/bin/kubectl-argo-rollouts
kubectl argo rollouts version
We will Install sample application(Rollout, Service, Ingress) and through that we will understand how Blue Green Deployment actually works.
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: my-app
namespace: default
spec:
replicas: 5
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-app-container
image: argoproj/rollouts-demo:blue
ports:
- containerPort: 80
strategy:
blueGreen:
activeService: my-app
previewService: my-app-preview
autoPromotionEnabled: true
apiVersion: v1
kind: Service
metadata:
name: my-app
namespace: default
spec:
selector:
app: my-app
ports:
- port: 80
targetPort: 80
type: ClusterIP
---
apiVersion: v1
kind: Service
metadata:
name: my-app-preview
namespace: default
spec:
selector:
app: my-app
ports:
- port: 80
targetPort: 80
type: ClusterIP
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-app-ingress
namespace: default
annotations:
kubernetes.io/ingress.class: nginx
spec:
ingressClassName: nginx
rules:
- host: example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: my-app
port:
number: 80
kubectl apply -f rollout.yaml
kubectl apply -f service.yaml
kubectl apply -f ingress.yaml
kubectl argo rollouts get rollout my-app
kubectl argo rollouts set image my-app my-app-container=argoproj/rollouts-demo:green
my-app
service while new (Green) version on my-app-preview
service, we can easily start using new(Green) version on my-app
service by Promoting it using argo rollouts cli.
kubectl argo rollouts promote my-app
After installing and configuring Argo Rollouts, you will achieve:
Argo Rollouts provide a robust solution for managing Kubernetes deployments. By leveraging advanced deployment strategies like Blue-Green deployments, you can ensure higher availability and reliability for your applications. Follow the steps outlined in this blog to implement a Blue-Green deployment with Argo Rollouts, enhancing your deployment process and minimizing downtime.
Argo Rollouts is a powerful tool that, can significantly streamline your Kubernetes deployment workflows. Try it out and experience the benefits of advanced deployment strategies in your applications!