paint-brush
Streamlining Kubernetes App Deployments with ArgoCD: A Step-by-Step GitOps Guideby@abrahamdahunsi
6,995 reads
6,995 reads

Streamlining Kubernetes App Deployments with ArgoCD: A Step-by-Step GitOps Guide

by Abraham Dahunsi November 7th, 2023
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

ArgoCD simplifies Kubernetes app deployment by automating synchronization, maintaining desired states, and providing a user-friendly interface. It's a valuable tool for DevOps and developers managing complex applications in Kubernetes clusters.
featured image - Streamlining Kubernetes App Deployments with ArgoCD: A Step-by-Step GitOps Guide
Abraham Dahunsi  HackerNoon profile picture


How can you make sure that your application code, configuration, and environment remain consistent and up-to-date across all your Kubernetes clusters? How do you keep track of your application deployments and reversions? What methods do you employ to adhere to practices for version control, change management, and security?


This article will guide you through the process of utilizing ArgoCD, a tool for GitOps CD in Kubernetes. It aims to streamline your Kubernetes application deployments by simplifying and automating deployment workflows, providing auditing and visibility into your application state, and, facilitating configuration management. Additionally, you'll be taken through a step-by-step tutorial on how to set up ArgoCD on your Kubernetes cluster, configure it for deploying your applications, and ultimately deploy your app using ArgoCD.


Content Overview

  • Introduction to Kubernetes and ArgoCD
  • Prerequisites for using ArgoCD
  • Setting up ArgoCD
  • Configuring ArgoCD for your Kubernetes app deployments
  • Deploying your app with ArgoCD
  • Monitoring and managing your app deployments with ArgoCD
  • Conclusion and next steps

Introduction to Kubernetes and ArgoCD


What is Kubernetes and why is it popular?

Credit: SIMFORM



Kubernetes is an open-source platform that streamlines the process of deploying, scaling, and overseeing containerized applications. It enables you to run your applications on a group of servers known as nodes, which can extend across clouds, data centers, or regions. Kubernetes simplifies the management of underlying infrastructure complexities and offers an approach to deploying and handling your applications efficiently.


Some of the key features and benefits of Kubernetes are:


  • Service discovery and load balancing: Kubernetes automatically assigns IP addresses and DNS names to your containers and services and distributes the traffic load among them.


  • Storage orchestration: Kubernetes allows you to mount various types of storage systems to your containers, such as local disks, cloud volumes, or network-attached storage.


  • Self-healing: Kubernetes can detect and restart failed containers, reschedule them to other nodes, or replace them with new ones.


  • Horizontal scaling: Kubernetes can automatically scale your applications up or down based on CPU or memory usage, or based on custom metrics or triggers.


  • Rollouts and rollbacks: Kubernetes can update your applications with zero downtime using rolling updates and roll them back to a previous version if something goes wrong.


  • Configuration and secret management: Kubernetes can store and manage your application configuration and sensitive data, such as passwords, tokens, or keys, as resources that can be injected into your containers at runtime.


  • Batch execution: Kubernetes can run batch or cron jobs that can be scheduled to run at a specific time or interval.


Kubernetes is a widely adopted platform utilized by organizations spanning from startups to enterprises for effectively running their applications at large scales while ensuring high availability, reliability, and performance. Prominent users of Kubernetes include companies such as Google, Netflix, Spotify, Shopify, and Airbnb.



What is ArgoCD and how does it simplify Kubernetes app deployments?

Credit: ArgoCD




ArgoCD is a declarative GitOps CD tool for Kubernetes. GitOps is a pattern of using Git repositories as the source of truth for defining the desired state of your applications and infrastructure. GitOps enables you to apply the same principles of version control, code review, and collaboration that you use for your application code to your configuration and deployment processes.


ArgoCD functions by keeping your application state in sync between your Kubernetes cluster and the configuration files stored in your Git repository. Whenever you make updates to your configuration files, like modifying app code, adjusting Kubernetes manifests, or changing environment variables, ArgoCD will automatically apply those changes to your cluster. If there are any inconsistencies or conflicts ArgoCD will notify you as well.


Additionally, ArgoCD provides a user web interface and command-line tool that allows you to monitor and manage deployments efficiently. This includes checking the status and health of resources, rolling back to versions if needed, and manually synchronizing any changes you make.


