CodexBloom - Programming Q&A Platform

OCI Kubernetes Cluster Not Scaling Pods Automatically Under Load Even with Horizontal Pod Autoscaler Configured

👀 Views: 1 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-07
oracle-cloud kubernetes autoscaling yaml

I've hit a wall trying to I'm running a Kubernetes cluster on Oracle Cloud Infrastructure (OCI) version 1.21, and I've set up a Horizontal Pod Autoscaler (HPA) to manage the scaling of my deployment based on CPU utilization. However, I'm noticing that when the load increases, the pods aren't scaling as expected. I've configured my HPA like this: ```yaml apiVersion: autoscaling/v2beta2 kind: HorizontalPodAutoscaler metadata: name: my-app-hpa spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: my-app minReplicas: 2 maxReplicas: 10 metrics: - type: Pods pods: metric: name: cpu target: type: AverageValue averageValue: 500m ``` I confirmed that the metrics server is running and functioning correctly by checking with `kubectl get --raw /apis/metrics.k8s.io/v1beta1/pods`. The metrics look accurate, and I'm seeing CPU usage spike well above 500m under load, but the HPA isn't scaling the deployment as expected. I also checked the events with `kubectl describe hpa my-app-hpa`, and I see a warning that says `failed to get metrics: no metrics available for pods`. I've tried the following troubleshooting steps: 1. Verified that the `metrics-server` is correctly deployed and running without errors. 2. Ensured that the service account has the correct permissions to access metrics. 3. Increased the CPU usage threshold in the HPA to see if that would trigger scaling. 4. Checked the resource requests and limits in my deployment to ensure they are appropriately set. Here's a snippet of my deployment configuration: ```yaml apiVersion: apps/v1 kind: Deployment metadata: name: my-app spec: replicas: 2 selector: matchLabels: app: my-app template: metadata: labels: app: my-app spec: containers: - name: my-app image: my-app-image:latest resources: requests: cpu: 250m memory: 512Mi limits: cpu: 1 memory: 1Gi ``` Despite all this, the HPA is still not triggering any scaling events. Has anyone faced a similar scenario or have any insights on what might be going wrong? I appreciate any help and suggestions! I'm working on a CLI tool that needs to handle this. Thanks in advance!