DEV Community

Cover image for Setup GitOps with ArgoCD
Cheulong Sear
Cheulong Sear

Posted on

Setup GitOps with ArgoCD

  • GitOps is a set of practices for managing infrastructure and application configurations to expand upon existing processes and improve the application lifecycle.

  • ArgoCD is a declarative, GitOps continuous delivery tool for Kubernetes. It does this by comparing the config repo to desired state.

Benefit

  • Declarative GtOps Tool
  • Kubernetes Native Continous Deployment
  • Disaster Recovery
  • Control Multiple Clusters

Prerequisites

  • Kubernetes
  • Configuration Repository

Here is the common pipeline that companies to use with ArgoCD

argo

Setup ArgoCD

Create namespace and apply the argocd manifest installation file

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

Access ArgoCD GUI

kubectl port-forward service/argocd-server -n argocd 8080:443
Enter fullscreen mode Exit fullscreen mode

then goto localhost:8080

argocd1

username: admin

to get password, you need to go back to command line and type

kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
Enter fullscreen mode Exit fullscreen mode

now you will see the dashboard

argodashboard

Example

Now, I will show you how to use ArgoCD in a small helm chart project.
Usually, there are at least 2 repos for application and deployment.
In this example, I have a nodejs repo and a k8s repo.

repos

in application repo

repo

in k8s repo

repo1

Workflow

graph

1.Add k8s repo to ArgoCD to monitor when it is changed to update the deployment

argodah

complete the detail of the app and repo

sid1

sdie2

hel1

click create

create

v1

2.When user commit or merge to main branch, the github action will build the new docker image and push it to dockerhub

change

cicddocker

dockerhub

3.After push successfully, the same pipeline will update the image tag number in k8s repo

manifest

ui

4.ArgoCD detects the change in k8s repo and apply the new manifest from the repo

ui1

diagram

Code used in this article

Keep Learning

(back to top)

Leave a comment if you have any questions.

===========
Please keep in touch
Portfolio
Linkedin
Github
Youtube

Top comments (0)