Logo

dev-resources.site

for different kinds of informations.

GitOps + ArgoCD: A Perfect Match for Kubernetes Continuous Delivery

Published at
9/21/2024
Categories
devops
gitops
argocd
tutorial
Author
mangadev
Categories
4 categories in total
devops
open
gitops
open
argocd
open
tutorial
open
Author
8 person written this
mangadev
open
GitOps + ArgoCD: A Perfect Match for Kubernetes Continuous Delivery

Introduction

Deploying and managing Kubernetes applications can be complex, but GitOps simplifies it by treating your Git repository as the single source of truth for deployments. ArgoCD streamlines this process further by automatically syncing your Kubernetes clusters with your Git repository.

In this guide, we’ll walk you through setting up GitOps with ArgoCD, making your Kubernetes deployments fast, consistent, and automated. If you're aiming to simplify your workflow, stay tuned—this tutorial will get you up and running in no time.

To dive deeper into GitOps, check out this detailed blog post by @sujal_dua:
GitOps Adoption: A Simple Guide to Modern Cloud Management.

Hands-on 🚀

Prerequisites

Clone the Hands-on GitHub Repository

git clone [email protected]:mangadev-dev-to/gitops-argocd.git
Enter fullscreen mode Exit fullscreen mode

Folder Structure

├── argocd
├── gitops
├── kind
└── rendered-resources
Enter fullscreen mode Exit fullscreen mode
  • gitops: The source of truth for all application manifests (typically stored in a separate repository).
  • kind: Contains local cluster configuration.
  • argocd: Contains ArgoCD configuration, from installation to resources.
  • rendered-resources: Contains the rendered ArgoCD manifests.

Create a Kind Cluster

kind create cluster --config=kind/kind.yaml --name=gitops-argocd
Enter fullscreen mode Exit fullscreen mode

Install ArgoCD: Install ArgoCD on your Kind cluster

# Ensure you're in the Kind cluster. This command should return 'kind-gitops-argocd' context.
kubectl config current-context

# Add the ArgoCD Helm repository
helm repo add argo https://argoproj.github.io/argo-helm

# Update the local Helm chart cache
helm repo update

# Install the ArgoCD Helm chart
helm install argocd --namespace argocd --create-namespace argo/argo-cd

# Create context for the ArgoCD namespace
kubectl config set-context kind-ns-argocd --namespace argocd --cluster kind-gitops-argocd --user kind-gitops-argocd

# Set the current context for the argocd namespace
kubectl config use-context kind-ns-argocd

# Grant cluster-admin role to the ArgoCD service account (use with caution in production)
kubectl apply -f argocd/rbac/argocd-svc-account-clusterrole-admin-binding.yaml

# Get the admin password via kubectl
kubectl get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d

# Access the ArgoCD UI (http://localhost:8080) using 'admin' as the username and the copied password
kubectl port-forward service/argocd-server 8080:443
Enter fullscreen mode Exit fullscreen mode

Prepare ArgoCD Resources: Set up ArgoCD Projects and Applications

# Render Helm Charts
./resource-helm-template-generator.sh car
./resource-helm-template-generator.sh truck
./resource-helm-template-generator.sh train

# Validate if the rendered Helm Charts are present in the 'rendered-resources' folder
Enter fullscreen mode Exit fullscreen mode

Create ArgoCD Resources: Apply the rendered resources

# Create the rendered Helm Charts
kubectl apply -f rendered-resources/

# Validate in the ArgoCD UI (http://localhost:8080) that the applications are up and running
Enter fullscreen mode Exit fullscreen mode

Update Application: Make changes to the application and let ArgoCD handle reconciliation

  1. Open the manifest gitops/car/app-1/deployment.yaml and change the replicas value to 2 on line 38.
  2. Save and push the changes to GitHub repository.
  3. Wait 3 minutes or manually sync the car-app-1 in ArgoCD.
  4. Verify that the car application now has two pods running.

Before Changes:

After Changes:

Final Thoughts

  • For simplicity, we kept the GitOps application manifests in the same repository and made changes manually, without using automation tools like GitHub Actions, Azure DevOps, or Jenkins.
  • ArgoCD offers an intuitive UI, enabling development teams to manage their applications effortlessly.
  • With just a few steps, you've enhanced application management, improving robustness, observability, and maintainability using a declarative approach.

That's it! Happy coding! 🎉🎉🎉

argocd Article's
30 articles in total
Favicon
CloudOps Challenge - Real-Time Projects
Favicon
Automating PostgreSQL Clusters: A Guide to Deployment with ArgoCD and CloudNativePG
Favicon
Crafting a Multi-Environment CI/CD Pipeline: A Hands-on Guide with Tekton and ArgoCD
Favicon
Leveraging ArgoCD for Kubernetes Applications: Implementation, Use Cases, and Best Practices
Favicon
Make ArgoCD authenticated using AWS Cognito
Favicon
Crossplane + ArgoCD: A Perfect Match for Kubernetes Automation
Favicon
GitOps + ArgoCD: A Perfect Match for Kubernetes Continuous Delivery
Favicon
CI/CD Pipeline for a Next.js Application Using GitHub Actions, ArgoCD, and MicroK8s
Favicon
A Production Ready EKS Deployment with GitOps - Part 1 - Introduction
Favicon
Deploy Github Actions y Argo CD
Favicon
Implemeting GitOps with Argocd
Favicon
Deploying Applications with GitHub Actions and ArgoCD to EKS: Best Practices and Techniques
Favicon
Day 23 of my 90-day Devops journey: Embracing GitOps Principles with Argo CD with Hello world project
Favicon
Deploying applications to Kubernetes with Gitlab CI/CD,Helm Charts and ArgoCD
Favicon
Cómo Instalar Argo CD
Favicon
Continuous Deployment to Kubernetes with ArgoCD
Favicon
Rendering the TRUE Argo CD diff on your PRs
Favicon
ArgoCD Getting Started - Hands On
Favicon
Integrating Multiple EKS Clusters with ArgoCD for Simplifying Kubernetes Operations
Favicon
Managing database migrations in ArgoCD 🐙
Favicon
ArgoCD Deployment on RKE2 with Cilium Gateway API
Favicon
Beginner's Guide to Argo CD: Streamlining Kubernetes Deployments with GitOps
Favicon
Building a CD Pipeline with GitOps and ArgoCD 🛠️
Favicon
Introducing ArgoCD: A GitOps Approach to Continuous Deployment
Favicon
Kustomize and Helm together
Favicon
GitOps no Amazon EKS com ArgoCD [Lab Session]
Favicon
Using CDK8S, YTT or Gomplate with ArgoCD Through "Config Management Plugins"
Favicon
Dominando GitOps con ArgoCD: Una guía práctica para kubernetes
Favicon
Extending GitOps: Effortless continuous integration and deployment on Kubernetes
Favicon
Your first ARGO-CD

Featured ones: