Written by Parveen Kumar Patidar.
ArgoCD is a declarative, GitOps continuous delivery tool for Kubernetes. By tracking application definitions in a Git repository, ArgoCD enables version control, reproducibility, and automated deployment of your applications. Git is a single source of truth, ensuring that your clustersâ desired states are always represented accurately and consistently.
ArgoCD is a powerful tool for continuous delivery in Kubernetes environments. By integrating Helm, Helmfile, and Kubernetes manifests, you can create a robust and flexible system for managing your applications. This guide provides an end-to-end solution for setting up and managing ArgoCD applications, ensuring a streamlined and efficient deployment process.
Introduction
This blog will cover a comprehensive guide to demonstrate the ArgoCD âapp of appsâ model. We will also cover bootstrapping argoCD application, repository management and application creation in the ArgoCD supported with the help of a demo. The demo also supports a basic production-ready application architecture by having platform and workload applications separately defined. The architecture also supports multiple environments by using the Cluster names and corresponding values files. The ArgoCD applications support Helm remote, Helm local charts and plain Kubernetes manifest files. The blog also covers all three types of configurations.Â
The code is located here:Â GitOps-in-a-boxÂ
Here is documentation regarding ArgoCD Applications and ApplicationSets
NOTE: The blog does NOT cover any Kubernetes Cluster Creation. The Cluster should have at least one node ready for the ArgoCD to deploy.
Below is the architecture document representing the Applications and the ApplicationSetz (app of apps model). In the demo, we are categorising the platform apps, which mainly consist of applications managed by the platform team. This is followed by a Workload application that consists of workload-related applications.
Let's deep dive into the code repo and start setting up ArgoCD followed by the repositories -Â
Setup EnvironmentÂ
To start with the environment setup. Below are the toolset required -Â
Helmfile can also be run via Docker, Follow the readme file for more information on helmfile running on Docker -Â https://github.com/praveenkpatidar/GitOps-in-a-box/blob/main/README.md
Setup connection
As noted earlier, the Kubernetes cluster is supposed to be set up already.Â
Setup the kubectl context - https://kubernetes.io/docs/reference/kubectl/generated/kubectl_config/kubectl_config_set-context/
Export the system variable CLUSTER=<Name of Your Cluster>
Setting up ArgoCD
Go to argocd/argocd
folder
ArgoCD Config Prep
Here is
helmfile.yaml
to run -Â
---
repositories:
- name: argocd
url: https://argoproj.github.io/argo-helm
releases:
- name: argocd
chart: "argocd/argo-cd"
namespace: "argocd"
version: "7.3.4"
values:
- ./values/common.yaml
- ./values/{{ requiredEnv "CLUSTER" }}.yaml
- name: argocd-repos
namespace: argocd
chart: ./{{ requiredEnv "CLUSTER" }}
As you can see it needs CLUSTER variable to be set up before running.Â
Review the below files folders as per your clusterÂ
Change the name of folder mycluster > <Cluster Name>
Change the file name values/mycluster.yaml to values/<Cluster Name>.yaml
Update all the TODO values in the values/<Cluster Name>.yaml
ArgoCD Repositories Prep
The helmfile
consists of the second chart which is argocd-init
.Â
ArgoCD maintains the repository configuration using secret. The file <Cluster Name>/argocd-init.yaml
contains the repository and secret configuration that is used in the ApplicationSets later. The file consists of several repositories and credentials for the repo (considering the repos are private). Some of the key highlightsÂ
If the repos are public then there won't be any credentials required, thus the secrets can be managed in plain files inside source control.Â
Label Required - ââ
argocd.argoproj.io/secret-type: repository
If the reports are private, one secret is required with the base organisation URL. you can review the file that has required configuration templates. Two reports and one credential.Â
For credentials, you donât need to maintain them in each repo. Create one secret with the base repo URL. In general, itâs the URL of GitHub Organisation or Username. E.g. in the example code itâs https://github.com/praveenkpatidar
Label Required -
argocd.argoproj.io/secret-type: repo-creds
The final configuration is metadata of the âin-clusterâ secret. You can have as much as required metadata information here. All metadata can be read in the ApplicationSets later to diversify the deployments.Â
For demo, you can have GitOps-in-a-box repo and in-cluster secret configuration.
Running ArgoCD Helmfile
You are now all set to run the helmfile.yaml usingÂ
Export CLUSTER=<Cluster Name>; helmfile apply
Access ArgoCD UIÂ
Access ArgoCD UI by using port forwarding -Â
kubectl port-forward -n argocd svc/argocd-server 8080:80
Access URL: http://localhost:8080/