Swiftorial Logo
Home
Swift Lessons
Matchups
CodeSnaps
Tutorials
Career
Resources

Argo CD for GitOps

1. Introduction

Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes. It allows users to manage their application deployments through Git repositories, ensuring that the desired state of applications is stored in Git, and automatically synchronizing the live state in Kubernetes with the desired state.

2. Key Concepts

2.1 GitOps

GitOps is a set of practices that uses Git pull requests to manage infrastructure and application configurations. It emphasizes using Git as a single source of truth.

2.2 Applications and Repositories

In Argo CD, an application refers to a Kubernetes resource that is managed by Argo CD, while a repository is a Git repository containing the Kubernetes manifests.

3. Installation

To install Argo CD, you can use the following commands:

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

Once installed, access the Argo CD API server:

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

The default username is admin. You can get the password with:

kubectl get pods -n argocd -l app.kubernetes.io/name=argocd-server -o jsonpath="{.items[0].metadata.annotations['argocd\.dex\.k8s\.io/username']}" | base64 -d

4. Configuration

To configure an application in Argo CD, you must define an Application manifest. Here is an example:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: guestbook
  namespace: argocd
spec:
  project: default
  source:
    repoURL: 'https://github.com/your-repo/guestbook.git'
    targetRevision: HEAD
    path: k8s
  destination:
    server: 'https://kubernetes.default.svc'
    namespace: default
  syncPolicy:
    automated:
      prune: true
      selfHeal: true

5. Usage

Once the application is configured, you can sync it with the Kubernetes cluster using:

argocd app sync guestbook

You can also monitor the application status through the Argo CD dashboard.

6. Best Practices

  • Use descriptive application names and maintain consistent structure in your Git repositories.
  • Implement RBAC policies to control access to the Argo CD dashboard and APIs.
  • Regularly backup your Git repositories and Argo CD configurations.
  • Use automated sync policies to ensure that your applications are always in the desired state.

7. FAQ

What is Argo CD?

Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes.

How does Argo CD work?

It compares the live state of your Kubernetes cluster against the desired state defined in Git and makes adjustments as necessary.

Can I use Argo CD with any Git repository?

Yes, Argo CD supports any Git repository, including GitHub, GitLab, and Bitbucket.