Argo CD: Deploying An App via YAML (Kubernetes)

Argo CD has options to deploy apps via a web GUI in a click ops fashion, but the same can be achieved using some YAML.

Argo CD Application YAML

The Argo CD application can be defined and applied via a YAML file, allowing for the configuration of apps to be saved in version control.

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: geek.app
namespace: argocd
spec:
project: default
destination:
namespace: default
name: in-cluster
source:
helm:
valueFiles:
- values.yaml
repoURL: https://github.com/geektechdude/helm-basic-chart
path: .
syncPolicy:
automated:
enabled: true

Saving this YAML as geekapp.yaml, it can then be applied via a kubectl apply:

 kubectl apply -f geekapp.yaml

The Argo CD app will then show in the Argo CD web GUI as normal.

Breaking Down The YAML

apiVersion: argoproj.io/v1alpha1
kind: Application

This is telling Kubernetes that an Application (kind:Application) is being created using the specifications of argoproj.io/v1alpha1.

metadata:
name: geek.app
namespace: argocd

This is the name of the application (geek.app) in Argo CD, and deploys the resource for the Argo CD application into the namespace Argo CD is running in (for me it’s a namespace called argocd).

spec:
project: default
destination:
namespace: default
name: in-cluster
source:
helm:
valueFiles:
- values.yaml
repoURL: https://github.com/geektechdude/helm-basic-chart
path: .
syncPolicy:
automated:
enabled: true

The specifications of the application and where the applications resources (pods, load balancer) should be deployed to. I’m deploying the resources to the default namespace of my Kubernetes cluster (namespace: default) and that is the cluster I have Argo CD deployed on (name: in-cluster).

My repository contains a value file called “values.yaml” that contains values I want to use with the deployment, so the “source > helm > valueFiles” tells Argo CD about the file.

repoURL is the location of the repository containing the Helm chart with the deployment resource details within, and the path (“.”) is saying where in the repository the chart it.

syncPolicy > automated is true which is telling Argo CD to automatically sync with the repository and make changes when detected in the repository.

Leave a comment

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

Welcome to GeekTechStuff

My home away from home and where I will be sharing my adventures in the world of technology and all things geek.

The technology subjects have varied over the years from Python code to handle ciphers and Pig Latin, to IoT sensors in Azure and Python handling Bluetooth, to Ansible and Terraform and material around DevOps.

Let’s connect