Skip to content

Conversation

@zhhray
Copy link
Contributor

@zhhray zhhray commented Jan 21, 2026

How to Auto-Scale Applications via HPA Based on Custom HTTP Metrics

Summary by CodeRabbit

  • Documentation
    • New comprehensive guide for auto-scaling Kubernetes apps with HPA using custom HTTP metrics. Covers architecture, prerequisites, end-to-end deployment, Prometheus and adapter configuration, metric verification, scripted load-testing with expected outcomes, observed scale behavior, and cleanup steps.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 21, 2026

Walkthrough

A new documentation guide explaining how to auto-scale Kubernetes apps with HPA using custom HTTP metrics via Prometheus and Prometheus Adapter; includes end-to-end setup, manifests, metric verification, and load-test validation.

Changes

Cohort / File(s) Summary
Kubernetes Auto-Scaling Documentation
docs/en/solutions/How_to_Auto_Scale_Apps_via_HPA_Based_on_Custom_HTTP_Metrics.md
Added comprehensive guide: demo app emitting Prometheus metrics, Prometheus & Prometheus Adapter configuration, Kubernetes manifests (Deployment, Service, ServiceMonitor, HPA), CLI build/push steps, metric verification commands, load-test workflow, and cleanup instructions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • fanzy618
  • tyzhou111

Poem

🐰 A doc hops out with metrics to show,
Pods rise and fall with each HTTP flow,
Prometheus hums, the adapter replies,
HPA counts beats beneath cloud-swept skies,
Celebrate scaling — a rabbit's small cheer! 🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding documentation about auto-scaling applications via HPA based on custom HTTP metrics, which matches the file added and PR objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In
`@docs/en/solutions/How_to_Auto_Scale_Apps_via_HPA_Based_on_Custom_HTTP_Metrics.md`:
- Around line 167-168: Replace the awkward sentence "Scp
`deploy/load-test-scaling.sh` to the master node of k8s cluster which the
metrics-app is running." with a tightened, correct version such as: "scp
deploy/load-test-scaling.sh to the master node of the Kubernetes cluster where
the metrics-app is running." Ensure lowercase "scp", use "Kubernetes cluster",
and change "which" to "where" for clarity.
- Around line 101-108: Add a brief clarifying note after the two kubectl apply
commands stating that both referenced manifests (deploy/resources.yaml and
deploy/servicemonitor.yaml) already set metadata.namespace: demo-ns, so you do
not need to pass -n demo-ns to kubectl; mention the exact field name
metadata.namespace: demo-ns to avoid confusion for readers about namespace
scope.
🧹 Nitpick comments (1)
docs/en/solutions/How_to_Auto_Scale_Apps_via_HPA_Based_on_Custom_HTTP_Metrics.md (1)

13-27: Fix markdown list indentation to satisfy linting.

Markdownlint flags MD007 across these lists; the current indentation is inconsistent and will fail CI if linting is enforced.

♻️ Example fix (apply similarly to other lists)
-  - Developing a demo application that exposes Prometheus metrics for HTTP request count.
-  - Containerizing the application and deploying it to Kubernetes.
-  - Configuring Prometheus to scrape metrics.
-  - Setting up Prometheus Adapter to expose custom metrics to Kubernetes.
-  - Creating Horizontal Pod Autoscaler (HPA) that uses custom HTTP metrics for scaling decisions.
-  - Validating the autoscaling behavior with load testing.
+- Developing a demo application that exposes Prometheus metrics for HTTP request count.
+- Containerizing the application and deploying it to Kubernetes.
+- Configuring Prometheus to scrape metrics.
+- Setting up Prometheus Adapter to expose custom metrics to Kubernetes.
+- Creating Horizontal Pod Autoscaler (HPA) that uses custom HTTP metrics for scaling decisions.
+- Validating the autoscaling behavior with load testing.

Also applies to: 78-87, 95-100

