GitOps-workflow inrichten met ArgoCD
Automatisch deployen vanuit uw Git-repository naar uw Proxy Kubernetes-cluster.
Tip
Met GitOps wordt uw Git-repository de single source of truth voor uw infrastructuur. Geschatte leestijd: 18 minuten.
Wat is GitOps?
GitOps is een operationeel model waarbij:
- De gewenste staat van uw cluster in Git staat
- ArgoCD continu synchroniseert tussen Git en uw cluster
- Elke wijziging traceerbaar is via Git history
- Rollbacks simpelweg een
git revertzijn
Vereisten
- Een draaiend Proxy Platform cluster (handleiding)
- ArgoCD ingeschakeld op uw cluster (via Control Panel → Add-ons)
- Een Git-repository met uw Kubernetes manifests
Stap 1: ArgoCD toegang configureren
ArgoCD UI openen
Open de ArgoCD UI via de Control Panel: Cluster → Add-ons → ArgoCD → Open UI.
CLI installeren
Terminal
# macOS
brew install argocd
# Linux
curl -sSL -o argocd https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
chmod +x argocd && sudo mv argocd /usr/local/bin/Inloggen via CLI
Terminal
argocd login argocd.mijn-cluster.proxy.nl \
--username admin \
--password <initial-password>Stap 2: Repository koppelen
Terminal
argocd repo add https://gitlab.example.com/mijn-org/k8s-manifests.git \
--username deploy-token \
--password <token>Warning
Gebruik altijd een deploy token of SSH key in plaats van persoonlijke credentials voor repository-toegang.
Stap 3: Repository structuur
Organiseer uw repository met een duidelijke structuur:
Repository structuur
k8s-manifests/
├── base/
│ ├── deployment.yaml
│ ├── service.yaml
│ ├── ingress.yaml
│ └── kustomization.yaml
├── overlays/
│ ├── staging/
│ │ ├── kustomization.yaml
│ │ └── replicas-patch.yaml
│ └── production/
│ ├── kustomization.yaml
│ ├── replicas-patch.yaml
│ └── resources-patch.yaml
└── argocd/
└── application.yamlStap 4: ArgoCD Application aanmaken
argocd/application.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: mijn-app-productie
namespace: argocd
spec:
project: default
source:
repoURL: https://gitlab.example.com/mijn-org/k8s-manifests.git
path: overlays/production
targetRevision: main
destination:
server: https://kubernetes.default.svc
namespace: mijn-app
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=trueTerminal
kubectl apply -f argocd/application.yamlStap 5: Workflow testen
Maak een wijziging
Terminal
# Pas de replica count aan
cd overlays/production
cat > replicas-patch.yaml << 'EOF'
apiVersion: apps/v1
kind: Deployment
metadata:
name: mijn-app
spec:
replicas: 5
EOFPush naar Git
Terminal
git add .
git commit -m "feat: scale to 5 replicas"
git push origin mainVerifieer synchronisatie
ArgoCD detecteert de wijziging binnen 3 minuten (of direct bij webhook):
Terminal
argocd app get mijn-app-productieWebhook configureren (optioneel)
Voor directe synchronisatie bij elke push:
GitLab Webhook URL
https://argocd.mijn-cluster.proxy.nl/api/webhookNote
Configureer de webhook in GitLab via Settings → Webhooks met de events: Push en Tag push.
Volgende stappen
- Cluster architectuur — Begrijp de onderliggende infrastructuur
- API Referentie — Automatiseer met de Platform API
Last updated on