Create Argo CD Application¶
An ArgoCD application is a Kubernetes Custom Resource Definition (CRD) used to define and manage the deployment of an application to a Kubernetes cluster.
An ArgoCD application resource defines the source repository, the target Kubernetes namespace, and the synchronization options, among other things.
You can create Argo CD application from the Argo CD UI or declaratively using the YAML file.
We'll set it up declaratively.
Step 1: Prepare Kubernetes Manifest Files¶
Create a private git repo and add manifest files. I'll name the git repo kubernetes-manifests (You can name anything you want). In that repository I'll create a folder for node app called node-app.
Here's how the folder structure looks like:
Step 2: Create Argo CD Application¶
Now that we have our kubernetes manifest files ready, let's create Argo CD application.
Apply the manifest to create the Argo CD application:
The application will be deployed but it will have an error since our repo is private. We need to configure argo cd to access git repo.
Credentials can be configured using Argo CD CLI:
argocd repo add https://github.com/argoproj/argocd-example-apps --username <username> --password <password>
Or you can use the UI. Navigate to Settings/Repositories
and Click Connect Repo using HTTPS
button and enter credentials.
Click Connect
to test the connection and have the repository added.
You can also set up credentials to serve as templates for connecting repositories, without having to repeat credential configuration. For example, if you setup credential templates for the URL prefix https://github.com/argoproj
, these credentials will be used for all repositories with this URL as prefix (e.g. https://github.com/argoproj/argocd-example-apps
) that do not have their own credentials configured.
To set up a credential template
using the Web UI, simply fill in all relevant credential information in the Connect repo using SSH or Connect repo using HTTPS dialogues (as described above), but select Save as credential template instead of Connect to save the credential template. Be sure to only enter the prefix URL (i.e. https://github.com/argoproj
) instead of the complete repository URL (i.e. https://github.com/argoproj/argocd-example-apps
) in the field Repository URL
Argo CD Application for Helm¶
What if your kubernetes objects are defined as helm charts? How do you write Argo CD application for that?
Here's an example:
Here we have defined the repo, branch, path in the repo and which file to consider for helm values.
References: