Optimizing Resource Limits and Pod Distribution for ArgoCD
Optimizing Resource Limits and Pod Distribution for ArgoCD Overview This guide details the process of optimizing an ArgoCD deployment in Kubernetes by implementing proper resource limits and ensuring optimal pod distribution across worker nodes. These optimizations enhance reliability, performance, and high availability of the ArgoCD installation. Initial Environment Analysis Cluster Configuration Kubernetes Cluster (K3s v1.31.6+k3s1) Architecture: 1 master node (control plane) 2 worker nodes Initial state: Pods distributed across all nodes including master Master Node Protection Implementing Control Plane Isolation # Adding taint to master node kubectl taint nodes <master-node> node-role.kubernetes.io/control-plane=:NoSchedule Purpose of Master Node Taint Prevents regular workloads from scheduling on the control plane Reserves master node resources for critical cluster operations Enforces best practices for Kubernetes architecture Resource Limits Configuration Resource Allocation by Component Application Controller resources: requests: cpu: 100m memory: 128Mi limits: cpu: 500m memory: 512Mi API Server resources: requests: cpu: 50m memory: 64Mi limits: cpu: 200m memory: 128Mi Repository Server resources: requests: cpu: 50m memory: 64Mi limits: cpu: 200m memory: 256Mi Dex Server resources: requests: cpu: 50m memory: 128Mi limits: cpu: 200m memory: 256Mi Redis resources: requests: cpu: 50m memory: 32Mi limits: cpu: 100m memory: 64Mi ApplicationSet Controller resources: requests: cpu: 50m memory: 32Mi limits: cpu: 200m memory: 128Mi Notifications Controller resources: requests: cpu: 50m memory: 32Mi limits: cpu: 100m memory: 128Mi Pod Distribution Strategy Anti-Affinity Rules affinity: podAntiAffinity: preferredDuringSchedulingIgnoredDuringExecution: - weight: 100 podAffinityTerm: labelSelector: matchExpressions: - key: app.kubernetes.io/name operator: In values: - <component-name> topologyKey: kubernetes.io/hostname Final Pod Distribution Worker Node 1: argocd-repo-server argocd-server Worker Node 2: argocd-application-controller argocd-applicationset-controller argocd-dex-server argocd-notifications-controller argocd-redis Optimization Results Resource Management Benefits Predictable resource usage Prevention of resource contention Efficient resource allocation Protection against memory/CPU exhaustion High Availability Improvements Proper workload distribution Enhanced fault tolerance Better resource utilization Reduced single point of failure risk Performance Metrics CPU usage maintained within defined limits Memory consumption optimized Improved response times Better overall cluster stability Monitoring and Maintenance Health Checks # View pod distribution kubectl get pods -n argocd -o wide # Check resource usage kubectl top pods -n argocd Resource Adjustment Monitor resource usage and adjust limits based on: ...