Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement keda health-checks (#16715)
Signed-off-by: parmou <parveshmourya96@gmail.com> Co-authored-by: Blake Pettersson <blake.pettersson@gmail.com>
- Loading branch information
1 parent
7945b26
commit 9bc9ff9
Showing
7 changed files
with
291 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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
21
resource_customizations/keda.sh/ScaledObject/health_test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
52 changes: 52 additions & 0 deletions
52
resource_customizations/keda.sh/ScaledObject/testdata/keda-degraded-1.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
51 changes: 51 additions & 0 deletions
51
resource_customizations/keda.sh/ScaledObject/testdata/keda-degraded.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
51 changes: 51 additions & 0 deletions
51
resource_customizations/keda.sh/ScaledObject/testdata/keda-healthy.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
30 changes: 30 additions & 0 deletions
30
resource_customizations/keda.sh/ScaledObject/testdata/keda-progressing.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
51 changes: 51 additions & 0 deletions
51
resource_customizations/keda.sh/ScaledObject/testdata/keda-suspended.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |