ArgoCD ​
To deploy apps on kubernetes, please welcome ArgoCD !
ArgoCD helps you to manage the lifecycle of your workload automatically. Basically, I have 1 monorepo which contains all of my helm chart applications and 1 repository which contains argocd manifest.
Inside the argocd manifest, I declare an ApplicationSet
which will handle the deployment of all applications.
Here is an example of ApplicationSet
deploying all helm charts under folder kubernetes/apps/**
from the repo https://gitlab.local/infrastructure/kubernetes/helm-charts.git
.
TIP
Note that I use also argocd-image-updater component which will automatically update the version based on latest tag.
yaml
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: default-apps
namespace: argocd
spec:
goTemplate: true
goTemplateOptions: ["missingkey=error"]
ignoreApplicationDifferences:
- jqPathExpressions:
- .spec.source.helm.parameters
templatePatch: |
metadata:
annotations:
{{- if eq .path.basename "frigate" }}
argocd-image-updater.argoproj.io/write-back-method: argocd
argocd-image-updater.argoproj.io/image-list: frigate=ghcr.io/blakeblackshear/frigate
argocd-image-updater.argoproj.io/frigate.update-strategy: newest-build
argocd-image-updater.argoproj.io/frigate.allow-tags: regexp:^\d+\.\d+\.\d+$
argocd-image-updater.argoproj.io/frigate.helm.image-tag: frigate.image.tag
{{- end }}
# See more generator type
# https://argo-cd.readthedocs.io/en/stable/operator-manual/applicationset/Generators/
generators:
- git:
repoURL: "https://gitlab.local/infrastructure/kubernetes/helm-charts.git"
revision: HEAD
directories:
- path: "kubernetes/apps/**"
template:
metadata:
name: '{{.path.basename}}'
labels:
project: "default-apps"
service: '{{.path.basename}}'
spec:
# https://argo-cd.readthedocs.io/en/stable/user-guide/sync-options/#respect-ignore-difference-configs
ignoreDifferences:
- kind: "Rollout"
jsonPointers:
- /spec/replicas
project: default-apps
source:
repoURL: https://gitlab.local/infrastructure/kubernetes/helm-charts.git
targetRevision: HEAD
path: '{{.path.path}}'
destination:
server: https://kubernetes.default.svc
namespace: '{{.path.basename}}'
syncPolicy:
automated:
prune: true
syncOptions:
- CreateNamespace=true
- RespectIgnoreDifferences=true
So the final architecture will look like this: