Simplify Your Kubernetes Deployments with ArgoCD and GitOps 


In this blog, we’ll discuss how ArgoCD can help you simplify your Kubernetes deployments. ArgoCD is a Kubernetes tool that allows you to automate your deployment process and manage your applications using GitOps. This means that you can define the desired state of your Kubernetes resources as code, and ArgoCD will ensure that your cluster matches this state.


By the end of this blog, you’ll have a solid understanding of how to use ArgoCD to simplify your Kubernetes deployments and streamline your workflows.

What is ArgoCD ?

ArgoCD is not just any Kubernetes tool, it’s your ultimate weapon in the battle to simplify and streamline your Kubernetes deployments. It’s a powerful tool that automates your deployment process, so you can say goodbye to repetitive manual tasks and hello to a streamlined deployment process. With ArgoCD, you can manage your applications using GitOps, which means you can define the desired state of your Kubernetes resources as code, and ArgoCD will make sure your cluster matches this state. Are you ready to take your DevOps game to the next level with ArgoCD’s intuitive web interface and CLI? 

Whether you’re new to Kubernetes or a pro, ArgoCD can help you simplify your workflows and make your life easier.

Why do we need ArgoCD ?

  • Automates deployment processes, saving time and effort
  • Ensures consistency and compliance across Kubernetes resources
  • Simplifies and streamlines Kubernetes deployments
  • Provides version control and rollback capabilities to avoid deployment errors
  • Offers an intuitive web interface and CLI for easy application management and workflow optimization.

What is GitOps ?

GitOps is a revolutionary approach to managing infrastructure and applications that make life easier. It harnesses the power of Git, the version control system used to keep track of changes and updates to code. 

With GitOps, you can manage Kubernetes clusters and applications declaratively, which means that they can express the desired state of their system as code, and Git takes care of the rest. 

This approach reduces complexity, standardizes workflows, and increases productivity, while minimizing the risk of errors and downtime. ArgoCD is an exciting tool that makes GitOps on Kubernetes even easier and simplifies the management of even the most complex systems.

Let’s get started!

What is Applications & Projects in ArgoCD ?

ArgoCD can be a powerful tool for managing your Kubernetes applications, but to get started, you’ll need to understand two key concepts: Applications and Projects. 

Applications are like the blueprint for your Kubernetes resources. You define the source (where your manifests live) and the destination (where they should be deployed) and let ArgoCD handle the rest. It’s like having a personal deployment assistant that always keeps your applications running in the desired state.

But what if you have multiple applications that are related or unrelated? That’s where Projects come in. Projects are like folders that help you organise and manage your Applications. You can group Applications by team, environment, or any other criteria you choose.

With these two tools, you can deploy your apps with ease and keep your Kubernetes cluster running like a well-oiled machine.

Let’s look how can we create a project and an application in ArgoCD

Creating an application in ArgoCD is a breeze! You have multiple options to choose from, including using the web interface, command-line interface, or manifest files. You can even paste your application manifest directly into the UI. With ArgoCD, managing your apps has never been easier. So sit back, relax, and let ArgoCD handle the heavy lifting. How cool is that?

Creating a Project in ArgoCD

Step 1: Access the ArgoCD user interface ArgoCD UI.
Step 2: Navigate to Settings In the ArgoCD UI, navigate to the “Settings” page.
Step 3: Create a Project In the “Settings” page, click on the “Projects” tab. Then, click on the “New Project” button to create a new project, provide the details for your project. This includes:-

Project Name: Enter a unique name for your project.
Description (optional): You can optionally provide a description for your project.

Step 4: Click on the “Create” button to create the project.

That’s it! This project will be used in the applications that will be created in the next step. Let’s proceed with creating and managing your applications within this project in ArgoCD.

ArgoCD Application Manifest
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: efk-stack
spec:
destination:
namespace: kube-logging
server: 'https://44FAE76C0259DAA41A67841B25E5A9C1.gr7.us-west-2.eks.amazonaws.com'
source:
path: efk-stack
repoURL: 'https://gitlab.com/priyanshichauhan0707/efk-stack.git'
targetRevision: main
sources: []
project: devops
syncPolicy:
automated:
prune: true
selfHeal: true
retry:
limit: 5
backoff:
duration: 5s
factor: 2
maxDuration: 3m
syncOptions:
– Validate=true
– CreateNamespace=true