Some of the key features and benefits of ArgoCD are:


  • Declarative and reproducible: ArgoCD allows you to define your application state in a declarative and human-readable way, using YAML or JSON files or using tools like Helm, Kustomize, or Jsonnet. This makes your application state easy to understand, track, and reproduce across different environments and clusters.


  • Consistent and automated: ArgoCD ensures that your application state in your cluster is always consistent with the state in your Git repository and automatically applies any changes or updates to your cluster. This eliminates the need for manual or scripted deployments and reduces the risk of human errors or configuration drifts.


  • Auditable and traceable: ArgoCD records and displays the history and details of your application deployments, such as the Git commit, the author, the date, and the diff. This allows you to audit and trace the changes and events that occurred in your application lifecycle, and easily identify and troubleshoot any issues or anomalies.


  • Secure and compliant: ArgoCD supports various authentication and authorization mechanisms, such as SSO, OIDC, OAuth2, LDAP, SAML, or GitHub, to control access to your application deployments. ArgoCD also supports RBAC and multi-tenancy policies to define different roles and permissions for different users and teams. ArgoCD also enforces the use of HTTPS and TLS encryption and allows you to store and manage your secrets securely using tools like HashiCorp Vault or AWS KMS.


ArgoCD is a popular and widely used tool for implementing GitOps on Kubernetes. Some of the users of ArgoCD include Intuit, Red Hat, Ticketmaster, and Codefresh.


What are the benefits of using ArgoCD for Kubernetes app deployments?

By using ArgoCD for your Kubernetes app deployments, you can enjoy the following benefits:


- Faster and more reliable deployments: ArgoCD can speed up your deployment cycles and improve your deployment quality by automating and streamlining your deployment workflows and reducing manual intervention and human errors. ArgoCD can also handle complex and multi-stage deployments, such as blue-green, canary, or progressive delivery, using tools like Argo Rollouts or Flagger.

- Improved visibility and traceability: ArgoCD can provide you with a clear and real-time view of your application state and activity by showing you the status, health, and differences of your resources, as well as the history and details of your deployments. ArgoCD can also integrate with various notification and alerting tools, such as Slack, Email, or Prometheus, to keep you informed of any changes or issues in your application deployments.

- Easier configuration management: ArgoCD can simplify and centralize your configuration management by allowing you to store and manage your configuration files in a single Git repository or by using multiple repositories for different environments or teams. ArgoCD can also help you manage your configuration files using tools like Helm, Kustomize, or Jsonnet to avoid duplication and complexity and to enable parameterization and customization.


Prerequisites for using ArgoCD

Before you can use ArgoCD to deploy your Kubernetes applications, you need to have the following requirements:


To proceed, you'll need a Kubernetes cluster that includes one worker node. You have the flexibility to choose any Kubernetes distribution or service, such as DigitalOcean Managed Kubernetes, Google Kubernetes Engine, or Minikube. Additionally, ensure you have installed and properly set up the command-line tool to establish a connection with your cluster. For instructions on setting up Kubectl, refer to the documentation.


GitHub account where you can create and manage your Git repositories for your application code and configuration files. You also need to have the git command-line tool installed and configured to interact with GitHub. For more information on how to set up Git and GitHub, see the official documentation.


A Docker Hub account where you can store and pull your application container images. You also need to have the docker command-line tool installed and configured to build and push your images. For more information on how to set up Docker and Docker Hub, see the official documentation.


Once you have these prerequisites, you can proceed to install and set up ArgoCD on your Kubernetes cluster.



Setting up ArgoCD

Once you have fulfilled the requirements for utilizing ArgoCD, you can proceed with the installation and configuration of ArgoCD on your Kubernetes cluster. Now, I will guide you through the steps to install ArgoCD using either Helm or Kubectl, as how to access its web interface and command-line interface (CLI). Additionally, we will cover the process of creating an ArgoCD project and application.


Installing ArgoCD using Helm or kubectl

There are two ways to install ArgoCD on your Kubernetes cluster: using Helm or Kubectl. Helm is a package manager for Kubernetes that allows you to install and manage applications using charts, which are collections of YAML templates. Kubectl is a command-line tool that allows you to run commands against your Kubernetes cluster.


