From 2b2818a412e291c7cce043970d84c786f499d208 Mon Sep 17 00:00:00 2001 From: nutcas3 Date: Fri, 17 Apr 2026 17:20:15 +0300 Subject: [PATCH] feat: Add HPA and VPA autoscaling configurations for telecom platform components - Add api-server HPA with 2-10 replicas scaling on CPU (70%), memory (80%), HTTP requests (100/s), queue messages (1000) - Add charging-engine HPA with 2-8 replicas scaling on CPU (75%), memory (85%), billing events (50/s) - Add packet-gateway HPA with 2-12 replicas scaling on CPU (60%), memory (75%), packets (1000/s) - Add web-dashboard HPA with 1-6 replicas scaling on CPU (70%), memory (80%), active sessions (50) - Configure H --- deployments/autoscaling/hpa.yaml | 218 +++++++++++++++++++++++++++++++ deployments/autoscaling/vpa.yaml | 107 +++++++++++++++ 2 files changed, 325 insertions(+) create mode 100644 deployments/autoscaling/hpa.yaml create mode 100644 deployments/autoscaling/vpa.yaml diff --git a/deployments/autoscaling/hpa.yaml b/deployments/autoscaling/hpa.yaml new file mode 100644 index 0000000..5a01a44 --- /dev/null +++ b/deployments/autoscaling/hpa.yaml @@ -0,0 +1,218 @@ +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: api-server-hpa + namespace: telecom-platform + labels: + app.kubernetes.io/name: api-server-hpa + app.kubernetes.io/component: autoscaling + app.kubernetes.io/part-of: telecom-platform +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: api-server + minReplicas: 2 + maxReplicas: 10 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 70 + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: 80 + - type: Pods + pods: + metric: + name: http_requests_per_second + target: + type: AverageValue + averageValue: "100" + - type: Object + object: + metric: + name: queue_messages + describedObject: + apiVersion: v1 + kind: Service + name: api-server + target: + type: Value + value: "1000" + behavior: + scaleDown: + stabilizationWindowSeconds: 300 + policies: + - type: Percent + value: 10 + periodSeconds: 60 + - type: Pods + value: 2 + periodSeconds: 60 + selectPolicy: Min + scaleUp: + stabilizationWindowSeconds: 60 + policies: + - type: Percent + value: 50 + periodSeconds: 60 + - type: Pods + value: 4 + periodSeconds: 60 + selectPolicy: Max +--- +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: charging-engine-hpa + namespace: telecom-platform + labels: + app.kubernetes.io/name: charging-engine-hpa + app.kubernetes.io/component: autoscaling + app.kubernetes.io/part-of: telecom-platform +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: charging-engine + minReplicas: 2 + maxReplicas: 8 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 75 + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: 85 + - type: Pods + pods: + metric: + name: billing_events_per_second + target: + type: AverageValue + averageValue: "50" + behavior: + scaleDown: + stabilizationWindowSeconds: 300 + policies: + - type: Percent + value: 10 + periodSeconds: 60 + scaleUp: + stabilizationWindowSeconds: 60 + policies: + - type: Percent + value: 100 + periodSeconds: 60 +--- +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: packet-gateway-hpa + namespace: telecom-platform + labels: + app.kubernetes.io/name: packet-gateway-hpa + app.kubernetes.io/component: autoscaling + app.kubernetes.io/part-of: telecom-platform +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: packet-gateway + minReplicas: 2 + maxReplicas: 12 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 60 + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: 75 + - type: Pods + pods: + metric: + name: packets_per_second + target: + type: AverageValue + averageValue: "1000" + behavior: + scaleDown: + stabilizationWindowSeconds: 300 + policies: + - type: Percent + value: 15 + periodSeconds: 60 + scaleUp: + stabilizationWindowSeconds: 30 + policies: + - type: Percent + value: 200 + periodSeconds: 60 +--- +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: web-dashboard-hpa + namespace: telecom-platform + labels: + app.kubernetes.io/name: web-dashboard-hpa + app.kubernetes.io/component: autoscaling + app.kubernetes.io/part-of: telecom-platform +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: web-dashboard + minReplicas: 1 + maxReplicas: 6 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 70 + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: 80 + - type: Pods + pods: + metric: + name: active_sessions + target: + type: AverageValue + averageValue: "50" + behavior: + scaleDown: + stabilizationWindowSeconds: 300 + policies: + - type: Percent + value: 20 + periodSeconds: 60 + scaleUp: + stabilizationWindowSeconds: 60 + policies: + - type: Percent + value: 100 + periodSeconds: 60 diff --git a/deployments/autoscaling/vpa.yaml b/deployments/autoscaling/vpa.yaml new file mode 100644 index 0000000..33ec727 --- /dev/null +++ b/deployments/autoscaling/vpa.yaml @@ -0,0 +1,107 @@ +apiVersion: autoscaling.k8s.io/v1 +kind: VerticalPodAutoscaler +metadata: + name: api-server-vpa + namespace: telecom-platform + labels: + app.kubernetes.io/name: api-server-vpa + app.kubernetes.io/component: autoscaling + app.kubernetes.io/part-of: telecom-platform +spec: + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: api-server + updatePolicy: + updateMode: "Auto" + resourcePolicy: + containerPolicies: + - containerName: api-server + minAllowed: + cpu: 100m + memory: 128Mi + maxAllowed: + cpu: 2000m + memory: 2Gi + controlledResources: ["cpu", "memory"] +--- +apiVersion: autoscaling.k8s.io/v1 +kind: VerticalPodAutoscaler +metadata: + name: charging-engine-vpa + namespace: telecom-platform + labels: + app.kubernetes.io/name: charging-engine-vpa + app.kubernetes.io/component: autoscaling + app.kubernetes.io/part-of: telecom-platform +spec: + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: charging-engine + updatePolicy: + updateMode: "Auto" + resourcePolicy: + containerPolicies: + - containerName: charging-engine + minAllowed: + cpu: 100m + memory: 128Mi + maxAllowed: + cpu: 1500m + memory: 1.5Gi + controlledResources: ["cpu", "memory"] +--- +apiVersion: autoscaling.k8s.io/v1 +kind: VerticalPodAutoscaler +metadata: + name: packet-gateway-vpa + namespace: telecom-platform + labels: + app.kubernetes.io/name: packet-gateway-vpa + app.kubernetes.io/component: autoscaling + app.kubernetes.io/part-of: telecom-platform +spec: + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: packet-gateway + updatePolicy: + updateMode: "Auto" + resourcePolicy: + containerPolicies: + - containerName: packet-gateway + minAllowed: + cpu: 100m + memory: 128Mi + maxAllowed: + cpu: 3000m + memory: 3Gi + controlledResources: ["cpu", "memory"] +--- +apiVersion: autoscaling.k8s.io/v1 +kind: VerticalPodAutoscaler +metadata: + name: web-dashboard-vpa + namespace: telecom-platform + labels: + app.kubernetes.io/name: web-dashboard-vpa + app.kubernetes.io/component: autoscaling + app.kubernetes.io/part-of: telecom-platform +spec: + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: web-dashboard + updatePolicy: + updateMode: "Auto" + resourcePolicy: + containerPolicies: + - containerName: web-dashboard + minAllowed: + cpu: 50m + memory: 64Mi + maxAllowed: + cpu: 1000m + memory: 1Gi + controlledResources: ["cpu", "memory"]