|
38 | 38 | refreshInterval: 5 |
39 | 39 | statusCode: 503 |
40 | 40 | headers: |
| 41 | + Content-Type: "text/html; charset=utf-8" |
41 | 42 | X-Service-Status: "warming-up" |
42 | 43 | content: | |
43 | 44 | <!DOCTYPE html> |
@@ -154,49 +155,81 @@ This is the target value for the scaling configuration. |
154 | 155 |
|
155 | 156 | ## `placeholderConfig` |
156 | 157 |
|
157 | | -This optional section enables serving placeholder pages when the workload is scaled to zero. When enabled, instead of returning an error while waiting for the workload to scale up, the interceptor will serve a customizable HTML page that refreshes automatically. |
| 158 | +This optional section enables serving placeholder responses when the workload is scaled to zero. When enabled, instead of returning an error while waiting for the workload to scale up, the interceptor will serve a customizable response with any content format. |
158 | 159 |
|
159 | 160 | ### `enabled` |
160 | 161 |
|
161 | 162 | >Default: false |
162 | 163 |
|
163 | | -Whether to enable placeholder pages for this HTTPScaledObject. |
| 164 | +Whether to enable placeholder responses for this HTTPScaledObject. |
164 | 165 |
|
165 | 166 | ### `refreshInterval` |
166 | 167 |
|
167 | 168 | >Default: 5 |
168 | 169 |
|
169 | | -The interval in seconds at which the placeholder page will refresh. This should be set based on your expected cold start time. |
| 170 | +A template variable (in seconds) that can be used in your content template. This is just data passed to the template - it does not automatically refresh the response. You can use it in your content for client-side refresh logic if needed (e.g., `<meta http-equiv="refresh" content="{{.RefreshInterval}}">`). |
170 | 171 |
|
171 | 172 | ### `statusCode` |
172 | 173 |
|
173 | 174 | >Default: 503 |
174 | 175 |
|
175 | | -The HTTP status code to return with the placeholder page. Common values are 503 (Service Unavailable) or 202 (Accepted). |
| 176 | +The HTTP status code to return with the placeholder response. Common values are 503 (Service Unavailable) or 202 (Accepted). |
176 | 177 |
|
177 | 178 | ### `headers` |
178 | 179 |
|
179 | 180 | >Default: {} |
180 | 181 |
|
181 | | -A map of custom HTTP headers to include in the placeholder response. Useful for adding service-specific headers. |
| 182 | +A map of custom HTTP headers to include in the placeholder response. **Important**: Use this to set the `Content-Type` header to match your content format. For example: |
| 183 | +- `Content-Type: text/html; charset=utf-8` for HTML |
| 184 | +- `Content-Type: application/json` for JSON |
| 185 | +- `Content-Type: text/plain` for plain text |
182 | 186 |
|
183 | 187 | ### `content` |
184 | 188 |
|
185 | | ->Default: Built-in template |
| 189 | +>Default: ConfigMap-provided template (if configured), otherwise returns simple text |
186 | 190 |
|
187 | | -Custom HTML content for the placeholder page. Supports Go template syntax with the following variables: |
| 191 | +Custom content for the placeholder response. Supports any format (HTML, JSON, XML, plain text, etc.). Content is processed as a Go template with the following variables: |
188 | 192 | - `{{.ServiceName}}` - The name of the service from scaleTargetRef |
189 | 193 | - `{{.Namespace}}` - The namespace of the HTTPScaledObject |
190 | | -- `{{.RefreshInterval}}` - The configured refresh interval |
| 194 | +- `{{.RefreshInterval}}` - The configured refresh interval value (just a number) |
191 | 195 | - `{{.RequestID}}` - The X-Request-ID header value if present |
192 | 196 | - `{{.Timestamp}}` - The current timestamp in RFC3339 format |
193 | 197 |
|
194 | | -### `contentConfigMap` |
| 198 | +**Examples:** |
195 | 199 |
|
196 | | -The name of a ConfigMap containing the placeholder page template. This is an alternative to inline `content`. |
197 | | - |
198 | | -### `contentConfigMapKey` |
| 200 | +HTML with client-side refresh: |
| 201 | +```yaml |
| 202 | +content: | |
| 203 | + <!DOCTYPE html> |
| 204 | + <html> |
| 205 | + <head> |
| 206 | + <title>Service Starting</title> |
| 207 | + <meta http-equiv="refresh" content="{{.RefreshInterval}}"> |
| 208 | + </head> |
| 209 | + <body> |
| 210 | + <h1>{{.ServiceName}} is starting...</h1> |
| 211 | + </body> |
| 212 | + </html> |
| 213 | +headers: |
| 214 | + Content-Type: "text/html; charset=utf-8" |
| 215 | +``` |
199 | 216 |
|
200 | | ->Default: "template.html" |
| 217 | +JSON response: |
| 218 | +```yaml |
| 219 | +content: | |
| 220 | + { |
| 221 | + "status": "warming_up", |
| 222 | + "service": "{{.ServiceName}}", |
| 223 | + "namespace": "{{.Namespace}}", |
| 224 | + "timestamp": "{{.Timestamp}}" |
| 225 | + } |
| 226 | +headers: |
| 227 | + Content-Type: "application/json" |
| 228 | +``` |
201 | 229 |
|
202 | | -The key within the ConfigMap that contains the template content. |
| 230 | +Plain text: |
| 231 | +```yaml |
| 232 | +content: "{{.ServiceName}} is starting up. Please retry in a few seconds." |
| 233 | +headers: |
| 234 | + Content-Type: "text/plain" |
| 235 | +``` |
0 commit comments