To install ArgoCD using Helm, you need to have Helm installed and configured on your local machine. You can follow the official documentation to install and set up Helm. Then, you can add the ArgoCD Helm repository and install the ArgoCD chart with the following commands:


helm repo add argo https://argoproj.github.io/argo-helm

helm install argocd argo/ argo-cd -n argocd


This will create a new namespace, argocd, where ArgoCD services and application resources will live. You can customize the installation by using different values for the chart parameters. You can find the list of available parameters and their default values in the chart README.


To install ArgoCD using Kubectl, you need to have Kubectl installed and configured on your local machine. You can follow the official documentation to install and set up Kubectl. Then, you can create the argocd namespace and apply the ArgoCD installation manifest with the following commands:


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


This will create the same namespace and resources as the Helm installation. You can also install the core ArgoCD components only, without the UI, SSO, or multi-cluster features, by using the core-install.yaml manifest instead of the install.yaml manifest.


Accessing the ArgoCD web UI and CLI

After installing ArgoCD on your Kubernetes cluster, you will be able to access the ArgoCD web user interface (UI) and command-line interface (CLI). These interfaces allow you to effectively monitor and manage your application deployments. The web UI provides a representation of your applications, resources, clusters, status, and health. It also enables you to perform tasks, like synchronization, rollback, or deletion of your applications. On the other hand, the CLI offers functionality as a web UI while also allowing you to configure and troubleshoot ArgoCD.


By default, the ArgoCD web UI is not exposed to an external IP. To access the web UI, you need to expose the argocd-server service with one of the following methods:


- Service Type Load Balancer: Change the argocd-server service type to LoadBalancer, which will assign an external IP address to the service. You can do this by running the following command:


kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}'



Then, you can get the external IP address of the service by running the following command:


kubectl get svc argocd-server -n argocd


You can then access the web UI by using the external IP address and the default port 443 in your browser, such as <https://<external_ip>:443>.


- Ingress: Configure an ingress controller and an ingress resource to route the traffic to the argocd-server service. You can follow the official documentation to set up an ingress controller and an ingress resource for ArgoCD. You can then access the web UI by using the hostname and the path that you specified in the ingress resource, such as ‘https://argocd.example.com.’


- Port Forwarding: Use kubectl port-forwarding to connect to the argocd-server service without exposing it. You can do this by running the following command:


kubectl port-forward svc/argocd-server -n argocd 8080:443



This will forward the local port 8080 to the remote port 443 of the service. You can then access the web UI by using the local port and the localhost address in your browser, such as https://localhost:8080.


To use the ArgoCD CLI, you must first install the binary on your personal computer. The latest version of the binary can be obtained from the GitHub releases page. Alternatively, if you are using Mac, Linux, or WSL, you can install the binary through Homebrew by executing this command:


brew install argocd



After you have installed the binary, you need to log in to the ArgoCD server using the argocd login command. The initial password for the admin account is auto-generated and stored as clear text in the field password in a secret named argocd-initial-admin-secret in the argocd namespace. You can retrieve this password by running the following command:


kubectl get secret argocd-initial-admin-secret -n argocd -o jsonpath='{.data.password}' | base64 -d



You can then log in to the ArgoCD server by running the following command, replacing <server_address> with the address of the argocd-server service that you exposed and <password> with the password that you retrieved:


argocd login <server_address> --username admin --password <password>


You can also use the --insecure flag to skip the server certificate verification or the --core flag to use the core ArgoCD components without the UI, SSO, or multi-cluster features. After you log in, you can use the argocd commands to interact with the ArgoCD server. You can run argocd help to see the list of available commands and options.


Creating an ArgoCD project and application

To get started with deploying your applications using ArgoCD the first step is to create an ArgoCD, project, and application. An ArgoCD project serves as a way to group applications based on policies, such as the repositories they come from, the clusters they are deployed to the namespaces, they use, and the permissions they require. On the other hand, an ArgoCD application is a custom resource in Kubernetes that specifies details like the source repository for your application, the path it should follow, the cluster it is targeted at, and the namespace it belongs to. Additionally, it also handles synchronization. Provides health status updates for your application.


To create an ArgoCD project, you can use the argocd proj create command or the web UI. For example, to create a project named demo with the source repository https://github.com/argoproj/argocd-example-apps, the destination cluster https://kubernetes.default.svc, and the destination namespace default, you can run the following command:


