Manage Application Lifecycle and Health on Kubernetes with Argo CD

Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes. It follows the GitOps pattern of using git repositories as the source of truth for defining the desired application state. With ArgoCD, application deployments can be automated and updates to application can be made at the simple git commit events without the need of any complicated Continuous Integration and/or Deployment Pipelines.

This is our second post in the series of blog post on deploying and managing application with Kubernetes and Argo CD. In the first part, we discussed how to setup Argo CD and deploy an application on to Kubernetes cluster with it.

You can find the series index here.

View / Edit / Manage the Application and its Health

We can view the applications health at a glance by viewing the /applications page in the UI. It is also the default landing page. All applications added to the Argo CD are listed in the form of tiles. We can also search and filter the results with the application name:

Since our setup has only application, we are shown the same. To view more details about application health, click on the associated tile and it will load the more details about the same:

View/Edit Application Configuration – App Details

This button can be used to view the application configuration (as was created during the setup) and also edit the configuration if required:

View deviation from desired state – App Diff

This button can be used to compare the desired state of the application versus the live state in the Kubernetes cluster and show the difference. If there are multiple manifests, it will show the same in form of different blocks.

If the Argo CD has determined that there is no difference between live state and desired state, this button will be greyed out.

Synchronize/Deploy Application – Sync

This button can be used to synchronize the live state and the desired state. Once you click it, it will present you with multiple options on what you want to synchronize.

You can also choose to perform selective sync for the manifests:

View Last Sync Operation Details – Sync Status

This button shows the details about the last sync operation performed such as when the sync was performed, what was the status of operation, start time and end time of operation etc.

You can also view if any actions were performed as part of the sync operation:

View Sync History and Rollback Release – History and Rollback

This button shows the history of the sync operations performed and if possible, to rollback the application manifests:

Rollback is performed by selecting specified sync and choosing to redeploy it:

Remove the Application – Delete

This button can be used to delete the application at once. You’ll be presented with a confirmation box about the same before it proceeds further:

Here you can select the propagation policy for deletion of resources. Supported policies are background, foreground and orphan / non-cascading. In non-cascading policy, it deletes the application from the Argo CD and not from the Kubernetes cluster.

Changing Application Views

Since the default view provides most useful information, it can become hard to view all information for large application manifests at a glance. We can view selective data about the Resources by changing the view from default view to other by selecting appropriate filters on basis of sync status, health status and Kubernetes resource type:

We can also change the view from tree (default) to pods, networks etc.

Pods View in Argo CD 2.0

One of the new features introduced in Argo CD release is Pod View. Pods View is particularly useful for applications that have hundreds of pods. Instead of visualizing all Kubernetes resources for the application, it only shows Kubernetes pods and closely related resources. Access the view via the Pods View type icon in the right top:

Right now, we have only 1 pod, so it does not look much interesting. Lets scale deployment to increase desired count to 5:

mohitgoyal@desktop:/mnt/d/mohit/src/kind$ kubectl scale deployment guestbook-ui --replicas=5 -n default --context kind-kind-1a
deployment.apps/guestbook-ui scaled

mohitgoyal@desktop:/mnt/d/mohit/src/kind$ kubectl get all -n default --context kind-kind-1a
NAME                                READY   STATUS    RESTARTS   AGE
pod/guestbook-ui-85985d774c-jhb82   1/1     Running   0          8s
pod/guestbook-ui-85985d774c-m8ngl   1/1     Running   0          8s
pod/guestbook-ui-85985d774c-mwc6v   1/1     Running   0          66m
pod/guestbook-ui-85985d774c-rb85j   1/1     Running   0          8s
pod/guestbook-ui-85985d774c-zl725   1/1     Running   0          8s

NAME                   TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)   AGE
service/guestbook-ui   ClusterIP   10.96.149.44   <none>        80/TCP    66m
service/kubernetes     ClusterIP   10.96.0.1      <none>        443/TCP   160m

NAME                           READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/guestbook-ui   5/5     5            5           66m

NAME                                      DESIRED   CURRENT   READY   AGE
replicaset.apps/guestbook-ui-85985d774c   5         5         5       66m

The screenshot below demonstrates how we can use the new view to quickly find how many pods your application is running and which resources created them:

We can also group pods by Node to see how they are spread across the nodes and how many resources they requested:

Viewing Logs and Events for Resources

Argo CD provides a way to see live logs of pods, which is very useful for debugging and troubleshooting. In the v2.0 release, the log visualization has been rewritten to support pagination, filtering, the ability to disable/enable log streaming.

To view logs for a resource, click on the 3 dots associated with the resource tile and select logs:

There is even a dark mode:

We can also see the events associated with a resource in the events section:

The Argo CD CLI supports log streaming as well. Use the argocd app logs command to get logs for one or more pods:

mohitgoyal@desktop:/mnt/d/mohit/src/kind$ argocd app logs --help
Get logs of application pods

Usage:
  argocd app logs APPNAME [flags]

Flags:
      --filter string       Show logs contain this string
      --follow              Specify if the logs should be streamed
      --group string        Resource group
  -h, --help                help for logs
      --kind string         Resource kind
      --name string         Resource name
      --namespace string    Resource namespace
      --since-seconds int   A relative time in seconds before the current time from which to show logs
      --tail int            The number of lines from the end of the logs to show
      --until-time string   Show logs until this time

Displaying Application Status Badge

Argo CD can display a badge with health and sync status for any application. The feature is disabled by default because badge image is available to any user without authentication. The feature can be enabled using statusbadge.enabled key of argocd-cm ConfigMap. Add below lines to the configmap argocd-cm:

data:  
  # Enables application status badge feature
  statusbadge.enabled: "true"

Once its done, we can get the url from URL format ${argoCdServerURL}/api/badge?name=${appName}. Alternatively, it can be obtained from application details page:

You can copy the url and paste the same where you want to display it.

One thought on “Manage Application Lifecycle and Health on Kubernetes with Argo CD

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 )

Google photo

You are commenting using your Google 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