Canary deployments are a popular method for testing new features and improvements in a production environment before they are rolled out to a wider audience. By deploying a new version of an application to a small subset of users, developers can monitor its performance and identify any issues before they affect the entire user base. In this article, we’ll show you how to set up a canary deployment using Argo Rollouts, an open-source Kubernetes-native tool for managing and deploying canary releases. We’ll walk you through the process of installing Argo Rollouts, creating a new deployment, and monitoring the performance of your canary release.
By the end of this article, you’ll have a solid understanding of how to use Argo Rollouts to deploy canary releases and how to use its built-in metrics and Prometheus integration to monitor the performance of your applications.
Setup EKS cluster
At first, we need to create a cluster in EKS by running the below command. For creating the cluster I will use eksctl. Here is the command
curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
sudo mv /tmp/eksctl /usr/local/bin
eksctl create cluster
The EKS cluster creation will take around 5-10 mins. Once the cluster is created then copy the cluster name and run the following command to update the “kubectl” with cluster information
aws eks update-kubeconfig --region {aws-region-name} --name {eks-cluster-name}
How to install Argo rollouts in EKS
Install the Argo Rollouts components on your EKS cluster by running the following command:
kubectl create namespace argo-rollouts
kubectl apply -n argo-rollouts -f https://github.com/argoproj/argo-rollouts/releases/latest/download/install.yaml
Verify that the Argo Rollouts components have been installed successfully by running the following command:
kubectl get pods -n argo-rollouts
This command should return a list of pods for the Argo Rollouts components that have been installed.
A sample Deployment
Create a rollout.yml file
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: atiq-notification-dev
spec:
replicas: 1
strategy:
canary:
steps:
- setWeight: 20
- pause: {duration: 100}
- setWeight: 40
- pause: {duration: 100}
- setWeight: 60
- pause: {duration: 100}
- setWeight: 80
- pause: {duration: 100}
- setWeight: 100
revisionHistoryLimit: 2
selector:
matchLabels:
app: atiq-notification-dev
template:
metadata:
labels:
app: atiq-notification-dev
spec:
containers:
- name: atiq-notification-containers
image: public-image-nginx
imagePullPolicy: Always
resources: {}
ports:
- containerPort: 5000
Then create a service.yml file
apiVersion: v1
kind: Service
metadata:
name: atiq-notification-dev-svc-argo
labels:
app: atiq-notification
# env: dev
spec:
selector:
app: atiq-notification-dev
# env: dev
type: NodePort
ports:
- protocol: TCP
port: 80
targetPort: 5000
Then create an nginx ingress
# Nginx Ingress Ctrl Resources for this ingress
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: atiq-notification-dev
annotations:
kubernetes.io/ingress.class: 'nginx'
nginx.ingress.kubernetes.io/rewrite-target: /$2
nginx.ingress.kubernetes.io/use-regex: 'true'
nginx.ingress.kubernetes.io/proxy-body-size: "50m"
spec:
rules:
- http:
paths:
- path: /atiq-notification-service(/|$)(.*)
pathType: Prefix
backend:
service:
name: atiq-notification-dev-svc-argo
port:
number: 80
In conclusion, Argo Rollouts is a powerful tool for managing and deploying canary releases on Kubernetes clusters. By following the steps outlined in this article, you can set up a canary deployment for your application in a matter of minutes. Argo Rollouts provides a simple and efficient way to manage the deployment of new versions of your application, and its built-in metrics and Prometheus integration make it easy to monitor the performance of your canary releases. With Argo Rollouts, you can be sure that your canary releases are being deployed safely and efficiently, allowing you to test new features and improvements before rolling them out to a wider audience.