Application Resource in Argo CD

Application Resource 

I hope you remember this question in the previous blog: "But how does the Argo CD operator know about the source and destination? ".
These all are declared in a custom resource definition(CRD) called Application. It has a source field, a destination field, and many more fields.
In order to differentiate b/w source and destination, simply ask this question:
  • For Source: From where to fetch/pull the manifest or configuration files??
  • For Destination: And where to deploy these manifests or configuration files??

So, the Argo CD operator i.e. application controller uses application resources to achieve the desired state in the cluster with the help of the reconciliation concept. Let's understand the terminologies used in the Application.

Argo CD Concepts and Terminologies ??

Terminologies to be used while writing an application resource:

The application has 3 main components:
  • Destination:
    • This refers to clusters to which manifest to be deployed or the place where manifest are applied.
  • Project:
    • It is used to create specific restrictions.
    • For example: this application should only deploy resources to a cluster and specific namespace.
  • Source Repository
    • This refers to the place where the desired state is stored in Git.
    • All manifests that are required to run an app are placed here.

How the Application manifests looks like:
    
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: geocentric-model-app
namespace: argocd
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
project: default

source:
repoURL: https://github.com/viveksahu26/gitops-argocd.git
targetRevision: HEAD
path: ./declarative/manifests/geocentric-model
destination:
server: https://kubernetes.default.svc
namespace: geocentric-model

syncPolicy:
syncOptions:
- CreateNamespace=true
automated:
prune: true
selfHeal: true


Terminologies to be used after deploying an application:

Sync:
  • The process of moving the live state of a cluster towards the desired state.
  • Example: applying changes to the k8s cluster by picking up updated manifest from git.
  • The default time for syncing is 3 minutes. Every 3 minutes ArgoCD(GitOps operator) reconciles to check the git repo for the desired state and apply it to the cluster. 
Sync Status:
  • It tells about the status of whether the manifest present in the cluster is synced with the manifest present in the Git.
  • Is the deployed application the same as Git says it should be?
  • Types of Synced Status:
    • Synced
    • SyncFailed
    • Pruned
    • PruneSkipped
Refresh:
  • This refresh button compares the latest code in Git with the live state. It figures out what is different. In case it is different, it tells the sync status "not-synced". And suggest manually syncing by clicking on the sync button.
  • By default, reconciliation loops run every 3 minutes which compares the latest code in it. And if it finds a difference, then it automatically syncs it. And the refresh button is an alternative to it.
Health:
  • After deploying the application, you are eager to know the health of your app, whether it is running or not. It is used to tell the health status of your app. 
  • For example:
  • The health of an application, is it running correctly?
    • Can it serve requests?
Types of Health status:
  • Healthy
    • All resources are 100% healthy
  • Progressing
    • Resources are unhealthy, but could still be healthy in a given time.
  • Degraded
    • It indicates a failure or an inability to reach a healthy state in a timely manner.
  • Missing
    • Resources are not present in the cluster.
  • Suspended
    • Resources are suspended or paused. A typical example is a paused deployment.
  • Unknown
    • Health assessment failed and actual health status is unknown.
    • Later we will also understand how to write custom health checks for your application to ensure the health of an app. It uses the Lua programming language to write custom health checks.

Some other terminologies used in Argo CD are:

Application Source Types:
  • Tools that are used to build the applications. For Example: Helm, Customize, YAML, or ksonnet.
Project:
  • It projects a logical grouping of an application which is useful when Argo CD is used by multiple teams.
Target State:
  • The desired state of an application is represented by files in a git repository.
  • Also known as desired state.
Live State:
  • The live state of an application manifest such as pods, config map, secrets, etc present in the Kubernetes cluster.
  • Also known as current state.

What are the ways to create an application ??

There are 3 ways to create an application:
  • CLI
  • Argo CD Web UI
  • Manifest (i.e. Declarative approach).
We will perform these practicals when we learn more about the application in detail.

Now will have some hands-on to create an application.

1. Using CLI

$ argocd app create demo-app  --repo https://github.com/viveksahu26/gitops-argocd.git  --path ./nginx-app  --dest-namespace demo   --dest-server https://kubernetes.default.svc

$ argocd app list
$ argocd app sync demo-app

2. Using Argo CD Web UI

  1. Login to Argo CD UI.
  2. Click on + New App.
  3. Enter "demo-app" in the Application Name.
  4. Enter "default" in Project Name.
  5. Enter "Manual" in SYNC POLICY.
  6. Select "AUTO_CREATE_NAMESPACE" under SYNC OPTIONS.
  7. Enter "https://github.com/viveksahu26/gitops-argocd.git" in the Repository URL.
  8. Enter "./nginx-app" in Path.
  9. Enter "https://kuberentes.default.svc" in the Cluster URL.
  10. Enter "demo" in Namespace.
  11. Finally, click on CREATE.
  12. Now click on the Sync button.

3. Manifest: Using Declarative form:


apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: demo-app
namespace: argocd
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
project: default

source:
repoURL: https://github.com/viveksahu26/gitops-argocd.git
targetRevision: HEAD
path: ./nginx-app
destination:
server: https://kubernetes.default.svc
namespace: demo

syncPolicy:
syncOptions:
- CreateNamespace=true
automated:
prune: false
selfHeal: false

Save in a file for say, "application.yaml". Deploy to the cluster by running the below command:
  • $ kubectl apply -n argocd -f application.yaml
That's all for today. Next, we will learn some advanced concepts of Argo CD.

Comments

All Post

Argo CD 101

Logging ??

What is GitOps in easy way ??

AWS and its Services ??

Observability 101

Prometheus Architecture...

Why need of Cloud Computing ??

Build a Slack activity dashboard with Metabase

Monitoring 101