argocd proj create demo -d https://kubernetes.default.svc,default -s
https://github.com/argoproj/argocd-example-apps 



You can also use the --description flag to add a description for your project, or the --roles flag to define roles and permissions for your project. You can run argocd proj create --help to see the full list of flags and options.


To create an ArgoCD application, you can use the argocd app create command or the web UI. For example, to create an application named guestbook with the source repository https://github.com/argoproj/argocd-example-apps, the path guestbook, the cluster https://kubernetes.default.svc, the namespace default, and the project demo, you can run the following command:


argocd app create guestbook --repo https://github.com/argoproj/argocd-example-apps --path guestbook --dest-server https://kubernetes.default.svc --dest-namespace default --project demo



You can also use the --sync-policy flag to specify the synchronization policy for your application, such as automatic or manual, or the --helm-set flag to set Helm parameters for your application. You can run argocd app create --help to see the full list of flags and options.



Configuring ArgoCD for your Kubernetes app deployments

Once you have set up your ArgoCD project and application, the next step is to configure ArgoCD to sync your application from GitHub to your Kubernetes cluster. In this section, you will be guided on how to create a GitHub repository for your application code and configuration files. Additionally, you will learn how to write a Dockerfile and a Kubernetes manifest specifically tailored for your application. Lastly, instructions will be provided on configuring ArgoCD to synchronize your application from GitHub to your Kubernetes cluster.


Creating a GitHub repository for your app code and configuration files

To deploy your application using ArgoCD, it is necessary to have your application code and configuration files stored in a Git repository. You have the option to utilize GitHub as your Git hosting service since it is compatible with ArgoCD and provides a range of features and integrations that can enhance your development process.


In order to create a GitHub repository for your application, it is essential to possess a GitHub account and have the git command-line tool properly installed and configured on your computer. To assist you in this process, you may refer to the documentation provided by GitHub for instructions on setting up git and GitHub.


Then, you can create a new repository on GitHub by following these steps:


- Go to GitHub and sign in with your account.

- In the upper-right corner of any page, click the + icon, and then click New repository.




- Type a name for your repository, such as argocd-demo-app.



- Optionally, add a description, choose a license, or initialize the repository with a README file.

- Click Create repository.


Alternatively, you can create a new repository on your local machine by following these steps:


- Create a new directory for your project, such as argocd-demo-app, and navigate to it.

- Run the following command to initialize the directory as a Git repository:


git init



- Run the following command to create a README file with some basic information about your project:


echo "# ArgoCD Demo App" > README.md



- Run the following command to add the README file to the staging area:


git add README.md



- Run the following command to commit the README file to the local repository:


git commit -m "Initial commit"


- Go to GitHub and sign in with your account.

- In the upper-right corner of any page, click the + icon, and then click New repository.

- Type a name for your repository, such as argocd-demo-app, and copy the URL of the repository, such as https://github.com/<username>/argocd-demo-app.git.

- Run the following command to add the URL of the remote repository to your local repository:


git remote add origin https://github.com/<username>/argocd-demo-app.git



- Run the following command to push the local repository to the remote repository:


git push -u origin master


You have now created a GitHub repository for your app code and configuration files. You can use this repository as the source for your ArgoCD application.


Writing a Dockerfile and a Kubernetes manifest for your app

To deploy your app to your Kubernetes cluster, you need to write a Dockerfile and a Kubernetes manifest for your app. A Dockerfile is a text file that contains the instructions to build a Docker image for your app. A Kubernetes manifest is a YAML file that defines the Kubernetes resources, such as pods, services, or deployments, for your app.


For this tutorial, you will use a simple Node.js app that serves a static web page.


The Dockerfile for the app looks like this:


# Use the official Node.js image as the base image
FROM node:14-# Set the working directory in the containeralpine

# Set the working directory in the container
WORKDIR /app

# Copy the package.json and package-lock.json files to the working directory
COPY package*.json ./

# Install the app dependencies
RUN npm install

# Copy the app code to the working directory
COPY . .

# Expose port 3000 to the outside world
EXPOSE 3000

# Run the app when the container launches
CMD ["node", "server.js"]



The Kubernetes manifest for the app looks like this:


# Define a deployment resource for the app
apiVersion: apps/v1
kind: Deployment
metadata:
  # Name the deployment as argocd-demo-app
  name: argocd-demo-app
