{"id":398,"date":"2024-02-27T10:00:00","date_gmt":"2024-02-27T10:00:00","guid":{"rendered":"https:\/\/blog.ngocha.biz\/?p=398"},"modified":"2024-02-27T10:00:00","modified_gmt":"2024-02-27T10:00:00","slug":"argo-rollouts-setup-on-kubernetes","status":"publish","type":"post","link":"https:\/\/blog.ngocha.biz\/?p=398","title":{"rendered":"Easy Argo Rollouts Setup on Kubernetes: Complete Guide"},"content":{"rendered":"<p>In this blog, we are going to learn about how to set up Argo Rollouts and how we can deploy applications using it on Kubernetes.<\/p>\n<p>Argo Rollouts is an open-source Kubernetes tool that can be used with or without Argo CD, its role is to help you to perform various advanced deployment strategies like blue-green and canary deployment.<\/p>\n<p>Kubernetes has its own native rolling update strategies but with many limitations such as you cannot fully control the speed of the rollout, cannot control the traffic flow to the new version, etc.<\/p>\n<p>With Argo Rollouts you can do deployments without any limitations.<\/p>\n<h2 id=\"argo-rollouts-workflow\">Argo Rollouts Workflow<\/h2>\n<p>The diagram given below shows the simple workflow of Argo Rollouts, which uses Ingress Controller, Argo CD for visualizing, and Prometheus for monitoring.<\/p>\n<figure class=\"kg-card kg-image-card kg-card-hascaption\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/argo-rollouts-1.gif\" class=\"kg-image\" alt=\"Argo Rollouts Workflow\" loading=\"lazy\" width=\"800\" height=\"1040\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/argo-rollouts-1.gif 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/argo-rollouts-1.gif 800w\" sizes=\"auto, (min-width: 720px) 720px\"><figcaption><span style=\"white-space: pre-wrap;\">Click to View in HD<\/span><\/figcaption><\/figure>\n<p>Let me explain the image<\/p>\n<ol>\n<li>This workflow uses Argo Rollouts with Argo CD.<\/li>\n<li>As shown in the diagram an application is already running, to start the rollout you change the image and update the changes using the manifest file.<\/li>\n<li>As soon as you update the changes Argo Rollouts deploy the new version along with the old version.<\/li>\n<li>Then the traffic will gradually shift from the old to the new version with a time gap as you specified on the manifest file.<\/li>\n<li>Argo Rollouts uses an Ingress Controller to route the traffic to old and new versions.<\/li>\n<li>And the metrics created during the rollout process are scraped and sent to Prometheus.<\/li>\n<\/ol>\n<h2 id=\"install-argo-rollouts\">Install Argo Rollouts<\/h2>\n<p>Given below are the prerequisites for the setup<\/p>\n<h3 id=\"prerequisites\">Prerequisites<\/h3>\n<ol>\n<li>A working <a href=\"https:\/\/devopscube.com\/setup-kubernetes-cluster-kubeadm\/\">Kubernetes Cluster<\/a><\/li>\n<li><a href=\"https:\/\/devopscube.com\/kubectl-set-context\/\" rel=\"noreferrer\">Kubectl<\/a> is configured with the cluster.<\/li>\n<\/ol>\n<p>Follow the below steps to install Argo Rollouts on <a href=\"https:\/\/devopscube.com\/kubernetes-tutorials-beginners\/\">Kubernetes<\/a>.<\/p>\n<h3 id=\"step-1-create-namespace\">Step 1: Create Namespace<\/h3>\n<p>Create a separate namespace for Argo Rollouts using the following command<\/p>\n<pre><code>kubectl create namespace argo-rollouts<\/code><\/pre>\n<h3 id=\"step-2-install-argo-rollouts\">Step 2: Install Argo Rollouts<\/h3>\n<p>Now, run the following command to install Argo Rollouts on the <strong>argo-rollouts<\/strong> namespace you created in the previous step.<\/p>\n<pre><code>kubectl apply -n argo-rollouts -f https:\/\/raw.githubusercontent.com\/argoproj\/argo-rollouts\/stable\/manifests\/install.yaml<\/code><\/pre>\n<p>This command will install the latest stable version of Argo Rollouts on the <strong>argo-rollouts<\/strong> namespace.<\/p>\n<h3 id=\"step-3-install-the-argo-rollouts-kubectl-plugin\">Step 3: Install the Argo Rollouts Kubectl Plugin<\/h3>\n<p>The use of the Argo Rollouts kubectl plugin is to manage and visualize rollouts from the CLI.<\/p>\n<div class=\"kg-card kg-callout-card kg-callout-card-blue\">\n<div class=\"kg-callout-emoji\">\u26a0\ufe0f<\/div>\n<div class=\"kg-callout-text\"><b><strong style=\"white-space: pre-wrap;\">Note:<\/strong><\/b> The below command is for MAC users, if you are a Linux user use <a href=\"https:\/\/github.com\/argoproj\/argo-rollouts\/releases?ref=devopscube.com\">Linux<\/a> instead of Darwin in the below commands.<\/div>\n<\/div>\n<p>First, download the latest Argo Rollouts using the command<\/p>\n<pre><code>curl -LO https:\/\/github.com\/argoproj\/argo-rollouts\/releases\/latest\/download\/kubectl-argo-rollouts-darwin-amd64<\/code><\/pre>\n<p>Make the binary of the Argo Rollouts Kubectl plugin executable with the command<\/p>\n<pre><code>chmod +x .\/kubectl-argo-rollouts-darwin-amd64<\/code><\/pre>\n<p>Move the binary to \/usr\/local\/bin\/ directory using the following command<\/p>\n<pre><code>sudo mv .\/kubectl-argo-rollouts-darwin-amd64 \/usr\/local\/bin\/kubectl-argo-rollouts<\/code><\/pre>\n<p>Check the version and see if it installed properly using the command<\/p>\n<pre><code>kubectl argo rollouts version<\/code><\/pre>\n<p>You will get the following output<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-65-8.png\" class=\"kg-image\" alt=\"checking argo rollouts version\" loading=\"lazy\" width=\"733\" height=\"339\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-65-8.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-65-8.png 733w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>Now, that you have installed Argo Rollouts and Kubectl Plugin, let&#8217;s see how to deploy an application using Argo Rollouts.<\/p>\n<h2 id=\"deploy-applications-using-argo-rollouts\">Deploy Applications Using Argo Rollouts<\/h2>\n<p>As an example, I am going to <strong>deploy Nginx using Argo Rollouts <\/strong>and check how the rollout works by changing the version of the Nginx deployment.<\/p>\n<h3 id=\"step-1-deploy-the-application\">Step 1: Deploy the Application<\/h3>\n<p>First, create a YAML file <strong>nginx-rollouts.yaml<\/strong> and copy the below contents. Here we use the Rollout custom resource.<\/p>\n<pre><code>apiVersion: argoproj.io\/v1alpha1\nkind: Rollout\nmetadata:\n  name: nginx-rollout\n  namespace: default\nspec:\n  replicas: 3\n  selector:\n    matchLabels:\n      app: nginx\n  template:\n    metadata:\n      labels:\n        app: nginx\n    spec:\n      containers:\n      - name: nginx-container\n        image: nginx:1.24-alpine\n        ports:\n        - containerPort: 80\n  strategy:\n    canary:\n      steps:\n      - setWeight: 20\n      - pause: {duration: 10}\n      - setWeight: 50\n      - pause: {duration: 10}\n      - setWeight: 70\n      - pause: {duration: 10}\n      - setWeight: 100<\/code><\/pre>\n<p>As you can see in the above file, t deploys the <strong>nginx version 1.24-alpine<\/strong> which is an older version of nginx with 3 replicas, and exposes the container to port 80.<\/p>\n<pre><code>  strategy:\n    canary:\n      steps:\n      - setWeight: 20\n      - pause: {duration: 10}\n      - setWeight: 50\n      - pause: {duration: 10}\n      - setWeight: 70\n      - pause: {duration: 10}\n      - setWeight: 100<\/code><\/pre>\n<p>This part of the file specifies the strategy it&#8217;s going to use for rollout and the steps in which manner the <strong>traffic is distributed<\/strong> with the older and the new version.<\/p>\n<p>The deployment strategy I am going to use in <strong>Canary<\/strong> deployment, and the steps say how traffic should be distributed from the older version to the newer version during rollout.<\/p>\n<p>Here is what it says, during the rollout, <strong>initially send 20% of traffic<\/strong> to the newer version and <strong>80% of traffic<\/strong> to the older version.<\/p>\n<p>Then it passes the rollout for ten seconds to observe the performance of the newer version, after 10 seconds 50% of the traffic will be sent to the newer version and the rollout happens until 100% of the traffic is sent to the newer version.<\/p>\n<p>Now, run the following command to deploy the application<\/p>\n<pre><code>kubectl apply -f nginx-rollouts.yaml<\/code><\/pre>\n<p>Check the deployment, if it&#8217;s running and healthy. This is where the Argo Rollouts kubectl plugin plays its role in visualizing the deployment.<\/p>\n<p>Run the following command to visualize the deployment using the plugin<\/p>\n<pre><code>kubectl argo rollouts get rollout nginx-rollout --watch<\/code><\/pre>\n<p>You will get the following output<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-71-4.png\" class=\"kg-image\" alt=\"view argo rollouts deployment\" loading=\"lazy\" width=\"951\" height=\"674\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-71-4.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-71-4.png 951w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<h3 id=\"step-2-rollout-a-new-version\">Step 2: Rollout a New version<\/h3>\n<p>To rollout a new version make changes on the deployment <strong>nginx-rollouts.yaml<\/strong> file and run the apply command again to rollout the new version.<\/p>\n<p>I am going to change the version of the nginx image to the latest image and apply the changes as given below<\/p>\n<pre><code>    spec:\n      containers:\n      - name: nginx-container\n        image: nginx:latest\n        ports:\n        - containerPort: 80<\/code><\/pre>\n<p>Now, run the following apply command to start the rollout<\/p>\n<pre><code>kubectl apply -f nginx-rollouts.yaml<\/code><\/pre>\n<p>You can see the visual rollout process using the command<\/p>\n<pre><code>kubectl argo rollouts get rollout nginx-rollout --watch<\/code><\/pre>\n<p>You can see the traffic shift from the older version to the newer version with a 10 sec gap as we set in the deployment file, you can set the time duration as long as you want for better observation.<\/p>\n<p>You can see how the rollout is done in the below images.<\/p>\n<p><strong>20%<\/strong> traffic to the newer version and <strong>80%<\/strong> traffic to the older version.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-67-7.png\" class=\"kg-image\" alt=\"Argo rollouts: 20% traffic to the newer version and 80% traffic to the older version.\" loading=\"lazy\" width=\"893\" height=\"413\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-67-7.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-67-7.png 893w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p><strong>50%<\/strong> traffic to the newer version and <strong>50%<\/strong> traffic to the older version.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-68-4.png\" class=\"kg-image\" alt=\"Argo rollouts: 50% traffic to the newer version and 50% traffic to the older version.\" loading=\"lazy\" width=\"893\" height=\"413\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-68-4.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-68-4.png 893w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p><strong>70%<\/strong> traffic is to the newer version and <strong>30%<\/strong> traffic is to the older version.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-69-4.png\" class=\"kg-image\" alt=\"Argo rollouts: 70% traffic to the newer version and 30% traffic to the older version.\" loading=\"lazy\" width=\"893\" height=\"394\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-69-4.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-69-4.png 893w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>If everything is stable on the newer version <strong>100%<\/strong> of traffic will be sent to the newer version<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-70-3.png\" class=\"kg-image\" alt=\"Argo rollouts: older version scales down and new version get 100% traffic\" loading=\"lazy\" width=\"893\" height=\"394\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-70-3.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-70-3.png 893w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>Also, if the newer version is healthy and running properly and you don&#8217;t want to wait until the rollout process, run the following promote command to direct all the traffic to the newer version immediately.<\/p>\n<pre><code>kubectl argo rollouts promote nginx-rollout<\/code><\/pre>\n<p>And if the newer version is not healthy and is not running properly, you can use the abort command to stop the rollout, which will terminate the newer version rollout and direct all the traffic to the older stable version.<\/p>\n<pre><code>kubectl argo rollouts abort nginx-rollout<\/code><\/pre>\n<p>You can also get the Argo Rollout dashboard of the rollout process in the UI using the command given below<\/p>\n<pre><code>kubectl argo rollouts dashboard<\/code><\/pre>\n<p>Now, view the dashboard on the browser using <strong>localhost:3100<\/strong>, you will get the following page<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-72-6.png\" class=\"kg-image\" alt=\"argo rollouts dashbroad\" loading=\"lazy\" width=\"676\" height=\"443\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-72-6.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-72-6.png 676w\"><\/figure>\n<p>Open it and view the rollout process in detail as shown below<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-73-5.png\" class=\"kg-image\" alt=\"view deployment on argo rollouts dashoboard\" loading=\"lazy\" width=\"1379\" height=\"750\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-73-5.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/03\/image-73-5.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-73-5.png 1379w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>You can modify the manifest file for better deployments like, automatically rolling back to the previous version if the new version is not stable or unhealthy, or add health checks to deployment to increase the traffic if the new deployment is healthy.<\/p>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>I believe you understand the steps in this blog to install Argo Rollouts, the Kubectl plugin, and rollout new versions or updates of an application using the Canary strategy.<\/p>\n<p>Also, here is the study guide for <a href=\"https:\/\/devopscube.com\/certified-argo-project-associate\/\">Certified Argo Project Associate (CAPA)<\/a>.<\/p>\n<hr>\n<p><strong>Ngu\u1ed3n:<\/strong> <a href=\"https:\/\/devopscube.com\/argo-rollouts-setup-on-kubernetes\/\" target=\"_blank\" rel=\"noopener noreferrer\">Easy Argo Rollouts Setup on Kubernetes: Complete Guide \u2014 DevOpsCube<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Source: https:\/\/devopscube.com\/argo-rollouts-setup-on-kubernetes\/<\/p>\n","protected":false},"author":1,"featured_media":399,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-398","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops"],"_links":{"self":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/398","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=398"}],"version-history":[{"count":0,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/398\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/media\/399"}],"wp:attachment":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=398"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=398"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=398"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}