Skip to content

Commit 087d8a3

Browse files
az-adhocCopilot
andcommitted
[UPD] Keda: interceptor
Co-authored-by: Copilot <copilot@github.com>
1 parent 703558b commit 087d8a3

3 files changed

Lines changed: 83 additions & 3 deletions

File tree

charts/adhoc-odoo/templates/rbac/dev.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ rules:
5656
verbs: ["get", "list"]
5757
{{- if .Values.autoscaling.keda.enabled }}
5858
- apiGroups: ["http.keda.sh"]
59-
resources: ["httpscaledobjects"]
59+
resources: ["httpscaledobjects", "interceptorroute"]
60+
verbs: ["get", "list"]
61+
- apiGroups: ["keda.sh"]
62+
resources: ["scaledobjects"]
6063
verbs: ["get", "list"]
6164
{{- end }}
6265
# Allow viewing services

charts/adhoc-odoo/templates/scaler/hpa.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
apiVersion: autoscaling/v2beta2
33
kind: HorizontalPodAutoscaler
44
metadata:
5-
name: {{ include "adhoc-odoo.fullname" . }}
5+
name: {{ .Release.Name }}
66
labels:
77
{{- include "adhoc-odoo.labels" . | nindent 4 }}
88
spec:

charts/adhoc-odoo/templates/scaler/keda.yaml

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
{{- if eq (include "keda.enabled" . | trim) "true" }}
2+
# TODO: Delete this HTTPScaledObject in a couple months once we are sure that KEDA is working correctly and the HPA is not being used anymore.
3+
# We need to keep it for now to avoid downtime during the transition, but it will be orphaned and won't have any effect once the InterceptorRoute is working.
4+
# Like Jun 2026
25
# kubectl explain --api-version=http.keda.sh/v1alpha1 httpscaledobject.spec
36
apiVersion: http.keda.sh/v1alpha1
47
kind: HTTPScaledObject
58
metadata:
69
name: {{ include "adhoc-odoo.fullname" . }}
710
labels:
811
{{- include "adhoc-odoo.labels" . | nindent 4 }}
12+
annotations:
13+
httpscaledobject.keda.sh/orphan-scaledobject: "true"
914
spec:
1015
hosts:
1116
{{- if .Values.ingress.istio.enabled }}
@@ -64,5 +69,77 @@ spec:
6469
window: 10s # Window for request rate scaling (Don't use more than 10s, otherwise it will problematic for the HPA)
6570
# Scaling based on pending requests for a given target
6671
# targetPendingRequests: 1 # DEPRECATED
67-
{{- end }}
72+
# ---
73+
# apiVersion: v1
74+
# kind: Service
75+
# metadata:
76+
# name: default-http-server
77+
# spec:
78+
# type: ExternalName
79+
# # TODO: Create a custom maintenance page
80+
# externalName: default-http-server.istio-system.svc.cluster.local
81+
# ports:
82+
# - port: 80
83+
# targetPort: 80
84+
---
85+
apiVersion: http.keda.sh/v1beta1
86+
kind: InterceptorRoute
87+
metadata:
88+
name: {{ .Release.Name }}
89+
spec:
90+
target:
91+
{{- if .Values.ingress.reverseProxy.enabled }}
92+
service: {{ include "adhoc-odoo.serviceNameSuffix" . }}-nginx
93+
{{- else }}
94+
service: {{ include "adhoc-odoo.serviceNameSuffix" . }}-http
95+
{{- end }}
96+
port: 80
97+
# There is a bug in KEDA type discrepancy (CRD/admission accept string, but controller try to read a ServiceRef)
98+
# coldStart:
99+
# fallback:
100+
# service:
101+
# name: default-http-server
102+
# port: 80
103+
rules:
104+
- hosts:
105+
{{- if .Values.ingress.istio.enabled }}
106+
- {{ printf "%s.%s" .Values.odoo.pg.db .Values.ingress.istio.cloudMainDomain | quote }}
107+
{{- if .Values.ingress.istio.altHosts -}}
108+
{{- $hosts := regexSplit ',' .Values.ingress.istio.altHosts -1 }}
109+
{{- range $hosts }}
110+
- {{ . | quote }}
111+
{{- end }}
112+
{{- end }}
113+
{{- end }}
114+
scalingMetric:
115+
# Scaling based on concurrent requests for a given target
116+
# Si los recursos son estables, es mejor usar concurrency ¿con workers?
117+
# concurrency:
118+
# targetValue: 10 # Target value for rate scaling
68119

120+
# Scaling based on request rate for a given target
121+
# Util cuando las peticiones son cortas y queremos reaccionar a picos de tráfico. ¿website/sin workers?
122+
requestRate:
123+
granularity: 5s # Granularity for request rate scaling
124+
targetValue: 100 # Target value for request rate scaling
125+
window: 10s # Window for request rate scaling (Don't use more than 10s, otherwise it will problematic for the HPA)
126+
---
127+
apiVersion: keda.sh/v1alpha1
128+
kind: ScaledObject
129+
metadata:
130+
name: {{ include "adhoc-odoo.fullname" . }}
131+
spec:
132+
scaleTargetRef:
133+
name: {{ include "adhoc-odoo.fullname" . }}
134+
kind: Deployment
135+
apiVersion: apps/v1
136+
minReplicaCount: {{ .Values.autoscaling.minReplicas | toString | int }}
137+
maxReplicaCount: {{ .Values.autoscaling.maxReplicas | toString | int }}
138+
initialCooldownPeriod: 900 # Initial period before scaling 15 min
139+
cooldownPeriod: 900
140+
triggers:
141+
- type: external-push
142+
metadata:
143+
scalerAddress: "keda-add-ons-http-external-scaler.keda:9090"
144+
interceptorRoute: {{ .Release.Name }}
145+
{{- end }}

0 commit comments

Comments
 (0)