This manifest is a basic example of what is needed to create an application in ArgoCD, and it includes all the required fields and some optional ones as well. It's important to note that each application can have its own unique configuration and the manifest may differ depending on the requirements of the application being deployed.

Creating an application in ArgoCD is super easy, but you need to make sure you include all the necessary information in your manifest. Here’s what you need to include:-

General Settings

  • project: A project is a way to organise and group related applications together. When you create an application in Argo CD. Each project can have multiple applications associated with it. The project field in the application manifest is optional and if not specified, it will default to the default project.
  • syncPolicy: The syncPolicy field of an application’s manifest is used to specify how the application should be synchronised with the desired state defined in the source repository.
  • automated: Specifies if and how the application should be automatically synchronised by Argo CD. This is an optional field and it defaults to true if not specified.
  • prune: Specifies if and how ArgoCD should prune resources that are not present in the source. This is an optional field and it defaults to false if not specified.
  • retry: specifies the number of times ArgoCD should attempt to deploy the resource before giving up and marking the deployment as failed.
  • limit: specifies the number of retries (5 in this case) and backoff field specifies the time between retries.
  • duration: specifies the initial duration between retries.
  • factor: specifies how much the duration should increase with each retry (doubling the duration each time).
  • maxDuration: specifies the maximum duration between retries (3 minutes).
  • Validate=true: specifies that the ArgoCD validates the resource before deploying it.
  • CreateNamespace=true: specifies that the ArgoCD creates the namespace for the resource if it doesn’t already exist.

Source Settings

  • source: The source field is a required field in the application manifest and it is used by Argo CD to determine what version of the application to deploy.
  • repoURL: The URL of the Git repository that contains the application manifests. This is a required field.
  • path: The path within the repository where the application manifests are located. This is an optional field and defaults to the root of the repository if not specified.
  • targetRevision: The revision that should be deployed. This can be a branch, tag, or commit hash. This is an optional field and defaults to HEAD if not specified.

Destination Settings

  • destination: This field is a required field of an application’s manifest used to specify the target environment where the application should be deployed.
  • server: The URL of the Kubernetes API server where the application should be deployed. This is a required field.
  • namespace: The namespace within the Kubernetes cluster where the application should be deployed. This is a required field.
Creating an Applications in ArgoCD: A Step-by-Step Guide
  • Step 1: Access the ArgoCD user interface ArgoCD UI and Authenticate with your credentials to log in.
  • Step 2: Navigate to the “Applications” section. This is where you can manage your applications. Click on the “New App” button.

  • Step 3: Click on the “Edit as YAML” button. This will open a text editor where you can paste your application YAML.

  • Step 4: Paste the entire content of your application YAML. Make sure it is a valid YAML format and includes all the required fields for creating an ArgoCD application.
  • Step 5: Click on the “Save” button to save the manifest.

  • Step 6: Click on the “Create” button to start creating a new application in ArgoCD.

  • Step 7: Verify the application creation. Once the application is created, you can verify its status in the ArgoCD user interface. You should see the application listed with its status and any error messages, if any.


Now the ArgoCD application is synced and healthy, ready to rock and roll in your Kubernetes cluster. But that’s not all. With ArgoCD, you have complete control over your applications behaviour to meet your specific requirements.

Whether it’s setting up automated sync policies, defining retries and self-healing options, or customising sync options to ensure your applications align with your desired state and performance expectations, ArgoCD puts you in the driver’s seat, allowing you to fine-tune your application for maximum productivity and reliability.

Let’s now verify the deployment of the EFK stack that we have deployed by access Kibana UI


By doing this, you are able to verify that the EFK stack deployment is working fine and as expected.

That’s it!

I hope this blog has been helpful in understanding how ArgoCD works as a GitOps tool and how to configure it for managing deployments in Kubernetes clusters. With ArgoCD, you can achieve efficient and reliable application deployments in your Kubernetes environment, ensuring smooth operations.

So go ahead, try out ArgoCD, and unlock the full potential of GitOps for your Kubernetes deployments. Happy deploying with ArgoCD!


Blog Pundits: Bhupender Rawat and Sandeep Rawat

OpsTree is an End-to-End DevOps Solution Provider.

Connect with Us


Author: Priyanshi Chauhan

I am a DevOps Engineer

One thought on “Simplify Your Kubernetes Deployments with ArgoCD and GitOps ”

Leave a Reply