ArgoCD app of apps installation in Kubernetes with Helm
Learn to initiate your ArgoCD environment within Kubernetes using a helm chart and a straightforward bash script in this instructional post.
By creating a single Bash script, you will learn how to bootstrap and automate the creation of an ArgoCD instance in Kubernetes, along with the creation of the initial project, repository, and the main application in the app of apps pattern.
Prepare your repository
Create a repository on GitHub, GitLab or wherever you prefer. Generate a personal access token if you are using GitHub, or create a project access token if you are using GitLab. Save it somewhere safe, because you will need it for ArgoCD later.
Create the necessary directories and files like the example below. The repository structure should look like this:
|
|
You will populate the files with content later. For now, just make the init.sh
script executable so you don’t forget later:
|
|
The bootstrap
directory
This is where we are setting up the automated first time installation of ArgoCD. To do so, follow these steps and edit each file:
The argocd/bootstrap/manifests/application.yaml
manifest will configure the main application, paste this inside and replace with your own values:
|
|
The argocd/bootstrap/manifests/project.yaml
manifest will configure the project which will be used for the application, paste this inside and replace with your own values:
|
|
The argocd/bootstrap/values.yaml
file is for the custom Helm chart values. You can look at the available values here. We are setting up values for the following:
-
If you want to expose the ArgoCD UI with your ingress controller, the SSL termination must be done at the ingress controller level. That is why we are setting the
--insecure
flag for the server. If you don’t set this field, the UI will not open in a browser in any way other that port forwarding. -
We are also adding the health assessment of applications custom script to be able to use sync waves between applications. Read more here.
|
|
The argocd/bootstrap/init.sh
bash script will ask you for the repository URL and the access token. After that, it will install ArgoCD in your Kubernetes cluster with Helm, it will create the repository secret, and it will create the project and the application. Remember to replace anything you want with your own values here. Paste the script into your own init.sh
:
|
|
After this, you can now push the code to your repository after you have reviewed it.
Installing ArgoCD
To install ArgoCD, prepare the repository URL and the access token for when the script asks you to provide them, and run it:
|
|
After some time, it will deploy ArgoCD and set it up for you. The initial username is admin
. You can get the initial admin password with this command:
|
|
Now, if you have an ingress controller in place, you can create an ingress resource to expose the UI, or you can simple use port forwarding to access it on localhost
. Here is the command for port forwarding, and after it’s done, you can access it on the browser with http://localhost:8080
:
|
|
You can check the official docs to see examples of exposing the UI with various ingress controllers.
The apps
directory
This is where the children applications of the main application will be stored. For example, if you want to add an application, it will look like this:
|
|
And the apps/cert-manager/application.yaml
manifest will look like this:
|
|
If you find this post helpful, please consider supporting the blog. Your contributions help sustain the development and sharing of great content. Your support is greatly appreciated!
Buy Me a Coffee