How to use a declarative setup for Argo CD to deploy an application using a Helm repository?

In this blog post I will cover the topic, how to use Argo CD - Declarative Setup to deploy an application using Helm repository.

With the Declarative Setup we can automate:

  • The connection to a repository
  • The creation and configuration of a project
  • The creation and configuration of an application

This blog post is in the context of my last blog post How to deploy an application with Argo CD using a Helm repository. Please visit that blog post for more details, if needed.

The blog post is structured in following sections:

  1. Basic architectural overview
  2. Setup steps
  3. Summary

Note: You can access the source code related to this blog post in the GitHub project I created. The project is under Apache-2.0 license.

1. Basic architectural overview

The following diagram shows a simplified overview of the dependencies we are going to setup.

  1. As you see, we have an IBM Cloud in Red Hat OpenShift cluster with Argo CD installed.
  2. We have a GitHub project with a Helm Chart for the example application deployment in place.

The example application is a Node.js server application I used in several blog posts related to OpenShift.

Step 1: Connect to your OpenShift cluster

oc login --token=YOUR_TOKEN --server=https://YOUR_SERVER_URL

Step 2: Connect to a GitHub repository

For details, please visit Argo CD - Declarative Setup

1. Create a yaml file called repository.yaml

nano repository.yaml

2. Copy and past following content into that repository.yaml file

apiVersion: v1
kind: Secret
metadata:
  name: github.com-thomassuedbroecker-vend-helm
  namespace: openshift-gitops
  labels:
    argocd.argoproj.io/secret-type: repository
stringData:
  type: git
  url: https://github.com/thomassuedbroecker/vend-helm

3. Apply the repository.yaml

oc apply -f repository.yaml

4. Verify that ArgoCD is connected to that repository

Select Settings/Repositories in ArgoCD

Step 2: Create an ArgoCD project

For details, please visit Argo CD - Declarative Setup

1. Create a yaml file called project.yaml

nano project.yaml

2. Copy and past following content into that project.yaml file

apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
  name: vend-helm
  namespace: openshift-gitops
spec:
  clusterResourceWhitelist:
    - group: '*'
      kind: '*'
  description: This is just an example.
  destinations:
    - name: in-cluster
      namespace: vend
      server: 'https://kubernetes.default.svc'
  namespaceResourceWhitelist:
    - group: '*'
      kind: '*'
  sourceRepos:
    - 'https://github.com/thomassuedbroecker/vend-helm'
status: {}

3. Apply the project.yaml

oc apply -f project.yaml

4. Verify that ArgoCD created that project

Select Settings/Projects/vend-helm in ArgoCD

Step 3: Create an ArgoCD application

For details, please visit Argo CD - Declarative Setup

1. Create a yaml file called application.yaml

nano application.yaml

2. Copy and past following content into that application.yaml file

apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
  name: vend-helm
  namespace: openshift-gitops
spec:
  clusterResourceWhitelist:
    - group: '*'
      kind: '*'
  description: This is just an example.
  destinations:
    - name: in-cluster
      namespace: vend
      server: 'https://kubernetes.default.svc'
  namespaceResourceWhitelist:
    - group: '*'
      kind: '*'
  sourceRepos:
    - 'https://github.com/thomassuedbroecker/vend-helm'
status: {}

3. Apply the application.yaml

oc apply -f application.yaml

4. Verify that ArgoCD created that application

Select Applications/vend-helm in ArgoCD and ensure to pressed sync.

3. Summary

As we see, we could easily add our own application to Argo CD with the Declarative Setup for:

  • The connection to a repository
  • The creation and configuration of a project
  • The creation and configuration of an application

Let me summaries the content with three steps, we could say:

  • The environment we have in place
  • The configuration of Argo CD
  • The deployment of the application using Argo CD into the OpenShift cluster

1. The environment we have in place

  • IBM Cloud
    • VPC and OpenShift setup
  • OpenShift
    • ArgoCD installed
  • Existing GitHub Projects
    • Configuration for Argo CD
    • Deployment for example with Helm of a custom application

2. The configuration of Argo CD

a. Using the first GitHub repository to do the configuration in Argo CD.

  • Configure in Argo CD
    • Connect to repository
    • Create a project
    • Create an application

2. The configuration YAMLs for ArgoCD do contain the information how to connect and use the GitHub repository that contains the Helm chart of the custom application we are going to deploy to the OpenShift cluster.

3. The deployment of the application using Argo CD into the OpenShift cluster

Now the application will be deployed by the Argo CD configuration, we uploaded.

There is a pattern called app of apps pattern that makes sense. It shows how to use ArgoCD to deploy ArgoCD application configurations to deploy new applications to a cluster. That pattern could be a topic for a future blog posts.

This blog post is in the context of my last blog post How to deploy an application with Argo CD using a Helm repository. Please visit the blog post for more details, if needed.


I hope this was useful to you and let’s see what’s next?

Greetings,

Thomas

#ibmcloud, #softwareeverywhere, #iascable, #argocd, #openshift, #helm

One thought on “How to use a declarative setup for Argo CD to deploy an application using a Helm repository?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.