spec;
  # Create one replica of the app pod
  replicas: 1
  # Define the selector to match the app pod labels
 selector:
  matchLabels:
   app: argocd-demo-app
  # Define the template for the app pod
  template:
   metadata:
    # Set the labels for the app pod
    labels:
     app: argocd-demo-app
    spec:
     # Define the container for the app pod
     containers:
      - name: argocd-demo-app
       # Use the image built from the Dockerfile
       image: argocd-demo-app:latest
       # Set the image pull policy to Never
       # This assumes that the image is already present on the node
       # Change this to Always or IfNotPresent if the image is pulled from a registry
       imagePullPolicy: Never
       # Expose port 3000 on the container
       - containerPort: 3000
# Define a service resource for the app
apiVersion: v1
kind: Service
metadata:
 # Name the service as argocd-demo-app
 name: argocd-demo-app
spec:
 # Set the service type to NodePort
 # This will expose the service on a port on each node
  type: NodePort
  # Define the selector to match the app pod labels
  selector:
   app: argocd-demo-app
  # Define the ports for the service
  ports:
   - name: http
    # Expose port 80 on the service
    port: 80
    # Target port 3000 on the app pod


You can save these files as Dockerfile and k8s.yaml in the root directory of your repository. You can also modify them according to your app requirements.

Configuring ArgoCD to sync your app from GitHub to your Kubernetes cluster

To set up ArgoCD for syncing your application from GitHub to your Kubernetes cluster, you will have to make changes to the ArgoCD application resource that was created in this section. Make sure to provide the required parameters mentioned below:


- repo: The URL of your GitHub repository, such as https://github.com/<username>/argocd-demo-app.git.

- path: The path in your repository where the Kubernetes manifest file is located, such as /k8s.yaml.

- image: The name and tag of the Docker image for your app, such as argocd-demo-app:latest.


You can update the ArgoCD application resource using the argocd app set command or the web UI. For example, to update the application named guestbook, you can run the following command:


argocd app set guestbook --repo https://github.com/<username>/argocd-demo-app.git --path /k8s.yaml --helm-set image=argocd-demo-app:latest



You can also use the --sync-policy flag to specify the synchronization policy for your application, such as automatic or manual. You can run argocd app set --help to see the full list of flags and options.


Alternatively, you can update the ArgoCD application resource using the web UI by following these steps:


- Go to the ArgoCD web UI and log in with your credentials.

- Click on the guestbook application to view its details.

- Click on the EDIT button on the top right corner to edit the application settings.

- In the Application Source section, update the Repository URL, Path, and Helm Parameters fields with the values mentioned above.

- Click on the UPDATE button to save the changes.


You have now configured ArgoCD to sync your app from GitHub to your Kubernetes cluster. You can proceed to deploy your app with ArgoCD in the next section.



Deploying your app with ArgoCD

ArgoCD is a declarative, GitOps continuous delivery tool for Kubernetes. It allows you to sync your application state in your cluster with the configuration files in your Git repository. You can use ArgoCD to automate and streamline your Kubernetes app deployments and to provide visibility and traceability of your application lifecycle.


In this section, you will learn how to deploy your app with ArgoCD, using the following steps:


- Build, test, and stage your app using GitHub Actions.

- Trigger an automatic deployment of your app to your Kubernetes cluster using ArgoCD.

- Verify that your app is deployed correctly using the ArgoCD web UI or CLI.


Building, testing, and staging your app using GitHub Actions


GitHub Actions is a feature provided by GitHub that enables you to automate your software development workflows. It works through the use of YAML files called workflows, where you define a sequence of steps and actions to execute on your code. With GitHub Actions, you have the power to build, test, and prepare your application before deploying it with ArgoCD.


In this tutorial, you'll be working with a Node.js application that serves a webpage. The application code and configuration files can be found in this repository You have the option to either clone this repository onto your machine or copy the files into your repository


For this tutorial, you will use a simple Node.js app that serves a static web page. You can clone this repository on your local machine or copy the files to your repository.


The GitHub Actions workflow file for the app looks like this:


# Define the name of the workflow
name: Build and push Docker image

# Define the trigger for the workflow
# In this case, the workflow will run on every push to the main branch
on:
 push:
  branches: [main]

