Argocd and Yaml

In the world of Kubernetes, automation and consistency are crucial. Managing dozens — or even hundreds — of microservices across multiple environments can become complex and error-prone. That’s where Argo CD and YAML come in. Together, they form the backbone of a GitOps-driven deployment strategy.

This blog will walk you through how Argo CD and YAML work together, why they’re powerful when combined, and how you can get started deploying your Kubernetes applications with confidence.

What is Argo CD?

Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes. It allows you to define your application’s desired state in a Git repository, and it ensures that the live state in your cluster

Key Features:

  • Git as the single source of truth
  • Continuous sync of applications
  • Real-time status monitoring
  • Multi-cluster support
  • Web UI, CLI, and REST API

Why YAML?

YAML (YAML Ain’t Markup Language) is the human-readable data format used to define Kubernetes resources — including Deployments, Services, ConfigMaps, Ingress, and more. It is also used to define Argo CD’s Application resources.

YAML is:

  • Declarative: You specify what you want, not how to get it
  • Version-controlled: Ideal for GitOps
  • Portable: Works across environments and clusters
  • Extensible: Supports Helm, Kustomize, Jsonnet, and more

How Argo CD Uses YAML

With Argo CD, you define applications using Kubernetes manifests written in YAML. These manifests can be raw Kubernetes files or templates generated using Helm, Kustomize, etc. Argo CD watches these YAML files in your Git repository and applies them to your cluster.

ArgoCD Installed: Ensure you have ArgoCD installed and configured on your Kubernetes cluster, you can install argocd using the below commands.

$ kubectl create namespace argocd
$ kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

2. Git Repository: Have your application’s source code and deployment configuration (YAML files) in a Git repository.

Example: application.yaml

apiVersion: argoproj.io/v1alpha1

kind: Application

metadata:

name: my-app

namespace: argocd

spec:

project: default

source:

repoURL: https://github.com/my-org/k8s-configs

targetRevision: main

path: apps/my-app

destination:

server: https://kubernetes.default.svc

namespace: my-namespace

syncPolicy:

automated:

prune: true

selfHeal: true

Now, let’s break down this YAML file to understand what each section does:

metadata: Here, you provide a name for your ArgoCD application. In this case, it’s named myapp.

destination: This section specifies where your application will be deployed. You define the Kubernetes namespace and server URL. In this example, we’re deploying to the apps namespace and using the default Kubernetes server.

source: This section provides details about the source code repository for your application. Specify the path to your application’s code within the repository, the repository’s URL, and the target Git revision (in this case, master). Additionally, it mentions that you’re using Helm for deploying the application, and you specify any Helm values files to include.

project: You can categorize your applications into projects for better organization. In this example, the application is assigned to the dev-projects project.

syncPolicy: This section defines how the synchronization of the application should be handled. In this case, it’s set to automated, and we’ve configured it not to prune resources (prune: false) and to enable self-healing (selfHeal: true).

Git structure:

my-org-k8s-repo/

├── apps/

│ └── my-app/

│ ├── deployment.yaml

│ ├── service.yaml

│ └── configmap.yaml

└── argocd/

└── application.yaml

Deployment Steps

1.Save the above YAML file to a location on your local machine.

2.Use the kubectl apply command to create the ArgoCD Application and deploy it into argocd namespace.

$ kubectl apply -f app.yaml -n argocd

Benefits of Using Argo CD with YAML

Gitops Blog

FeatureBenefit
Declarative ConfigurationEverything is written as code and stored in Git
TraceabilityYou always know who changed what, when, and why
AutomationNo need to manually run deployment scripts
Tooling SupportWorks with Helm, Customize, Json net, plain YAML
Safe RollbacksGit history lets you revert anytime
ObservabilityArgo cd provides a live view of your app health and sync state

Conclusion

Using Argo CD with YAML gives you a powerful, declarative, and automated way to deploy applications on Kubernetes. It simplifies operations, improves reliability, and embraces Git as the single source of truth. Whether you’re managing a single microservice or an entire fleet of applications, this combo helps you deliver software the GitOps way — fast, safe, and scalable.

Mahesh Wabale
Latest posts by Mahesh Wabale (see all)

Leave a Comment