Skip to content

Commit be66804

Browse files
committed
Autoscaling HTTP applications on Kubernetes
Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>
1 parent 7ea1b98 commit be66804

6 files changed

Lines changed: 348 additions & 0 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
title: "Autoscaling HTTP applications on Kubernetes"
3+
4+
minutes_to_complete: 45
5+
6+
who_is_this_for: >
7+
Developers and SREs running HTTP-based workloads on Kubernetes who want to enable intelligent, event-driven autoscaling.
8+
9+
learning_objectives:
10+
- Install Kedify (KEDA build, HTTP Scaler, and Kedify Agent) via Helm
11+
- Verify that the components are running in your cluster
12+
- Deploy a sample HTTP application and test autoscaling behavior
13+
14+
prerequisites:
15+
- A running Kubernetes cluster (local or cloud)
16+
- kubectl and helm installed locally
17+
- Access to the Kedify Service dashboard (https://dashboard.kedify.io/) to obtain Organization ID and API Key — log in or create an account if you don’t have one
18+
19+
author: Zbynek Roubalik
20+
21+
### Tags
22+
skilllevels: Introductory
23+
subjects: Containers and Virtualization
24+
cloud_service_providers: Any
25+
armips:
26+
- Neoverse
27+
operatingsystems:
28+
- Linux
29+
tools_software_languages:
30+
- Kubernetes
31+
- Helm
32+
- KEDA
33+
- Kedify
34+
35+
further_reading:
36+
- resource:
37+
title: Kedify HTTP Scaler
38+
link: https://kedify.io/scalers/http
39+
type: documentation
40+
- resource:
41+
title: Kedify documentation
42+
link: https://docs.kedify.io
43+
type: documentation
44+
- resource:
45+
title: KEDA project
46+
link: https://keda.sh/
47+
type: documentation
48+
49+
50+
### FIXED, DO NOT MODIFY
51+
# =============================================================================
52+
weight: 1 # _index.md always has weight of 1 to order correctly
53+
layout: "learningpathall" # All files under learning paths have this same wrapper
54+
learning_path_main_page: "yes" # This should be surfaced when looking for related content. Only set for _index.md of learning path content.
55+
---
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
# =============================================================================
3+
# FIXED, DO NOT MODIFY THIS FILE
4+
# =============================================================================
5+
weight: 21 # Set to always be larger than the content in this path to be at the end of the navigation.
6+
title: "Next Steps" # Always the same, html page title.
7+
layout: "learningpathall" # All files under learning paths have this same wrapper for Hugo processing.
8+
---
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
---
2+
title: "HTTP Scaling for Ingress-Based Applications"
3+
weight: 3
4+
layout: "learningpathall"
5+
---
6+
7+
Use this section to get a quick, hands-on feel for Kedify HTTP autoscaling. We’ll deploy a small web service, expose it through a standard Kubernetes Ingress, and rely on Kedify’s autowiring to route traffic via its proxy so requests are measured and drive scaling.
8+
9+
Scale a real HTTP app exposed through Kubernetes Ingress using Kedify’s [kedify-http](https://docs.kedify.io/scalers/http-scaler/) scaler. You will deploy a simple app, enable autoscaling with a [ScaledObject](https://keda.sh/docs/latest/concepts/scaling-deployments/), generate load, and observe the system scale out and back in (including scale-to-zero when idle).
10+
11+
## How it works
12+
13+
With ingress autowiring enabled, Kedify automatically routes traffic through its proxy before it reaches your Service/Deployment:
14+
15+
```
16+
Ingress → kedify-proxy → Service → Deployment
17+
```
18+
19+
The [Kedify Proxy](https://docs.kedify.io/scalers/http-scaler/#kedify-proxy) gathers request metrics used by the scaler to make decisions.
20+
21+
## What you’ll deploy
22+
23+
- Deployment & Service: an HTTP server with a small response delay to simulate work
24+
- Ingress: public entry using host `application.keda`
25+
- ScaledObject: Kedify HTTP scaler with `trafficAutowire: ingress`
26+
27+
## Step 1 — Create the application and Ingress
28+
29+
Save the following as `application.yaml` and apply it:
30+
31+
```bash
32+
kubectl apply -f application.yaml
33+
```
34+
35+
```yaml
36+
# application.yaml
37+
apiVersion: apps/v1
38+
kind: Deployment
39+
metadata:
40+
name: application
41+
spec:
42+
replicas: 1
43+
selector:
44+
matchLabels:
45+
app: application
46+
template:
47+
metadata:
48+
labels:
49+
app: application
50+
spec:
51+
containers:
52+
- name: application
53+
image: ghcr.io/kedify/sample-http-server:latest
54+
imagePullPolicy: Always
55+
ports:
56+
- name: http
57+
containerPort: 8080
58+
protocol: TCP
59+
env:
60+
- name: RESPONSE_DELAY
61+
value: '0.3'
62+
---
63+
apiVersion: v1
64+
kind: Service
65+
metadata:
66+
name: application-service
67+
spec:
68+
ports:
69+
- name: http
70+
protocol: TCP
71+
port: 8080
72+
targetPort: http
73+
selector:
74+
app: application
75+
type: ClusterIP
76+
---
77+
apiVersion: networking.k8s.io/v1
78+
kind: Ingress
79+
metadata:
80+
name: application-ingress
81+
spec:
82+
rules:
83+
- host: application.keda
84+
http:
85+
paths:
86+
- path: /
87+
pathType: Prefix
88+
backend:
89+
service:
90+
name: application-service
91+
port:
92+
number: 8080
93+
```
94+
95+
Notes:
96+
- `RESPONSE_DELAY` adds ~300ms latency per request, making scaling effects easier to see.
97+
- The Ingress uses host `application.keda`. If you don’t have DNS set up, use your ingress controller’s IP with a `Host:` header (shown below).
98+
99+
## Step 2 — Enable autoscaling with Kedify
100+
101+
Save the following as `scaledobject.yaml` and apply it:
102+
103+
```bash
104+
kubectl apply -f scaledobject.yaml
105+
```
106+
107+
```yaml
108+
# scaledobject.yaml
109+
kind: ScaledObject
110+
apiVersion: keda.sh/v1alpha1
111+
metadata:
112+
name: application
113+
spec:
114+
scaleTargetRef:
115+
apiVersion: apps/v1
116+
kind: Deployment
117+
name: application
118+
cooldownPeriod: 5
119+
minReplicaCount: 0
120+
maxReplicaCount: 10
121+
fallback:
122+
failureThreshold: 2
123+
replicas: 1
124+
advanced:
125+
restoreToOriginalReplicaCount: true
126+
horizontalPodAutoscalerConfig:
127+
behavior:
128+
scaleDown:
129+
stabilizationWindowSeconds: 5
130+
triggers:
131+
- type: kedify-http
132+
metadata:
133+
hosts: application.keda
134+
pathPrefixes: /
135+
service: application-service
136+
port: '8080'
137+
scalingMetric: requestRate
138+
targetValue: '1000'
139+
granularity: 1s
140+
window: 10s
141+
trafficAutowire: ingress
142+
```
143+
144+
What the key fields do:
145+
- `type: kedify-http` — Use Kedify’s HTTP scaler.
146+
- `hosts`, `pathPrefixes` — Which requests to observe for scaling.
147+
- `service`, `port` — The Service and port receiving traffic.
148+
- `scalingMetric: requestRate` and `targetValue: 1000` — Target 1000 req/s (per granularity/window) before scaling out.
149+
- `minReplicaCount: 0` — Allows scale-to-zero when idle.
150+
- `trafficAutowire: ingress` — Lets Kedify auto-wire your Ingress to the kedify-proxy.
151+
152+
After applying, the ScaledObject will appear in the Kedify dashboard (https://dashboard.kedify.io/).
153+
154+
![Kedify Dashboard With ScaledObject](images/scaledobject.png)
155+
156+
## Step 3 — Send traffic and observe scaling
157+
158+
First, hit the app to confirm routing works. Replace the address with your ingress endpoint if needed:
159+
160+
```bash
161+
curl -I -H "Host: application.keda" http://localhost:9080
162+
```
163+
164+
You should see a 200 OK response. Next, generate sustained load. You can use `hey` (or a similar tool):
165+
166+
```bash
167+
hey -n 10000 -c 150 -host "application.keda" http://localhost:9080
168+
```
169+
170+
While the load runs, watch replicas change:
171+
172+
```bash
173+
kubectl get deploy application -w
174+
```
175+
176+
Expected behavior:
177+
- On bursty load, Kedify scales the Deployment up toward `maxReplicaCount`.
178+
- When traffic subsides, replicas scale down. After the cooldown, they can return to zero.
179+
180+
You can also observe traffic and scaling in the Kedify dashboard:
181+
182+
![Kedify Dashboard ScaledObject Detail](images/load.png)
183+
184+
## Clean up
185+
186+
```bash
187+
kubectl delete -f scaledobject.yaml
188+
kubectl delete -f application.yaml
189+
```
190+
191+
## Next steps
192+
193+
Explore the official Kedify [How-to guides](https://docs.kedify.io/how-to/) for more configurations such as Gateway API, Istio VirtualService, or OpenShift Routes.
194+
195+
### See also
196+
197+
- Kedify documentation: https://docs.kedify.io
192 KB
Loading
125 KB
Loading
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
title: "Install Kedify via Helm"
3+
weight: 2
4+
layout: "learningpathall"
5+
---
6+
7+
This page installs Kedify on your cluster using Helm. You’ll add the Kedify chart repo, install KEDA (Kedify build), the HTTP Scaler, and the Kedify Agent, then verify everything is running.
8+
9+
For more details and all installation methods, see Kedify installation docs: https://docs.kedify.io/installation
10+
11+
## Prerequisites
12+
13+
- A running Kubernetes cluster (kind, minikube, EKS, GKE, AKS, etc.)
14+
- kubectl and helm installed and configured to talk to your cluster
15+
- Kedify Service account (https://dashboard.kedify.io/) to obtain Organization ID and API Key — log in or create an account if you don’t have one
16+
17+
## Prepare installation
18+
19+
1) Get your Organization ID: In the Kedify dashboard (https://dashboard.kedify.io/) go to Organization -> Details and copy the ID.
20+
21+
2) Get your API key:
22+
- If you already have a Kedify Agent deployed, you can retrieve it from the existing Secret:
23+
24+
```bash
25+
kubectl get secret -n keda kedify-agent -o=jsonpath='{.data.apikey}' | base64 --decode
26+
```
27+
28+
- Otherwise, in the Kedify dashboard (https://dashboard.kedify.io/) go to Organization -> API Keys, click Create Agent Key, and copy the key.
29+
30+
Note: The API Key is shared across all your Agent installations. If you regenerate it, update existing Agent installs and keep it secret.
31+
32+
## Helm repository
33+
34+
Add the Kedify Helm repository and update your local index:
35+
36+
```bash
37+
helm repo add kedifykeda https://kedify.github.io/charts
38+
helm repo update
39+
```
40+
41+
## Helm installation
42+
43+
Install each component into the keda namespace. Replace placeholders where noted.
44+
45+
1) Install Kedify build of KEDA:
46+
47+
```bash
48+
helm upgrade --install keda kedifykeda/keda \
49+
--namespace keda \
50+
--create-namespace
51+
```
52+
53+
2) Install Kedify HTTP Scaler:
54+
55+
```bash
56+
helm upgrade --install keda-add-ons-http kedifykeda/keda-add-ons-http \
57+
--namespace keda
58+
```
59+
60+
3) Install Kedify Agent (edit clusterName, orgId, apiKey):
61+
62+
```bash
63+
helm upgrade --install kedify-agent kedifykeda/kedify-agent \
64+
--namespace keda \
65+
--set clusterName="my-cluster" \
66+
--set agent.orgId="$YOUR_ORG_ID" \
67+
--set agent.apiKey="$YOUR_API_KEY"
68+
```
69+
70+
## Verify installation
71+
72+
```bash
73+
kubectl get pods -n keda
74+
```
75+
76+
Expected example (names may differ):
77+
78+
```text
79+
NAME READY STATUS RESTARTS AGE
80+
keda-add-ons-http-external-scaler-xxxxx 1/1 Running 0 1m
81+
keda-add-ons-http-interceptor-xxxxx 1/1 Running 0 1m
82+
keda-admission-webhooks-xxxxx 1/1 Running 0 1m
83+
keda-operator-xxxxx 1/1 Running 0 1m
84+
keda-operator-metrics-apiserver-xxxxx 1/1 Running 0 1m
85+
kedify-agent-xxxxx 1/1 Running 0 1m
86+
```
87+
88+
Proceed to the next section to deploy a sample HTTP app and test autoscaling.

0 commit comments

Comments
 (0)