# Define the jobs for the workflow
jobs:
 # Define the job name
 build-and-push:
  # Define the runner for the job
  # In this case, the job will run on Ubuntu 20.04
  runs-on: ubuntu-20.04
  # Define the steps for the job
   # Checkout the code from the GitHub repository
   - name: Checkout code
     uses: actions/checkout@v2
   # Build the Docker image for the app and tag it with the latest commit SHA
   - name: Build Docker image
     run: |
      # Get the latest commit SHA
      COMMIT_SHA=$(git rev-parse --short HEAD)
      # Build the Docker image and tag it with the commit SHA
      docker build -t
argocd-demo-app:$COMMIT_SHA 

   # Push the Docker image to Docker Hub
   - name: Push Docker image
     run: |
      # Get the latest commit SHA
      COMMIT_SHA=$(git rev-parse --short HEAD)
      # Log in to Docker Hub with your credentials
      # You need to store your Docker Hub username and password as secrets in your GitHub repository settings
      echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
      # Push the Docker image to Docker Hub
argocd-demo-app:$COMMIT_SHA
   # Update the image tag in the Kubernetes manifest file with the latest commit SHA
   - name: Update image tag
     run: |
      # Get the latest commit SHA
      COMMIT_SHA=$(git rev-parse --short HEAD)
      # Replace the image tag in the k8s.yaml file with the commit SHA
      sed -i "s/image:
argocd-demo-app:latest/image:
argocd-demo-app:$COMMIT_SHA/g" k8s.yaml
     # Commit and push the changes to the GitHub repository
     git config --global user.name "GitHub Actions"
     git config --global user.email "[email protected]"
     git add k8s.yaml
     git commit -m "Update image tag to $COMMIT_SHA"
     git push


You can save this file as .github/workflows/build-and-push.yml in the root directory of your repository. You can also modify it according to your app requirements.


Once you have this file in your repository, the GitHub Actions workflow will run automatically on every push to the main branch. You can view the status and logs of the workflow on the GitHub Actions tab of your repository.


Triggering an automatic deployment of your app to your Kubernetes cluster using ArgoCD


To initiate an automated deployment of your application to your Kubernetes cluster using ArgoCD, you must activate the synchronization policy for the ArgoCD application resource that you previously set up. This synchronization policy governs how ArgoCD maintains consistency between your application state in the cluster and the configuration files in your repository. You have the option to select from a range of synchronization policies, including:


Choose the sync policy that best suits your deployment requirements and preferences.


- Manual: ArgoCD will not sync your application automatically. You need to manually trigger the sync operation using the ArgoCD web UI or CLI.

- Automatic: ArgoCD will sync your application automatically whenever there is a change in your repository. You can also configure the sync options, such as pruning, self-healing, or retry.

- Sync and Apply: ArgoCD will sync your application automatically whenever there is a change in your repository, and apply the changes to your cluster without waiting for approval. This is similar to the automatic policy, but with less control and visibility.


For this tutorial, you will use the automatic sync policy, which will trigger an automatic deployment of your app to your Kubernetes cluster whenever the GitHub Actions workflow updates the image tag in the Kubernetes manifest file.


To enable the automatic sync policy for your ArgoCD application resource, you can use the argocd app set command, or the web UI. For example, to enable the automatic sync policy for the application named Guestbook, you can run the following command:


argocd app set guestbook --sync-policy automated



Additionally, you have the option to utilize the auto-prune flag, which allows for the removal of resources that are no longer defined in the Git repository. Alternatively, you can enable the flag to automatically fix any modifications made to resources within the cluster. For a list of flags and options, refer to Argocd App Set Help.


Alternatively, you can enable the automatic sync policy for your ArgoCD application resource using the web UI by following these steps:


- Go to the ArgoCD web UI.

- Click on the guestbook application to view its details.

- Click on the EDIT button on the top right corner to edit the application settings.

- In the Sync Policy section, select Automatic from the drop-down menu.

- Optionally, check the Prune and Self Heal boxes to enable pruning and self-healing of resources.

- Click on the UPDATE button to save the changes.


You have now enabled the automatic sync policy for your ArgoCD application resource. Whenever there is a change in your GitHub repository, ArgoCD will sync your application and deploy it to your Kubernetes cluster.