Comment on lines 101 to 108
Deploy the application resources to Kubernetes:
```bash
kubectl apply -f deploy/resources.yaml
```
Deploy the Prometheus ServiceMonitor Configuration:
```bash
kubectl apply -f deploy/servicemonitor.yaml
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

find . -type f -name "*.md" | grep -i "hpa\|autoscale" | head -10

Repository: alauda/knowledge

Length of output: 276


🏁 Script executed:

git ls-files | grep -E "deploy.*\.yaml|resources\.yaml|servicemonitor\.yaml"

Repository: alauda/knowledge

Length of output: 78


🏁 Script executed:

cat -n ./docs/en/solutions/How_to_Auto_Scale_Apps_via_HPA_Based_on_Custom_HTTP_Metrics.md | sed -n '95,115p'

Repository: alauda/knowledge

Length of output: 950


🏁 Script executed:

find . -type d -name deploy | head -10

Repository: alauda/knowledge

Length of output: 42


🏁 Script executed:

find . -type f \( -name "*resources.yaml" -o -name "*servicemonitor.yaml" \) 2>/dev/null

Repository: alauda/knowledge

Length of output: 42


🏁 Script executed:

rg "deploy-ns|demo-ns" --type md | head -20

Repository: alauda/knowledge

Length of output: 994


🏁 Script executed:

cat -n ./docs/en/solutions/How_to_Auto_Scale_Apps_via_HPA_Based_on_Custom_HTTP_Metrics.md | sed -n '1,100p'

Repository: alauda/knowledge

Length of output: 4514


🏁 Script executed:

cat -n ./docs/en/solutions/How_to_Auto_Scale_Apps_via_HPA_Based_on_Custom_HTTP_Metrics.md | sed -n '60,90p'

Repository: alauda/knowledge

Length of output: 1395


🏁 Script executed:

rg "Step 3|namespace:|demo-ns" ./docs/en/solutions/How_to_Auto_Scale_Apps_via_HPA_Based_on_Custom_HTTP_Metrics.md -A 2 -B 2

Repository: alauda/knowledge

Length of output: 1065


🏁 Script executed:

cat -n ./docs/en/solutions/How_to_Auto_Scale_Apps_via_HPA_Based_on_Custom_HTTP_Metrics.md | sed -n '100,180p'

Repository: alauda/knowledge

Length of output: 3191


🏁 Script executed:

rg "apiVersion|kind|metadata" ./docs/en/solutions/How_to_Auto_Scale_Apps_via_HPA_Based_on_Custom_HTTP_Metrics.md -A 3 | head -60

Repository: alauda/knowledge

Length of output: 785


🌐 Web query:

site:github.com/zhhray/http-metrics-exporter deploy resources.yaml namespace

💡 Result:

I found the repo — the deploy manifest uses the namespace demo-ns (the README shows kubectl examples referencing deploy/resources.yaml and metrics in namespace "demo-ns"). [1]

Source:

  • zhhray/http-metrics-exporter (README / deploy instructions). [1]

🏁 Script executed:

rg "metadata:|namespace:" ./docs/en/solutions/How_to_Auto_Scale_Apps_via_HPA_Based_on_Custom_HTTP_Metrics.md -B 2 -A 1 | head -40

Repository: alauda/knowledge

Length of output: 165


🏁 Script executed:

cat -n ./docs/en/solutions/How_to_Auto_Scale_Apps_via_HPA_Based_on_Custom_HTTP_Metrics.md | tail -50

Repository: alauda/knowledge

Length of output: 4081


Add clarifying note: the provided manifests already include metadata.namespace: demo-ns.

The referenced GitHub manifests (deploy/resources.yaml and deploy/servicemonitor.yaml) already specify metadata.namespace: demo-ns, so the kubectl apply commands will correctly target the demo-ns namespace without requiring the -n demo-ns flag. Adding a brief note here would clarify this for readers and prevent confusion about namespace scope.

Suggested addition
Deploy the application resources to Kubernetes:
+ (Note: The manifests already specify `metadata.namespace: demo-ns`)
  ```bash
  kubectl apply -f deploy/resources.yaml
</details>

<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
Deploy the application resources to Kubernetes:
  (Note: The manifests already specify `metadata.namespace: demo-ns`)
🤖 Prompt for AI Agents
In
`@docs/en/solutions/How_to_Auto_Scale_Apps_via_HPA_Based_on_Custom_HTTP_Metrics.md`
around lines 101 - 108, Add a brief clarifying note after the two kubectl apply
commands stating that both referenced manifests (deploy/resources.yaml and
deploy/servicemonitor.yaml) already set metadata.namespace: demo-ns, so you do
not need to pass -n demo-ns to kubectl; mention the exact field name
metadata.namespace: demo-ns to avoid confusion for readers about namespace
scope.

Comment on lines +167 to +168
Scp `deploy/load-test-scaling.sh` to the master node of k8s cluster which the metrics-app is running.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Tighten the SCP sentence for clarity and spelling.

“Scp” and the clause “which the metrics-app is running” read awkwardly.

✍️ Suggested edit
-Scp `deploy/load-test-scaling.sh` to the master node of k8s cluster which the metrics-app is running.
+SCP `deploy/load-test-scaling.sh` to the master node of the k8s cluster where the metrics-app is running.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Scp `deploy/load-test-scaling.sh` to the master node of k8s cluster which the metrics-app is running.
SCP `deploy/load-test-scaling.sh` to the master node of the k8s cluster where the metrics-app is running.
🧰 Tools
🪛 LanguageTool

[grammar] ~167-~167: Ensure spelling is correct
Context: ...g.sh` to the master node of k8s cluster which the metrics-app is running. Execute th...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🤖 Prompt for AI Agents
In
`@docs/en/solutions/How_to_Auto_Scale_Apps_via_HPA_Based_on_Custom_HTTP_Metrics.md`
around lines 167 - 168, Replace the awkward sentence "Scp
`deploy/load-test-scaling.sh` to the master node of k8s cluster which the
metrics-app is running." with a tightened, correct version such as: "scp
deploy/load-test-scaling.sh to the master node of the Kubernetes cluster where
the metrics-app is running." Ensure lowercase "scp", use "Kubernetes cluster",
and change "which" to "where" for clarity.

@zhhray zhhray deployed to translate January 21, 2026 10:51 — with GitHub Actions Active
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants