Giter VIP home page Giter VIP logo

blue-green-canary-argocd-rollouts's Introduction

Blue-green and canary deployment strategy using ArgoCD and Argo Rollouts

This repository shows Argo Rollouts in action. Argo Rollouts is Kubernetes progressive delivery controller. It expands the possibilities of more complex Kubernetes deployment strategies, like deployments

  1. Blue-green
  2. Canary
    1. with traffic management
    2. with analysis

Examples of these two types of deployments are shown in this repository. See Get started.

Creation and management of a Kubernetes cluster on kind is done via Terraform and Argo CD.

๐Ÿ“– TOC

โš ๏ธ Prerequisites

  1. Docker installed
  2. Terraform CLI installed
  3. Kubectl CLI installed

๐Ÿ Get started

  1. Fork this repository (you need to have a fork of this repository in order to make some commits to simulate a deployment of a new versions of applications)

  2. Clone your forked repo

    git clone https://github.com/<gh_username>/blue-green-canary-argocd-rollouts.git
  3. Navigate to a folder blue-green-canary-argocd-rollouts

    cd blue-green-canary-argocd-rollouts
  4. Replace value of repoURL of ArgoCD applications to your GitHub repository

    make replace-repourl URL=https://github.com/<gh_username>/blue-green-canary-argocd-rollouts.git
  5. Commit and push these changes

๐Ÿš€ Create an infrastructure

  1. Create an infrastructure based on terraform/main.tf

    make tf-apply
  2. After some minutes (max 5) there will be running

    1. 1-node K8s cluster
    2. ArgoCD
    3. Argo Rollouts
    4. ingress-nginx
    5. Prometheus
    6. blue-green app
    7. canary app
  3. After that when infrastructure is in place it automatically deploys all aplications from Helm Chart argocd/apps. These applications are Helm Charts, defined in charts/ folder

  4. See FAQ for more questions

๐ŸŸฆ๐ŸŸฉ Simulate a blue-green deployment

As far as infrastructure is up and running you can use this procedure to simulate a blue-green deployment.

In this procedure we will have

  1. two URLs:

    1. http://blue-green.local - stable version, considered like "production" version where production traffic goes to
    2. http://blue-green-preview.local - preview version, considered like a potencionally new version of the application, but before going to production we have abillity to test it
  2. two versions of simple blue-green app (presented by container images):

    1. jakuboskera/blue-green:blue - blue background color
    2. jakuboskera/blue-green:green - green background color

Procedure

  1. Get initial admin password for ArgoCD and access ArgoCD UI

  2. Check that blue-green application was deployed

  3. Open your /etc/hosts file and add there these local DNS records, save that file

    # /etc/hosts
    
    127.0.0.1 blue-green.local # stable/active version
    127.0.0.1 blue-green-preview.local # preview version
  4. Try to visit http://blue-green.local, you should see a webpage with blue background color (wait for DNS, it could take some seconds to take an effect)

  5. Also when you visit http://blue-green-preview.local you will see a blue version, because this is a first deployment

  6. If so, everything is correct and now you can deploy a new version of this app (with a green background color)

  7. Go to your forked repository and open a file argocd/apps/templates/blue-green.yaml

    1. If value of .spec.source.helm.parameters[0].value is blue change it green, if green change it to blue
    2. Commit these changes
  8. Go back to ArgoCD UI and open the application blue-green, you will see that after some seconds App Health is now in Suspended state, which means that application on URL http://blue-green.local is still in blue version, but desired state (from git) is green version.

    Without Argo Rollouts, ArgoCD would normally sync the desired state and application would be now in green version. Hovewer here is where Argo Rollouts comes into play, because now you have a possibility to inspect a new version before it is switched to "production" and see if the new version is ok.

    To inspect the new green version before switching visit http://blue-green-preview.local.

    (If you don't see a green version it have not been probably sync yet, in this case go to ArgoCD UI and refresh a blue-green app.)

  9. As far as you are satisfied with a potential new version of the app you can click in ArgoCD UI -> application blue-green -> options (three dots) on rollout blue-green -> Promote-Full

  10. Now when you visit http://blue-green.local, you can see that a new version of blue-green application is in place (green background color)

  11. (Optional) You can repeat steps 7-10 how many times you want, just interchange blue for green and green for blue

  12. That was an example of a blue-green deployment strategy in Kubernetes using Argo Rollouts using GitOps principles

๐Ÿฆœ Simulate a canary deployment

TODO

๐Ÿงน Destroy an infrastructure

To destroy infrastructure based on terraform/main.tf

make tf-destroy

๐Ÿ™‹โ€โ™‚๏ธ FAQ

How to get initial argocd password for user admin

make argocd-get-password

How to access to ArgoCD

To port-forward to ArgoCD, it will be available on http://localhost:8080

make argocd-port-forward

How to access to Prometheus

To port-forward to Prometheus, it will be available on http://localhost:8090

make prometheus-port-forward

blue-green-canary-argocd-rollouts's People

Contributors

jakuboskera avatar jakuboskerarws avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.