Verifying that your app is deployed correctly using the ArgoCD web UI or CLI


To verify that your app is deployed correctly using ArgoCD, you can use the ArgoCD web UI or CLI to monitor the status and health of your application, resources, and cluster. You can also use the ArgoCD web UI or CLI to perform various actions on your application, such as syncing, rolling back, or deleting your application.


To verify that your app is deployed correctly using the ArgoCD web UI, you can follow these steps:


- Go to the ArgoCD web UI and log in with your credentials.

- Click on the guestbook application to view its details.

- In the Application Details section, you can see the status and health of your app, such as Synced, Healthy, or OutOfSync, Degraded, or Missing.

- In the Application Summary section, you can see the summary of your app resources, such as the number of pods, services, or deployments, and their status and health.

- In the Resource Tree section, you can see the tree view of your app resources, and their status and health. You can also click on each resource to view its details, such as the YAML definition, the events, the logs, or the diff.

- In the Resource Status section, you can see the status view of your app resources, and their status and health. You can also click on each resource to view its details, as in the Resource Tree section.

- In the Application History section, you can see the history and details of your app deployments, such as the Git commit, the author, the date, and the diff. You can also click on each deployment to view its details, or to roll back to a previous version.

- In the Application Events section, you can see the events and messages related to your app deployments, such as the sync status, the sync result, or the sync error.


To verify that your app is deployed correctly using the ArgoCD CLI, you can run the following command:


argocd app get guestbook



This will display the status and health of your app, resources, and cluster, similar to the web UI. You can also use the --show-conditions flag to display the conditions that affect the app health, or the --resource-events flag to display the resource events. You can run argocd app get --help to see the full list of flags and options.


You can also use the argocd app commands to perform various actions on your app, such as syncing, rolling back, or deleting your app. You can run argocd app --help to see the list of available commands and options.


Monitoring and managing your app deployments with ArgoCD


Once you've successfully deployed your application using ArgoCD, you have the option to monitor and manage your deployments through either the ArgoCD web user interface or the command-line interface (CLI). These tools allow you to keep track of the status and overall health of your application as well as its associated resources and cluster. Additionally, you can perform a variety of actions, like rolling to versions, scaling up or down updating configurations or even deleting your app if necessary.


Monitoring the status and health of your app deployments using the ArgoCD web UI or CLI


To monitor the status and health of your app deployments using the ArgoCD web UI or CLI, you can use the following features:


  • Application Details: This shows the overall status and health of your app, such as Synced, Healthy, OutOfSync, Degraded, or Missing. You can also see the source repository, the destination cluster and namespace, the sync policy, and the sync status of your app.


  • Application Summary: This shows the summary of your app resources, such as the number of pods, services, deployments, and other Kubernetes resources, and their status and health. You can also see the resource tree and status views, which show the hierarchical and tabular representations of your app resources, respectively.


  • Application History: This shows the history and details of your app deployments, such as the Git commit, the author, the date, and the diff. You can also see the sync result, the sync duration, and the sync operation for each deployment.


  • Application Events: This shows the events and messages related to your app deployments, such as the sync status, the sync result, the sync error, or the sync warning. You can also see the event type, the event reason, the event source, and the event message for each event.


To monitor the status and health of your app deployments using the ArgoCD web UI, you can follow these steps:


- Go to the ArgoCD web UI and log in with your credentials.

- Click on the app that you want to monitor to view its details.

- In the Application Details section, you can see the status and health of your app, as well as the source and destination information.

- In the Application Summary section, you can see the summary of your app resources, and their status and health. You can also switch between the Resource Tree and Resource Status tabs to see the different views of your app resources. You can also click on each resource to view its details, such as the YAML definition, the events, the logs, or the diff.

- In the Application History section, you can see the history and details of your app deployments. You can also click on each deployment to view its details or to roll back to a previous version.

- In the Application Events section, you can see the events and messages related to your app deployments. You can also filter the events by type, reason, source, or message.


To monitor the status and health of your app deployments using the ArgoCD CLI, you can run the following command:


argocd app get <app-name>


This will display the status and health of your app, resources, and cluster, similar to the web UI. You can also use the --show-conditions flag to display the conditions that affect the app's health, or the --resource-events flag to display the resource events. You can run the argocd app get --help to see the full list of flags and options.


