Skip to content

Commit

Permalink
feat: implement keda health-checks (#16715)
Browse files Browse the repository at this point in the history
Signed-off-by: parmou <parveshmourya96@gmail.com>
Co-authored-by: Blake Pettersson <blake.pettersson@gmail.com>
  • Loading branch information
parmou and blakepettersson committed May 8, 2024
1 parent 7945b26 commit 9bc9ff9
Show file tree
Hide file tree
Showing 7 changed files with 291 additions and 0 deletions.
35 changes: 35 additions & 0 deletions resource_customizations/keda.sh/ScaledObject/health.lua
@@ -0,0 +1,35 @@
local hs = {}
local healthy = false
local degraded = false
local suspended = false
if obj.status ~= nil then
if obj.status.conditions ~= nil then
for i, condition in ipairs(obj.status.conditions) do
if condition.status == "False" and condition.type == "Ready" then
hs.message = condition.message
degraded = true
end
if condition.status == "True" and condition.type == "Ready" then
hs.message = condition.message
healthy = true
end
if condition.status == "True" and condition.type == "Paused" then
hs.message = condition.message
suspended = true
end
end
end
end
if degraded == true then
hs.status = "Degraded"
return hs
elseif healthy == true and suspended == false then
hs.status = "Healthy"
return hs
elseif healthy == true and suspended == true then
hs.status = "Suspended"
return hs
end
hs.status = "Progressing"
hs.message = "Creating HorizontalPodAutoscaler Object"
return hs
21 changes: 21 additions & 0 deletions resource_customizations/keda.sh/ScaledObject/health_test.yaml
@@ -0,0 +1,21 @@
tests:
- healthStatus:
status: Progressing
message: "Creating HorizontalPodAutoscaler Object"
inputPath: testdata/keda-progressing.yaml
- healthStatus:
status: Degraded
message: "ScaledObject doesn't have correct Idle/Min/Max Replica Counts specification"
inputPath: testdata/keda-degraded-1.yaml
- healthStatus:
status: Degraded
message: "ScaledObject doesn't have correct triggers specification"
inputPath: testdata/keda-degraded.yaml
- healthStatus:
status: Healthy
message: "ScaledObject is defined correctly and is ready for scaling"
inputPath: testdata/keda-healthy.yaml
- healthStatus:
status: Suspended
message: "ScaledObject is paused"
inputPath: testdata/keda-suspended.yaml
@@ -0,0 +1,52 @@
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
annotations:
finalizers:
- finalizer.keda.sh
labels:
argocd.argoproj.io/instance: keda-default
name: keda
namespace: keda
resourceVersion: '160591442'
uid: 73ee438a-f383-43f3-9346-b901d9773f4b
spec:
maxReplicaCount: 3
minReplicaCount: 0
scaleTargetRef:
name: keda
triggers:
- metadata:
desiredReplicas: '1'
end: 00 17 * * 1-5
start: 00 08 * * 1-5
timezone: Europe/Stockholm
type: cron
status:
conditions:
- message: >-
ScaledObject doesn't have correct Idle/Min/Max Replica Counts specification
reason: ScaledObjectCheckFailed
status: 'False'
type: Ready
- message: ScaledObject check failed
reason: UnknownState
status: Unknown
type: Active
- message: No fallbacks are active on this scaled object
reason: NoFallbackFound
status: 'False'
type: Fallback
- status: Unknown
type: Paused
externalMetricNames:
- s0-cron-Europe-Stockholm-0008xx1-5-0019xx1-5
hpaName: keda-hpa
lastActiveTime: '2023-12-18T17:59:55Z'
originalReplicaCount: 1
scaleTargetGVKR:
group: apps
kind: Deployment
resource: deployments
version: v1
scaleTargetKind: apps/v1.Deployment
@@ -0,0 +1,51 @@
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
annotations:
finalizers:
- finalizer.keda.sh
labels:
argocd.argoproj.io/instance: keda-default
name: keda
namespace: keda
resourceVersion: '160591442'
uid: 73ee438a-f383-43f3-9346-b901d9773f4b
spec:
maxReplicaCount: 3
minReplicaCount: 0
scaleTargetRef:
name: keda
triggers:
- metadata:
desiredReplicas: '1'
end: 00 17 * * 1-5
start: 00 08 * * 1-5
timezone: Europe/Stockholm
type: cron
status:
conditions:
- message: ScaledObject doesn't have correct triggers specification
reason: ScaledObjectCheckFailed
status: 'False'
type: Ready
- message: Scaling is not performed because triggers are not active
reason: ScalerNotActive
status: 'False'
type: Active
- message: No fallbacks are active on this scaled object
reason: NoFallbackFound
status: 'False'
type: Fallback
- status: Unknown
type: Paused
externalMetricNames:
- s0-cron-Europe-Stockholm-0008xx1-5-0019xx1-5
hpaName: keda-hpa
lastActiveTime: '2023-12-18T17:59:55Z'
originalReplicaCount: 1
scaleTargetGVKR:
group: apps
kind: Deployment
resource: deployments
version: v1
scaleTargetKind: apps/v1.Deployment
@@ -0,0 +1,51 @@
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
annotations:
finalizers:
- finalizer.keda.sh
labels:
argocd.argoproj.io/instance: keda-default
name: keda
namespace: keda
resourceVersion: '160591442'
uid: 73ee438a-f383-43f3-9346-b901d9773f4b
spec:
maxReplicaCount: 3
minReplicaCount: 0
scaleTargetRef:
name: backstage
triggers:
- metadata:
desiredReplicas: '1'
end: 00 17 * * 1-5
start: 00 08 * * 1-5
timezone: Europe/Stockholm
type: cron
status:
conditions:
- message: ScaledObject is defined correctly and is ready for scaling
reason: ScaledObjectReady
status: 'True'
type: Ready
- message: Scaling is not performed because triggers are not active
reason: ScalerNotActive
status: 'False'
type: Active
- message: No fallbacks are active on this scaled object
reason: NoFallbackFound
status: 'False'
type: Fallback
- status: Unknown
type: Paused
externalMetricNames:
- s0-cron-Europe-Stockholm-0008xx1-5-0019xx1-5
hpaName: keda-hpa-backstage-kambi-standard-chart
lastActiveTime: '2023-12-18T17:59:55Z'
originalReplicaCount: 1
scaleTargetGVKR:
group: apps
kind: Deployment
resource: deployments
version: v1
scaleTargetKind: apps/v1.Deployment
@@ -0,0 +1,30 @@
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
annotations:
finalizers:
- finalizer.keda.sh
labels:
argocd.argoproj.io/instance: keda-default
name: keda
namespace: keda
resourceVersion: '160591442'
uid: 73ee438a-f383-43f3-9346-b901d9773f4b
spec:
maxReplicaCount: 3
minReplicaCount: 0
scaleTargetRef:
name: backstage
triggers:
- metadata:
desiredReplicas: '1'
end: 00 17 * * 1-5
start: 00 08 * * 1-5
timezone: Europe/Stockholm
type: cron
status:
conditions:
- message: Creating HorizontalPodAutoscaler Object
reason: Running
status: 'True'
type: Running
@@ -0,0 +1,51 @@
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
annotations:
finalizers:
- finalizer.keda.sh
labels:
argocd.argoproj.io/instance: keda-default
name: keda
namespace: keda
resourceVersion: '160591442'
uid: 73ee438a-f383-43f3-9346-b901d9773f4b
spec:
maxReplicaCount: 3
minReplicaCount: 0
scaleTargetRef:
name: backstage
triggers:
- metadata:
desiredReplicas: '1'
end: 00 17 * * 1-5
start: 00 08 * * 1-5
timezone: Europe/Stockholm
type: cron
status:
conditions:
- message: ScaledObject is defined correctly and is ready for scaling
reason: ScaledObjectReady
status: 'True'
type: Ready
- message: ScaledObject check failed
reason: UnknownState
status: Unknown
type: Active
- status: Unknown
type: Fallback
- message: ScaledObject is paused
reason: ScaledObjectPaused
status: 'True'
type: Paused
externalMetricNames:
- s0-cron-Europe-Stockholm-0008xx1-5-0019xx1-5
hpaName: keda-hpa-backstage-kambi-standard-chart
lastActiveTime: '2023-12-18T17:59:55Z'
originalReplicaCount: 1
scaleTargetGVKR:
group: apps
kind: Deployment
resource: deployments
version: v1
scaleTargetKind: apps/v1.Deployment

0 comments on commit 9bc9ff9

Please sign in to comment.