70 lines
2.6 KiB
YAML
70 lines
2.6 KiB
YAML
# ArgoCD Server HA Patch via Sync Hook
|
|
# WICHTIG: Dieses Resource wird nach dem Standard-ArgoCD Deployment angewendet
|
|
# und patcht es für HA
|
|
|
|
apiVersion: batch/v1
|
|
kind: Job
|
|
metadata:
|
|
name: argocd-server-ha-patch
|
|
namespace: argocd
|
|
annotations:
|
|
# WICHTIG: Sync Hook - wird nach Deployment-Sync ausgeführt
|
|
argocd.argoproj.io/hook: PostSync
|
|
argocd.argoproj.io/hook-delete-policy: BeforeHookCreation
|
|
# Sync Wave: Nach ArgoCD Deployment (Wave 0 oder später)
|
|
argocd.argoproj.io/sync-wave: "1"
|
|
spec:
|
|
ttlSecondsAfterFinished: 300 # Job wird nach 5 Minuten gelöscht
|
|
backoffLimit: 3
|
|
template:
|
|
spec:
|
|
# WICHTIG: argocd-server ServiceAccount hat keine Rechte zum Patchen
|
|
# Wir verwenden stattdessen default ServiceAccount oder erstellen eine RBAC-Rolle
|
|
serviceAccountName: argocd-ha-patch
|
|
restartPolicy: Never
|
|
containers:
|
|
- name: kubectl
|
|
image: bitnami/kubectl:latest
|
|
command:
|
|
- /bin/sh
|
|
- -c
|
|
- |
|
|
set -e
|
|
echo "Patching argocd-server Deployment für HA..."
|
|
|
|
# Patch Replicas auf 2
|
|
kubectl patch deployment argocd-server -n argocd --type='json' -p='[
|
|
{"op": "replace", "path": "/spec/replicas", "value": 2}
|
|
]' || echo "Replicas Patch fehlgeschlagen (möglicherweise bereits 2)"
|
|
|
|
# Patch Anti-Affinity
|
|
kubectl patch deployment argocd-server -n argocd --type='json' -p='[
|
|
{
|
|
"op": "add",
|
|
"path": "/spec/template/spec/affinity",
|
|
"value": {
|
|
"podAntiAffinity": {
|
|
"requiredDuringSchedulingIgnoredDuringExecution": [
|
|
{
|
|
"labelSelector": {
|
|
"matchExpressions": [
|
|
{
|
|
"key": "app.kubernetes.io/name",
|
|
"operator": "In",
|
|
"values": ["argocd-server"]
|
|
}
|
|
]
|
|
},
|
|
"topologyKey": "kubernetes.io/hostname"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
]' || echo "Affinity Patch fehlgeschlagen"
|
|
|
|
echo "✅ ArgoCD Server HA Patch erfolgreich angewendet"
|
|
|
|
# Warte auf Rollout
|
|
kubectl rollout status deployment/argocd-server -n argocd --timeout=300s
|