Managing your app deployments using the ArgoCD web UI or CLI

To manage your app deployments using the ArgoCD web UI or CLI, you can use the following actions:


  • Sync: This applies the changes in your Git repository to your Kubernetes cluster, and updates the live state of your app. You can also use the --prune flag to delete the resources that are no longer defined in your Git repository, or the --force flag to force the sync operation even if there are conflicts or errors.


  • Rollback: This reverts your app to a previous version, and updates the live state of your app. You can also use the --prune flag to delete the resources that are no longer defined in the previous version, or the --force flag to force the rollback operation even if there are conflicts or errors.


  • Scale: This changes the number of replicas of your app pods, and updates the live state of your app. You can also use the --dry-run flag to preview the changes without applying them, or the --force flag to force the scale operation even if there are conflicts or errors.


  • Update: This changes the configuration or parameters of your app, such as the image tag, the environment variables, or the Helm values, and updates the live state of your app. You can also use the --dry-run flag to preview the changes without applying them, or the --force flag to force the update operation even if there are conflicts or errors.


  • Delete: This deletes your app and all its resources from your Kubernetes cluster, and removes the app from ArgoCD. You can also use the --cascade flag to delete the app and all its dependent resources, or the --force flag to force the delete operation even if there are conflicts or errors.


To manage your app deployments using the ArgoCD web UI, you can follow these steps:


  • Go to the ArgoCD web UI and log in with your credentials.
  • Click on the app that you want to manage to view its details.
  • In the top right corner, you can see the SYNC, HISTORY, and DELETE buttons, which allow you to sync, roll back, or delete your app, respectively. You can also click on the MORE button to access more options, such as editing, cloning, or refreshing your app.
  • To sync your app, click on the SYNC button, and select the sync options, such as pruning, self-healing, or retry. Then, click on the SYNC button to confirm the sync operation.
  • To roll back your app, click on the HISTORY button, and select the deployment that you want to roll back to. Then, click on the ROLLBACK button, and select the rollback options, such as pruning, self-healing, or retry. Then, click on the ROLLBACK button to confirm the rollback operation.
  • To scale your app, click on the MORE button, and select Scale from the drop-down menu. Then, enter the number of replicas that you want to scale your app to, and select the scale options, such as dry-run or force. Then, click on the SCALE button to confirm the scale operation.
  • To update your app, click on the MORE button, and select Update from the drop-down menu. Then, enter the configuration or parameters that you want to update your app with, and select the update options, such as dry-run or force. Then, click on the UPDATE button to confirm the update operation.
  • To delete your app, click on the DELETE button, and select the delete options, such as cascade or force. Then, click on the DELETE button to confirm the delete operation.


To manage your app deployments using the ArgoCD CLI, you can use the argocd app commands, such as sync, rollback, scale, update, or delete. You can run argocd app --help to see the list of available commands and options.


Conclusion and next steps


In this article, you learned about the usage of ArgoCD. A tool for Kubernetes that employs declarative and GitOps principles to streamline your application deployments. We explored how ArgoCD can simplify and automate deployment workflows, offering insights into the state of your applications while facilitating effortless configuration management. Additionally, we followed a walkthrough to successfully install and configure ArgoCD on your Kubernetes cluster, ultimately deploying your application with ease using this tool.


ArgoCD is a flexible tool that can assist you in achieving quicker and more dependable deployments, enhanced visibility and traceability, and simplified configuration management for your Kubernetes applications. By utilizing ArgoCD, you can implement the principles of version control, code review, and collaboration that you apply to your application code into your configuration and deployment procedures.



If you want to learn more about ArgoCD or improve your skills, here are some suggestions for further learning or improvement:


  • Explore other features of ArgoCD, such as multi-cluster management, SSO integration, RBAC policies, Helm support, Kustomize support, Jsonnet support, or Argo Rollouts integration.


  • Integrate other tools or services with ArgoCD, such as GitHub Actions, Jenkins, Tekton, Prometheus, Grafana, Slack, or Email.


  • Apply best practices for GitOps, such as using separate branches or repositories for different environments, using pull requests and code reviews for configuration changes, using semantic versioning and tags for image releases, or using linting and validation tools for configuration files.


I hope you enjoyed this article and found it useful. If you have any feedback or questions, please feel free to contact us. Thank you for reading and happy deploying!