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
- Blue-green
- Canary
- with traffic management
- 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.
- Docker installed
- Terraform CLI installed
- Kubectl CLI installed
-
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)
-
Clone your forked repo
git clone https://github.com/<gh_username>/blue-green-canary-argocd-rollouts.git
-
Navigate to a folder
blue-green-canary-argocd-rollouts
cd blue-green-canary-argocd-rollouts
-
Replace value of
repoURL
of ArgoCD applications to your GitHub repositorymake replace-repourl URL=https://github.com/<gh_username>/blue-green-canary-argocd-rollouts.git
-
Commit and push these changes
-
Create an infrastructure based on
terraform/main.tf
make tf-apply
-
After some minutes (max 5) there will be running
- 1-node K8s cluster
- ArgoCD
- Argo Rollouts
- ingress-nginx
- Prometheus
- blue-green app
- canary app
-
After that when infrastructure is in place it automatically deploys all aplications from Helm Chart
argocd/apps
. These applications are Helm Charts, defined incharts/
folder -
See FAQ for more questions
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
-
two URLs:
- http://blue-green.local - stable version, considered like "production" version where production traffic goes to
- 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
-
two versions of simple blue-green app (presented by container images):
jakuboskera/blue-green:blue
- blue background colorjakuboskera/blue-green:green
- green background color
-
Check that
blue-green
application was deployed -
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
-
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)
-
Also when you visit http://blue-green-preview.local you will see a blue version, because this is a first deployment
-
If so, everything is correct and now you can deploy a new version of this app (with a green background color)
-
Go to your forked repository and open a file
argocd/apps/templates/blue-green.yaml
- If value of
.spec.source.helm.parameters[0].value
isblue
change itgreen
, ifgreen
change it toblue
- Commit these changes
- If value of
-
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.)
-
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 rolloutblue-green
-> Promote-Full -
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) -
(Optional) You can repeat steps 7-10 how many times you want, just interchange
blue
forgreen
andgreen
forblue
-
That was an example of a blue-green deployment strategy in Kubernetes using Argo Rollouts using GitOps principles
TODO
To destroy infrastructure based on terraform/main.tf
make tf-destroy
make argocd-get-password
To port-forward to ArgoCD, it will be available on http://localhost:8080
make argocd-port-forward
To port-forward to Prometheus, it will be available on http://localhost:8090
make prometheus-port-forward