Skip to content

Commit bdbe1bd

Browse files
authored
Merge pull request #95 from truefoundry/docs_website_integrations
integrations doc addition
2 parents 792229c + 9795b47 commit bdbe1bd

File tree

5 files changed

+52
-183
lines changed

5 files changed

+52
-183
lines changed

docs/integration-with-keda.md

-93
This file was deleted.

docs/integrations.md

+27-81
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,50 @@
11
---
2-
title: Integration
2+
title: Integrations
33
---
44

5-
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
6-
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
7-
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
8-
9-
- [Integration with HPA](#integration-with-hpa)
10-
- [Integration with KEDA](#integration-with-keda)
11-
- [Prerequisites](#prerequisites)
12-
- [Starting setup](#starting-setup)
13-
- [Add Elasti to the service](#add-elasti-to-the-service)
14-
15-
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
165

176
# Integration with HPA
187
Elasti works seamlessly with Horizontal Pod Autoscaler (HPA) and handles scaling to zero on its own. Since Elasti manages the scale-to-zero functionality, you can configure HPA to handle scaling based on metrics for any number of replicas **greater than zero**, while Elasti takes care of scaling to/from zero.
198

9+
A setup is explained in the [getting started](getting-started.md) guide.
10+
2011
# Integration with KEDA
21-
Elasti takes care of scaling up a service when there is some traffic. We need another component to scale down the service when there is no traffic. KEDA is a good candidate for this.
22-
Here we will see how to integrate Elasti with KEDA to perform a complete scaling solution.
12+
Elasti takes care of scaling up and down a service when there is some traffic. KEDA is a good candidate for performing the scaling logic for the service from minReplicas to maxReplicas based on it's triggers.
13+
14+
Here we will see how to integrate Elasti with KEDA to build a complete scaling solution.
2315

2416
## Prerequisites
25-
- Istio installed in the cluster - [Istio Installation](https://istio.io/latest/docs/setup/getting-started/)
17+
- Make sure you have gone through the [getting started](getting-started.md) guide. We will extend the same setup for this integration.
2618
- KEDA installed in the cluster - [KEDA Installation](https://keda.sh/docs/latest/deploy/)
27-
- Elasti installed in the cluster - [Elasti Installation](https://github.com/truefoundry/elasti)
28-
- Prometheus installed in the cluster - [Prometheus Installation](https://prometheus.io/docs/prometheus/latest/installation/)
29-
- A service to scale
30-
31-
## Starting setup
32-
Let's start with a setup where scaling down to zero is performed by KEDA for a service deployed behind istio.
3319

34-
![Starting setup](./assets/keda-scale-down.png)
20+
## Steps
21+
### 1. Create a keda scaler for the service
3522

36-
- traffic is being routed to the service via istio
37-
- keda handles the autoscaling logic for the service from minReplicas to maxReplicas based on it's triggers
23+
Let's create a keda scaler for the httpbin service.
3824

39-
The keda scaler yaml for such a setup is as follows:
40-
41-
```yaml
42-
apiVersion: keda.sh/v1alpha1
43-
kind: ScaledObject
44-
metadata:
45-
name: <service-name>-scaled-object
46-
spec:
47-
maxReplicaCount: 1
48-
minReplicaCount: 1
49-
pollingInterval: 30
50-
scaleTargetRef:
51-
apiVersion: apps/v1
52-
kind: Deployment
53-
name: <service-name>
54-
triggers:
55-
- type: <trigger-type>
56-
metadata:
57-
<trigger-metadata>
25+
```bash
26+
kubectl apply -f ./playground/config/ demo-application-keda.yaml
5827
```
28+
Note that the same prometheus query is used as in the [getting started](getting-started.md) guide for ElastiService and the namespace is the same as the namespace that the ElastiService is created in.
5929

6030
Refer to the [keda documentation](https://keda.sh/docs/2.16/reference/scaledobject-spec/) for more details on configuring the ScaledObject.
6131

62-
## Add Elasti to the service
63-
We will create an [ElastiService](../README.md#1-define-an-elastiservice) object for this service, update the keda scaler to query the Elasti metrics and add a scrapeconfig to the prometheus instance to scrape the Elasti metrics. The final setup will look like this:
64-
65-
![Final Setup](./assets/keda-with-elasti.png)
66-
67-
Here is the flow of requests:
68-
- first request on istio will go to resolver
69-
- controller will scale up the service to 1 replica
70-
- resolver will forward the request to the pods for further processing
71-
72-
When elasti scales down the service, it will pause the keda ScaledObject to prevent it from scaling up the service again, and when elasti scales up the service, it will resume the ScaledObject.
73-
74-
To achieve this, we will have to add the ScaledObject details to the ElastiService.
75-
76-
Note that the namespace that the ElastiService is created in **must** be the same as the namespace that the keda ScaledObject is deployed in.
77-
78-
An example of the ElastiService object is as follows:
32+
### 2. Update ElastiService to work with the keda scaler
7933

34+
We will update the ElastiService to specify the keda scaler to work with. We will add the following fields to the ElastiService object:
8035
```yaml
81-
apiVersion: elasti.truefoundry.com/v1alpha1
82-
kind: ElastiService
83-
metadata:
84-
name: <service-name>-elasti-service
8536
spec:
8637
autoscaler:
87-
name: <service-name>-scaled-object # Must be the same as the keda ScaledObject name
38+
name: httpbin-scaled-object
8839
type: keda
89-
cooldownPeriod: 300 # Elasti will not scale down a service for at least cooldownPeriod seconds from lastScaledUpTime
90-
minTargetReplicas: 1
91-
scaleTargetRef:
92-
apiVersion: apps/v1
93-
kind: Deployment
94-
name: <service-name>
95-
service: <service-name>
96-
triggers:
97-
- metadata:
98-
query: sum(rate(istio_requests_total{destination_service="<service-name>.demo.svc.cluster.local"}[1m])) or vector(0)
99-
serverAddress: http://<prometheus-instance-url>:9090
100-
threshold: "0.01"
101-
type: prometheus
102-
```
103-
104-
With these changes, elasti can reliably scale up the service when there is traffic and scale down the service to zero when there is no traffic.
40+
```
41+
42+
Patch the ElastiService object with the above changes.
43+
44+
```bash
45+
kubectl patch elastiservice httpbin -n elasti-demo -p '{"spec":{"autoscaler":{"name": "httpbin-scaled-object", "type": "keda"}}}' --type=merge
46+
```
47+
48+
Now when elasti scales down the service, it will pause the keda ScaledObject to prevent it from scaling up the service again, and when elasti scales up the service, it will resume the ScaledObject.
49+
50+
With these changes, elasti can reliably scale up the service when there is traffic and scale down the service to zero when there is no traffic while keda can handle the scaling logic for the service from minReplicas to maxReplicas based on it's triggers.

docs/introduction.md

+3-8
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ This allows Elasti to optimize resource consumption by scaling services down whe
2727

2828
- **Seamless Integration:** Elasti integrates effortlessly with your existing Kubernetes setup. It takes just a few steps to enable scale to zero for any service.
2929

30-
- **Development and Argo Rollouts Support:** Elasti supports two target references: Deployment and Argo Rollouts, making it versatile for various deployment scenarios.
30+
- **Deployment and Argo Rollouts Support:** Elasti supports two target references: Deployment and Argo Rollouts, making it versatile for various deployment scenarios.
3131

3232
- **HTTP API Support:** Currently, Elasti supports only HTTP API types, ensuring straightforward and efficient handling of web traffic.
3333

3434
- **Prometheus Metrics Export:** Elasti exports Prometheus metrics for easy out-of-the-box monitoring. You can also import a pre-built dashboard into Grafana for comprehensive visualization.
3535

36-
- **Istio Support:** Elasti is compatible with Istio. It also supports East-West traffic using cluster-local service DNS, ensuring robust and flexible traffic management across your services.
36+
- **Generic Service Support:** Elasti works at the kubernetes service level. It also supports East-West traffic using cluster-local service DNS, ensuring robust and flexible traffic management across your services. So any ingress or service mesh solution can be used with Elasti.
3737

3838

3939
# Why use Elasti?
@@ -42,9 +42,4 @@ Kubernetes clusters can become costly, especially when running multiple services
4242

4343
> The name Elasti comes from a superhero "Elasti-Girl" from DC Comics. Her superpower is to expand or shrink her body at will—from hundreds of feet tall to mere inches in height.
4444
45-
<div align="center"> <b> Demo </b></div>
46-
<div align="center">
47-
<a href="https://www.loom.com/share/6dae33a27a5847f081f7381f8d9510e6">
48-
<img style="max-width:640px;" src="https://cdn.loom.com/sessions/thumbnails/6dae33a27a5847f081f7381f8d9510e6-adf9e85a899f85fd-full-play.gif">
49-
</a>
50-
</div>
45+
Please checkout the comparison [here](comparisons.md) to see how Elasti compares to other Kubernetes autoscaling solutions.

docs/monitoring.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
## Monitoring
22

3-
During installation, two ServiceMonitor custom resources are created to enable Prometheus to discover the Elasti components. To verify this, you can open your Prometheus interface and search for metrics prefixed with elasti-, or navigate to the Targets section to check if Elasti is listed.
3+
Set `.global.enableMonitoring` to `true` in the [values.yaml](./charts/elasti/values.yaml) file to enable monitoring.
4+
5+
This will create two ServiceMonitor custom resources to enable Prometheus to discover the Elasti components. To verify this, you can open your Prometheus interface and search for metrics prefixed with `elasti_`, or navigate to the Targets section to check if Elasti is listed.
46

57
Once verification is complete, you can use the [provided Grafana dashboard](./playground/infra/elasti-dashboard.yaml) to monitor the internal metrics and performance of Elasti.
68

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: keda.sh/v1alpha1
2+
kind: ScaledObject
3+
metadata:
4+
name: httpbin-scaled-object
5+
spec:
6+
minReplicaCount: 1
7+
maxReplicaCount: 5
8+
pollingInterval: 30
9+
scaleTargetRef:
10+
apiVersion: apps/v1
11+
kind: Deployment
12+
name: httpbin
13+
triggers:
14+
- type: prometheus
15+
metadata:
16+
query: sum(rate(nginx_ingress_controller_nginx_process_requests_total[1m])) or vector(0)
17+
serverAddress: http://kube-prometheus-stack-prometheus.monitoring.svc.cluster.local:9090
18+
threshold: "0.5"
19+
```

0 commit comments

Comments
 (0)