Skip to content

Commit 64123e7

Browse files
feat(http-add-on): add InterceptorRoute CRD and update RBAC permissions (#839)
Signed-off-by: Atharva Pakade <pakade310@gmail.com>
1 parent e8a7a58 commit 64123e7

8 files changed

Lines changed: 302 additions & 2 deletions

File tree

.github/workflows/ci-http-add-on.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,13 @@ jobs:
143143
- name: Get all CRDs
144144
run: kubectl get crds
145145

146+
- name: Get InterceptorRoute CRD
147+
run: kubectl get crds/interceptorroutes.http.keda.sh
148+
149+
- name: Describe InterceptorRoute CRD
150+
run: kubectl describe crds/interceptorroutes.http.keda.sh
151+
152+
# TODO: Drop `HTTPScaledObject` specific steps after crd is DEPRECATED
146153
- name: Get HTTPScaledObject CRD
147154
run: kubectl get crds/httpscaledobjects.http.keda.sh
148155

http-add-on/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ their default values.
8585
| Parameter | Type | Default | Description |
8686
|-----------|------|---------|-------------|
8787
| `additionalLabels` | object | `{}` | Additional labels to be applied to installed resources. Note that not all resources will receive these labels. |
88-
| `crds.install` | bool | `true` | Whether to install the `HTTPScaledObject` [`CustomResourceDefinition`](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/) |
88+
| `crds.install` | bool | `true` | Whether to install the `HTTPScaledObject` and `InterceptorRoute` [`CustomResourceDefinitions`](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/) |
8989
| `images.interceptor` | string | `"ghcr.io/kedacore/http-add-on-interceptor"` | Image name for the interceptor image component |
9090
| `images.operator` | string | `"ghcr.io/kedacore/http-add-on-operator"` | Image name for the operator image component |
9191
| `images.scaler` | string | `"ghcr.io/kedacore/http-add-on-scaler"` | Image name for the scaler image component |

http-add-on/templates/crd.yaml

Lines changed: 286 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,4 +306,290 @@ spec:
306306
storage: true
307307
subresources:
308308
status: {}
309+
---
310+
apiVersion: apiextensions.k8s.io/v1
311+
kind: CustomResourceDefinition
312+
metadata:
313+
annotations:
314+
controller-gen.kubebuilder.io/version: v0.19.0
315+
name: interceptorroutes.http.keda.sh
316+
spec:
317+
group: http.keda.sh
318+
names:
319+
kind: InterceptorRoute
320+
listKind: InterceptorRouteList
321+
plural: interceptorroutes
322+
singular: interceptorroute
323+
scope: Namespaced
324+
versions:
325+
- additionalPrinterColumns:
326+
- jsonPath: .spec.target.service
327+
name: TargetService
328+
type: string
329+
- jsonPath: .status.conditions[?(@.type=="Ready")].status
330+
name: Ready
331+
type: string
332+
- jsonPath: .metadata.creationTimestamp
333+
name: Age
334+
type: date
335+
name: v1beta1
336+
schema:
337+
openAPIV3Schema:
338+
description: InterceptorRoute configures request routing and autoscaling for
339+
a target service.
340+
properties:
341+
apiVersion:
342+
description: |-
343+
APIVersion defines the versioned schema of this representation of an object.
344+
Servers should convert recognized schemas to the latest internal value, and
345+
may reject unrecognized values.
346+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
347+
type: string
348+
kind:
349+
description: |-
350+
Kind is a string value representing the REST resource this object represents.
351+
Servers may infer this from the endpoint the client submits requests to.
352+
Cannot be updated.
353+
In CamelCase.
354+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
355+
type: string
356+
metadata:
357+
type: object
358+
spec:
359+
description: InterceptorRouteSpec defines the desired state of InterceptorRoute.
360+
properties:
361+
coldStart:
362+
description: Cold start behavior when scaling from zero.
363+
properties:
364+
fallback:
365+
description: |-
366+
Fallback service to route to when the target is scaling from zero
367+
and the wait timeout expires.
368+
properties:
369+
port:
370+
description: Port number on the Service. Mutually exclusive
371+
with portName.
372+
format: int32
373+
maximum: 65535
374+
minimum: 1
375+
type: integer
376+
portName:
377+
description: Named port on the Service. Mutually exclusive
378+
with port.
379+
minLength: 1
380+
type: string
381+
service:
382+
description: Name of the Kubernetes Service.
383+
minLength: 1
384+
type: string
385+
required:
386+
- service
387+
type: object
388+
x-kubernetes-validations:
389+
- message: exactly one of 'port' or 'portName' must be set
390+
rule: has(self.port) != has(self.portName)
391+
required:
392+
- fallback
393+
type: object
394+
x-kubernetes-validations:
395+
- message: '''fallback'' must be set'
396+
rule: has(self.fallback)
397+
rules:
398+
description: Routing rules that define how requests are matched to
399+
this target.
400+
items:
401+
description: RoutingRule defines a set of matching criteria for
402+
routing requests.
403+
properties:
404+
headers:
405+
description: |-
406+
All listed headers must match the request (AND semantics).
407+
If a header's Value is omitted, the header must be present but any
408+
value is accepted.
409+
items:
410+
description: HeaderMatch defines a header matching rule.
411+
properties:
412+
name:
413+
description: Name of the HTTP header.
414+
minLength: 1
415+
type: string
416+
value:
417+
description: Value to match against (exact match). If
418+
omitted, matches any value for given header name.
419+
type: string
420+
required:
421+
- name
422+
type: object
423+
type: array
424+
x-kubernetes-list-map-keys:
425+
- name
426+
x-kubernetes-list-type: map
427+
hosts:
428+
description: |-
429+
Match any of these hostnames. Wildcard patterns (e.g. "*.example.com")
430+
are supported. A single "*" acts as a catch-all. Exact matches take
431+
priority over wildcards; more specific wildcards (e.g. "*.bar.example.com")
432+
take priority over less specific ones.
433+
items:
434+
type: string
435+
type: array
436+
x-kubernetes-list-type: set
437+
paths:
438+
description: |-
439+
Match any of these path prefixes. When multiple paths match,
440+
the longest prefix wins.
441+
items:
442+
description: PathMatch defines a path matching rule.
443+
properties:
444+
value:
445+
description: Path prefix to match against. The longest
446+
matching prefix wins.
447+
minLength: 1
448+
type: string
449+
required:
450+
- value
451+
type: object
452+
type: array
453+
x-kubernetes-list-type: atomic
454+
type: object
455+
type: array
456+
x-kubernetes-list-type: atomic
457+
scalingMetric:
458+
description: Metric configuration for autoscaling.
459+
properties:
460+
concurrency:
461+
description: Scale based on concurrent request count.
462+
properties:
463+
targetValue:
464+
default: 100
465+
description: Target concurrent request count per replica.
466+
format: int32
467+
minimum: 1
468+
type: integer
469+
type: object
470+
requestRate:
471+
description: Scale based on request rate.
472+
properties:
473+
granularity:
474+
default: 1s
475+
description: Bucket size for rate calculation within the window.
476+
type: string
477+
targetValue:
478+
default: 100
479+
description: Target request rate per replica.
480+
format: int32
481+
minimum: 1
482+
type: integer
483+
window:
484+
default: 1m
485+
description: Sliding time window over which the request rate
486+
is calculated.
487+
type: string
488+
type: object
489+
type: object
490+
x-kubernetes-validations:
491+
- message: at least one of 'concurrency' or 'requestRate' must be
492+
set
493+
rule: has(self.concurrency) || has(self.requestRate)
494+
target:
495+
description: Backend service to route traffic to.
496+
properties:
497+
port:
498+
description: Port number on the Service. Mutually exclusive with
499+
portName.
500+
format: int32
501+
maximum: 65535
502+
minimum: 1
503+
type: integer
504+
portName:
505+
description: Named port on the Service. Mutually exclusive with
506+
port.
507+
minLength: 1
508+
type: string
509+
service:
510+
description: Name of the Kubernetes Service.
511+
minLength: 1
512+
type: string
513+
required:
514+
- service
515+
type: object
516+
x-kubernetes-validations:
517+
- message: exactly one of 'port' or 'portName' must be set
518+
rule: has(self.port) != has(self.portName)
519+
required:
520+
- scalingMetric
521+
- target
522+
type: object
523+
status:
524+
description: InterceptorRouteStatus defines the observed state of InterceptorRoute.
525+
properties:
526+
conditions:
527+
description: Conditions of the InterceptorRoute.
528+
items:
529+
description: Condition contains details for one aspect of the current
530+
state of this API Resource.
531+
properties:
532+
lastTransitionTime:
533+
description: |-
534+
lastTransitionTime is the last time the condition transitioned from one status to another.
535+
This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
536+
format: date-time
537+
type: string
538+
message:
539+
description: |-
540+
message is a human readable message indicating details about the transition.
541+
This may be an empty string.
542+
maxLength: 32768
543+
type: string
544+
observedGeneration:
545+
description: |-
546+
observedGeneration represents the .metadata.generation that the condition was set based upon.
547+
For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
548+
with respect to the current state of the instance.
549+
format: int64
550+
minimum: 0
551+
type: integer
552+
reason:
553+
description: |-
554+
reason contains a programmatic identifier indicating the reason for the condition's last transition.
555+
Producers of specific condition types may define expected values and meanings for this field,
556+
and whether the values are considered a guaranteed API.
557+
The value should be a CamelCase string.
558+
This field may not be empty.
559+
maxLength: 1024
560+
minLength: 1
561+
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
562+
type: string
563+
status:
564+
description: status of the condition, one of True, False, Unknown.
565+
enum:
566+
- "True"
567+
- "False"
568+
- Unknown
569+
type: string
570+
type:
571+
description: type of condition in CamelCase or in foo.example.com/CamelCase.
572+
maxLength: 316
573+
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
574+
type: string
575+
required:
576+
- lastTransitionTime
577+
- message
578+
- reason
579+
- status
580+
- type
581+
type: object
582+
type: array
583+
x-kubernetes-list-map-keys:
584+
- type
585+
x-kubernetes-list-type: map
586+
type: object
587+
required:
588+
- metadata
589+
- spec
590+
type: object
591+
served: true
592+
storage: true
593+
subresources:
594+
status: {}
309595
{{ end }}

http-add-on/templates/interceptor/rbac.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ rules:
2727
- http.keda.sh
2828
resources:
2929
- httpscaledobjects
30+
- interceptorroutes
3031
verbs:
3132
- get
3233
- list

http-add-on/templates/operator/rbac.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ rules:
4646
- http.keda.sh
4747
resources:
4848
- httpscaledobjects
49+
- interceptorroutes
4950
verbs:
5051
- create
5152
- delete
@@ -58,12 +59,14 @@ rules:
5859
- http.keda.sh
5960
resources:
6061
- httpscaledobjects/finalizers
62+
- interceptorroutes/finalizers
6163
verbs:
6264
- update
6365
- apiGroups:
6466
- http.keda.sh
6567
resources:
6668
- httpscaledobjects/status
69+
- interceptorroutes/status
6770
verbs:
6871
- get
6972
- patch

http-add-on/templates/rbac-aggregateclusterroles.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ rules:
1414
- http.keda.sh
1515
resources:
1616
- httpscaledobjects
17+
- interceptorroutes
1718
verbs:
1819
- create
1920
- delete
@@ -38,6 +39,7 @@ rules:
3839
- http.keda.sh
3940
resources:
4041
- httpscaledobjects
42+
- interceptorroutes
4143
verbs:
4244
- get
4345
- list

http-add-on/templates/scaler/rbac.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ rules:
1919
- http.keda.sh
2020
resources:
2121
- httpscaledobjects
22+
- interceptorroutes
2223
verbs:
2324
- get
2425
- list

http-add-on/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
additionalLabels: {}
33

44
crds:
5-
# -- Whether to install the `HTTPScaledObject` [`CustomResourceDefinition`](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/)
5+
# -- Whether to install the `HTTPScaledObject` and `InterceptorRoute` [`CustomResourceDefinitions`](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/)
66
install: true
77

88
logging:

0 commit comments

Comments
 (0)