fix kube client side error
This commit is contained in:
37
apps/argocd-config/argocd-ha-patch-rbac.yaml
Normal file
37
apps/argocd-config/argocd-ha-patch-rbac.yaml
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
# RBAC für ArgoCD HA Patch Job
|
||||||
|
# WICHTIG: Job braucht Rechte zum Patchen von Deployments
|
||||||
|
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: Role
|
||||||
|
metadata:
|
||||||
|
name: argocd-ha-patch
|
||||||
|
namespace: argocd
|
||||||
|
rules:
|
||||||
|
- apiGroups: ["apps"]
|
||||||
|
resources: ["deployments"]
|
||||||
|
verbs: ["get", "patch", "update"]
|
||||||
|
- apiGroups: ["apps"]
|
||||||
|
resources: ["deployments/status"]
|
||||||
|
verbs: ["get"]
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ServiceAccount
|
||||||
|
metadata:
|
||||||
|
name: argocd-ha-patch
|
||||||
|
namespace: argocd
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: RoleBinding
|
||||||
|
metadata:
|
||||||
|
name: argocd-ha-patch
|
||||||
|
namespace: argocd
|
||||||
|
roleRef:
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
||||||
|
kind: Role
|
||||||
|
name: argocd-ha-patch
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: argocd-ha-patch
|
||||||
|
namespace: argocd
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
# ArgoCD Server HA Patch
|
|
||||||
# WICHTIG: Nur Deployment-Patch, PDB ist separate Resource
|
|
||||||
|
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: argocd-server
|
|
||||||
namespace: argocd
|
|
||||||
spec:
|
|
||||||
replicas: 2 # HA: Mindestens 2 Replicas für Ausfallsicherheit
|
|
||||||
template:
|
|
||||||
spec:
|
|
||||||
affinity:
|
|
||||||
podAntiAffinity:
|
|
||||||
# Hard Rule: Pods müssen auf verschiedenen Nodes laufen
|
|
||||||
requiredDuringSchedulingIgnoredDuringExecution:
|
|
||||||
- labelSelector:
|
|
||||||
matchExpressions:
|
|
||||||
- key: app.kubernetes.io/name
|
|
||||||
operator: In
|
|
||||||
values:
|
|
||||||
- argocd-server
|
|
||||||
topologyKey: kubernetes.io/hostname
|
|
||||||
69
apps/argocd-config/argocd-server-ha-sync-hook.yaml
Normal file
69
apps/argocd-config/argocd-server-ha-sync-hook.yaml
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
# 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
|
||||||
@@ -4,10 +4,6 @@ resources:
|
|||||||
- external-secret.yaml
|
- external-secret.yaml
|
||||||
- argocd-cm.yaml
|
- argocd-cm.yaml
|
||||||
- argocd-rbac-cm.yaml
|
- argocd-rbac-cm.yaml
|
||||||
|
- argocd-ha-patch-rbac.yaml # HA: RBAC für Patch Job
|
||||||
- argocd-server-pdb.yaml # HA: Pod Disruption Budget
|
- argocd-server-pdb.yaml # HA: Pod Disruption Budget
|
||||||
|
- argocd-server-ha-sync-hook.yaml # HA: Sync Hook patcht Deployment nach Installation
|
||||||
# WICHTIG: patchesStrategicMerge für Deployment Patch
|
|
||||||
# Der Patch muss nur die zu ändernden Felder enthalten
|
|
||||||
# Container-Spezifikation wird vom Original übernommen
|
|
||||||
patchesStrategicMerge:
|
|
||||||
- argocd-server-ha-patch.yaml
|
|
||||||
Reference in New Issue
Block a user