|
| 1 | +# The `HTTPScaledObject` |
| 2 | + |
| 3 | +> This document reflects the specification of the `HTTPScaledObject` resource for the `v0.13.0` version. |
| 4 | +
|
| 5 | +Each `HTTPScaledObject` looks approximately like the below: |
| 6 | + |
| 7 | +```yaml |
| 8 | +kind: HTTPScaledObject |
| 9 | +apiVersion: http.keda.sh/v1alpha1 |
| 10 | +metadata: |
| 11 | + name: xkcd |
| 12 | + annotations: |
| 13 | + httpscaledobject.keda.sh/skip-scaledobject-creation: "false" |
| 14 | +spec: |
| 15 | + hosts: |
| 16 | + - myhost.com |
| 17 | + - "*.example.com" |
| 18 | + pathPrefixes: |
| 19 | + - /test |
| 20 | + headers: |
| 21 | + - name: X-Custom-Header |
| 22 | + value: CustomValue |
| 23 | + scaleTargetRef: |
| 24 | + name: xkcd |
| 25 | + kind: Deployment |
| 26 | + apiVersion: apps/v1 |
| 27 | + service: xkcd |
| 28 | + port: 8080 |
| 29 | + replicas: |
| 30 | + min: 5 |
| 31 | + max: 10 |
| 32 | + scaledownPeriod: 300 |
| 33 | + scalingMetric: # requestRate and concurrency are mutually exclusive |
| 34 | + requestRate: |
| 35 | + granularity: 1s |
| 36 | + targetValue: 100 |
| 37 | + window: 1m |
| 38 | + concurrency: |
| 39 | + targetValue: 100 |
| 40 | +``` |
| 41 | +
|
| 42 | +This document is a narrated reference guide for the `HTTPScaledObject`. |
| 43 | + |
| 44 | +## `httpscaledobject.keda.sh/skip-scaledobject-creation` annotation |
| 45 | + |
| 46 | +This annotation will disable the ScaledObject generation and management but keeping the routing and metrics available. This is done removing the current ScaledObject if it has been already created, allowing to use user managed ScaledObjects pointing the add-on scaler directly (supporting all the ScaledObject configurations and multiple triggers). You can read more about this [here](./../../walkthrough.md#integrating-http-add-on-scaler-with-other-keda-scalers) |
| 47 | + |
| 48 | +## `hosts` |
| 49 | + |
| 50 | +These are the hosts to apply this scaling rule to. All incoming requests with one of these values in their `Host` header will be forwarded to the `Service` and port specified in the below `scaleTargetRef`, and that same `scaleTargetRef`'s workload will be scaled accordingly. |
| 51 | + |
| 52 | +Wildcard patterns are supported using a leading `*.` prefix. For example, `*.example.com` matches any subdomain of `example.com`, including multi-level subdomains like `foo.bar.example.com`. More specific wildcards take precedence over less specific ones (e.g., `*.bar.example.com` wins over `*.example.com`). Exact host matches always take precedence over wildcard matches. |
| 53 | + |
| 54 | +An empty host or `*` acts as a catch-all that matches any hostname. This is useful as a fallback when no other routes match. |
| 55 | + |
| 56 | +## `pathPrefixes` |
| 57 | + |
| 58 | +> Default: "/" |
| 59 | + |
| 60 | +These are the paths to apply this scaling rule to. All incoming requests with one of these values as path prefix will be forwarded to the `Service` and port specified in the below `scaleTargetRef`, and that same `scaleTargetRef`'s workload will be scaled accordingly. |
| 61 | + |
| 62 | +## `headers` |
| 63 | + |
| 64 | +> Default: No headers |
| 65 | + |
| 66 | +To further refine which requests this scaling rule applies to, you can specify a list of HTTP headers. Headers can be specified with or without values - if a value is provided, it must match exactly; if no value is provided, only the header's presence is required. All incoming requests that satisfy these header conditions will be forwarded to the `Service` and port specified in the below `scaleTargetRef`, and that same `scaleTargetRef`'s workload will be scaled accordingly. Most specific matches take precedence over less specific ones. This means that rules with more headers defined will be prioritized over those with fewer headers when multiple rules could apply to a request. Also a match for header with key and value takes precedence over a match for header with only a key. |
| 67 | + |
| 68 | +## `scaleTargetRef` |
| 69 | + |
| 70 | +This is the primary and most important part of the `spec` because it describes: |
| 71 | + |
| 72 | +1. The incoming host to apply this scaling rule to. |
| 73 | +2. What workload to scale. |
| 74 | +3. The service to which to route HTTP traffic. |
| 75 | + |
| 76 | +### `name` |
| 77 | + |
| 78 | +This is the name of the workload to scale. It must exist in the same namespace as this `HTTPScaledObject` and shouldn't be managed by any other autoscaling system. This means that there should not be any `ScaledObject` already created for this workload. The HTTP Add-on will manage a `ScaledObject` internally. |
| 79 | + |
| 80 | +### `kind` |
| 81 | + |
| 82 | +This is the kind of the workload to scale. |
| 83 | + |
| 84 | +### `apiVersion` |
| 85 | + |
| 86 | +This is the apiVersion of the workload to scale. |
| 87 | + |
| 88 | +### `service` |
| 89 | + |
| 90 | +This is the name of the service to route traffic to. The add-on will create autoscaling and routing components that route to this `Service`. It must exist in the same namespace as this `HTTPScaledObject` and should route to the same `Deployment` as you entered in the `deployment` field. |
| 91 | + |
| 92 | +### `port` |
| 93 | + |
| 94 | +This is the port to route to on the service that you specified in the `service` field. It should be exposed on the service and should route to a valid `containerPort` on the workload you gave. |
| 95 | + |
| 96 | +### `portName` |
| 97 | + |
| 98 | +Alternatively, the port can be referenced using it's `name` as defined in the `Service`. |
| 99 | + |
| 100 | +### `scaledownPeriod` |
| 101 | + |
| 102 | +> Default: 300 |
| 103 | + |
| 104 | +The period to wait after the last reported active before scaling the resource back to 0. |
| 105 | + |
| 106 | +> Note: This time is measured on KEDA side based on in-flight requests, so workloads with few and random traffic could have unexpected scale to 0 cases. In those case we recommend to extend this period to ensure it doesn't happen. |
| 107 | + |
| 108 | +## `scalingMetric` |
| 109 | + |
| 110 | +This is the second most important part of the `spec` because it describes how the workload has to scale. This section contains 2 nested sections (`requestRate` and `concurrency`) which are mutually exclusive between themselves. |
| 111 | + |
| 112 | +### `requestRate` |
| 113 | + |
| 114 | +This section enables scaling based on the request rate. |
| 115 | + |
| 116 | +> **NOTE**: Requests information is stored in memory, aggragating long periods (longer than 5 minutes) or too fine granularity (less than 1 second) could produce perfomance issues or memory usage increase. |
| 117 | + |
| 118 | +> **NOTE 2**: Although updating `window` and/or `granularity` is something doable, the process just replaces all the stored request count infomation. This can produce unexpected scaling behaviours until the window is populated again. |
| 119 | + |
| 120 | +#### `targetValue` |
| 121 | + |
| 122 | +> Default: 100 |
| 123 | + |
| 124 | +This is the target value for the scaling configuration. |
| 125 | + |
| 126 | +#### `window` |
| 127 | + |
| 128 | +> Default: "1m" |
| 129 | + |
| 130 | +This value defines the aggregation window for the request rate calculation. |
| 131 | + |
| 132 | +#### `granularity` |
| 133 | + |
| 134 | +> Default: "1s" |
| 135 | + |
| 136 | +This value defines the granualarity of the aggregated requests for the request rate calculation. |
| 137 | + |
| 138 | +### `concurrency` |
| 139 | + |
| 140 | +This section enables scaling based on the request concurrency. |
| 141 | + |
| 142 | +> **NOTE**: This is the only scaling behaviour before v0.8.0 |
| 143 | + |
| 144 | +#### `targetValue` |
| 145 | + |
| 146 | +> Default: 100 |
| 147 | + |
| 148 | +This is the target value for the scaling configuration. |
0 commit comments