GitOps using Argo CD
When it comes to GitOps, Argo CD is an established approach for consuming Kubernetes objects from a Git repository.
This guide is using the following repository as reference: https://github.com/rigdev/argocd-demo
Configuring Rig
The Rig Platform will by default apply the Kubernetes objects directly through the Kubernetes API. However, for a GitOps setup, this behavior can be changed. The first step is thus to follow the guide here to write the changes to your Git repository instead of Kubernetes directly.
When configuring the cluster, here is an example of using our GitHub repository:
rig:
clusters:
my-cluster:
git:
url: https://github.com/rigdev/argocd-demo
branch: main
path_prefix: "apps/{{ .Cluster.Name }}/{{ .Project.Name }}/{{ .Capsule.Name }}/"
The path_prefix
is a template for where Capsule-specific resources will be located - this will be important later when configuring Argo CD.
It's recommended to include the cluster-name in the path_prefix
path, to allow your repository to be consumed by multiple cluster.
Setup Repo in Argo CD
In Argo CD, using either the Dashboard, CLI or Kubernetes resources directly, configure you repository. It's recommended to configured it with GitHub webhooks, to accelerate the time from making changes until Argo CD picks them up. Without webhooks, the default delay is 3 minutes.


Create Rig Application
Next is to create an Application in Argo CD. The Application should be a "directory" type, that can consume raw Kubernetes manifests from a directory - in this case a directory in our repository.


It's also possible to utilize the Kustomize Application type, as described here.
The raw Application should look similar to this:
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: rig
spec:
destination:
server: https://kubernetes.default.svc
source:
path: apps/
repoURL: https://github.com/rigdev/argocd-demo.git
targetRevision: HEAD
directory:
recurse: true
include: '*'
project: default
syncPolicy:
automated:
prune: true
The path we are interested in, should match our path_prefix
from above. Anything within this subpath will be included, and in our case that would
indeed be anything designated my-cluster
cluster.
A few additional notes:
recurse
enables recursive mode, which means all .yaml files in all sub-folders will be consumed.prune
is required to ensure Argo CD deletes resources, as they are deleted by the Rig Platform.
With that in place, the Application should now be able to sync the repository and apply our Capsule resources.


Deploying from Rig
As seen in the video below, changes to a Capsule are now stored in a git repository, that Argo CD are picking up and applying for you.

