ArgoCD: GitOps Made Easy — Part 2

8grams
4 min readMay 8, 2023
ArgoCD

Introduction to ArgoCD

As Kubernetes continues to gain traction as a leading container orchestration platform, the need for efficient and reliable deployment and management tools grows. ArgoCD has emerged as a powerful solution, leveraging GitOps principles to optimize Kubernetes deployments.

What is ArgoCD?

ArgoCD is an open-source, declarative, GitOps-based continuous delivery tool specifically designed for Kubernetes. It allows developers and operations teams to streamline deployment and management processes by automating the synchronization of desired application states, as defined in a Git repository, with the actual states within a Kubernetes environment.

Key Features

ArgoCD offers a range of features that streamline the deployment and management of Kubernetes resources. It maintains declarative and version-controlled configurations by storing all Kubernetes resource configurations in a Git repository. This setup ensures consistency and version control. Furthermore, ArgoCD automatically detects and deploys changes as they are committed to the Git repository, enabling continuous delivery.

Real-time visibility into the health and status of applications within the Kubernetes cluster is another essential feature of ArgoCD. In addition, ArgoCD allows for easy rollbacks to previous configurations and maintains a detailed history of application changes. Finally, ArgoCD offers fine-grained access control and supports multi-tenancy, enabling multiple teams to manage their applications independently.

Why we need tools like ArgoCD

Using ArgoCD offers several advantages for organizations embracing Kubernetes:

  • Improved collaboration: ArgoCD's Git-centric approach encourages collaboration between development and operations teams.
  • Enhanced consistency: By maintaining version-controlled configurations, ArgoCD ensures application consistency across different environments.
  • Increased efficiency: ArgoCD automates deployment and management processes, reducing manual intervention and the potential for human error.
  • Faster deployment cycles: ArgoCD accelerates application deployment by automatically detecting and deploying changes as they are committed.
  • Greater visibility: ArgoCD's monitoring capabilities provide real-time insights into application health and status.

Installing ArgoCD on Kubernetes Cluster

Setting up ArgoCD on a Kubernetes cluster is relatively simple. ArgoCD conveniently offers deployment manifests, enabling a quick and efficient installation process on your Kubernetes cluster.

Download Deployment Manifest

~$ wget https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

Create dedicated namespace argocd and install ArgoCD on that namespace

~$ kubectl create namespacce argocd

~$ kubectl -n argocd apply -f install.yaml

Verify installation

~$ kubectl -n argocd get pods
NAME READY
argocd-application-controller-0 1/1 Running
argocd-applicationset-controller-xxx 1/1 Running
argocd-dex-server-xxx 1/1 Running
argocd-notifications-controller-xxx 1/1 Running
argocd-redis-xxx 1/1 Running
argocd-repo-server-xxx 1/1 Running
argocd-server-xxx 1/1 Running

At present, ArgoCD has been successfully installed on our Kubernetes cluster.

Exposing ArgoCD service

To enhance accessibility, we can expose the ArgoCD service through Ingress, allowing us to access it via a browser without the need for private tunneling. We will create an SSL Certificate using Let's Encrypt for our ArgoCD Ingress.

To learn how to accomplish this, you can refer to the following article:

Next, we will create Ingress resources

It is crucial to remember not to modify the tls.secretName value, as ArgoCD already has a reference to it.

Install to Kubernetes Cluster

~$ kubectl -n argocd apply -f ingress.yaml

Now you can open your browser and navigate to https://argocd.example.com and you will see ArgoCD's login page there

By default, the username is admin. To obtain the admin password, you can access it from ArgoCD's secret.

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

Configuring Git Repository on ArgoCD

The first thing we need to do after installing ArgoCD is configuring git repository. Git workflows form the core of your GitOps deployments, as they enable the implementation of changes in your environment. With GitOps, Git serves as both the source of truth and the interface for your environment.

Here are some best practices of managing git repository for our GitOps Deployments:

  1. Separate your repositories: Keep application code and YAML configurations in distinct repositories. This separation prevents configuration changes from triggering unnecessary application rebuilds and allows for independent lifecycles of code and configuration.
  2. Separate development in directories, not branches: Store configurations for different environments (e.g., test, production) in separate directories instead of branches. This approach avoids challenges related to merging environment-specific configurations.
  3. Trunk-based development: Use trunk-based development for your configuration repositories. This approach involves a single "trunk" branch and short-lived branches for each environment. Once an environment's development is complete, create a pull request to merge the branch into the trunk.
  4. Pay attention to policies and security: To maintain a stable environment and protect the trunk, utilize version control features for policy management and security. Set up branch protection rules and establish clear rules for merging and approvals.

By following these best practices, you can effectively manage Git workflows for your GitOps deployments, ensuring a streamlined and secure process.

So let's start. Login to ArgoCD Dashboard and navigate to Settings > Repositories > Connect Repo. Fill the form like screenshot below (adjust with your own values) and klik Connect.

Great! ArgoCD is now set up and prepared for use. You can begin configuring your Kubernetes resources within ArgoCD.

About 8grams

We are a small DevOps Consulting Firm that has a mission to empower businesses with modern DevOps practices and technologies, enabling them to achieve digital transformation, improve efficiency, and drive growth.

Ready to transform your IT Operations and Software Development processes? Let's join forces and create innovative solutions that drive your business forward.

--

--

8grams

We are a DevOps Consulting Firm with a mission to empower businesses with modern DevOps practices and technologies