In this guide, we demonstrate how to set up Kubernetes resources declaratively using a Mono application example. Declarative management involves defining Kubernetes resources (such as Deployments, Services, Secrets, and ConfigMaps) and ArgoCD objects (including Applications, Repositories, and Projects) in manifest files. These files can be applied with the kubectl CLI to ensure your desired state is maintained. Previously, we created ArgoCD applications using the CLI and UI, providing the source and destination interactively. In contrast, this approach leverages declarative manifests to define and manage these applications systematically.Documentation Index
Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
Use this file to discover all available pages before exploring further.
Defining your infrastructure as code in Git offers clear traceability, version control, and simplifies management of changes across different environments.
Git Repository Structure
Assume that you have a Git repository with the structure below. The repository contains a directory called “declarative” with two subdirectories: “manifests” and “mono-app”.- Project Name: The project within ArgoCD.
- Source Configuration: Includes the Git repository URL, the revision (e.g., HEAD), and the path pointing to the desired Kubernetes manifests (i.e., the “geocentric-model” directory inside “declarative/manifests”). This directory contains two YAML files: one for the Deployment and one for the Service.
- Destination Configuration: Specifies the target cluster (using the in-cluster URL) and the namespace where resources will be deployed.
- Sync Policy: An optional policy that can automate the synchronization and self-healing process.
Creating the Application
Once you have defined your manifest, create the application by running the following command:By managing both your application definition and its corresponding resources in source control, you can easily track changes and maintain a consistent state across your environments.