feat(health): Added KeptnMetric (#19210)

Signed-off-by: asamonik <49288593+asamonik@users.noreply.github.com>
This commit is contained in:
Andreas
2024-07-25 16:26:06 +02:00
committed by GitHub
parent e26c105e52
commit 326cc4a06b
6 changed files with 121 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
local hs = {}
if (obj.status.errMsg == nil or obj.status.errMsg == "") and obj.status.value ~= nil then
hs.status = "Healthy"
hs.message = "KeptnMetric is healthy"
return hs
end
if obj.status.errMsg ~= nil and obj.status.errMsg ~= "" then
hs.status = "Degraded"
hs.message = "KeptnMetric is degraded"
return hs
end
hs.status = "Progressing"
hs.message = "KeptnMetric is progressing"
return hs

View File

@@ -0,0 +1,17 @@
tests:
- healthStatus:
status: Progressing
message: "KeptnMetric is progressing"
inputPath: testdata/progressing.yaml
- healthStatus:
status: Degraded
message: "KeptnMetric is degraded"
inputPath: testdata/degraded.yaml
- healthStatus:
status: Healthy
message: "KeptnMetric is healthy"
inputPath: testdata/healthy.yaml
- healthStatus:
status: Healthy
message: "KeptnMetric is healthy"
inputPath: testdata/healthy_empty_error.yaml

View File

@@ -0,0 +1,24 @@
apiVersion: metrics.keptn.sh/v1
kind: KeptnMetric
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: >
{"apiVersion":"metrics.keptn.sh/v1","kind":"KeptnMetric","metadata":{"annotations":{},"labels":{"app.kubernetes.io/instance":"podtato-head"},"name":"available-cpus","namespace":"podtato-kubectl"},"spec":{"fetchIntervalSeconds":10,"provider":{"name":"my-provider"},"query":"sum(kube_node_status_capacity{resource='cpu'})"}}
creationTimestamp: '2024-07-16T07:34:42Z'
generation: 1
labels:
app.kubernetes.io/instance: podtato-head
name: available-cpus
namespace: podtato-kubectl
resourceVersion: '405403'
uid: c448a014-b6b6-45a4-91ff-89949b9d0fce
spec:
fetchIntervalSeconds: 10
provider:
name: my-provider
query: sum(kube_node_status_capacity{resource='cpu'})
status:
errMsg: >-
Post "http://prometheus-k8s.monitoring.svc.cluster.local:9090/api/v1/query":
dial tcp: lookup prometheus-k8s.monitoring.svc.cluster.local on
lastUpdated: '2024-07-23T12:49:44Z'

View File

@@ -0,0 +1,22 @@
apiVersion: metrics.keptn.sh/v1
kind: KeptnMetric
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: >
{"apiVersion":"metrics.keptn.sh/v1","kind":"KeptnMetric","metadata":{"annotations":{},"labels":{"app.kubernetes.io/instance":"podtato-head"},"name":"available-cpus","namespace":"podtato-kubectl"},"spec":{"fetchIntervalSeconds":10,"provider":{"name":"my-provider"},"query":"sum(kube_node_status_capacity{resource='cpu'})"}}
creationTimestamp: '2024-07-16T07:34:42Z'
generation: 1
labels:
app.kubernetes.io/instance: podtato-head
name: available-cpus
namespace: podtato-kubectl
resourceVersion: '405403'
uid: c448a014-b6b6-45a4-91ff-89949b9d0fce
spec:
fetchIntervalSeconds: 10
provider:
name: my-provider
query: sum(kube_node_status_capacity{resource='cpu'})
status:
value: '100'
lastUpdated: '2024-07-23T12:49:44Z'

View File

@@ -0,0 +1,23 @@
apiVersion: metrics.keptn.sh/v1
kind: KeptnMetric
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: >
{"apiVersion":"metrics.keptn.sh/v1","kind":"KeptnMetric","metadata":{"annotations":{},"labels":{"app.kubernetes.io/instance":"podtato-head"},"name":"available-cpus","namespace":"podtato-kubectl"},"spec":{"fetchIntervalSeconds":10,"provider":{"name":"my-provider"},"query":"sum(kube_node_status_capacity{resource='cpu'})"}}
creationTimestamp: '2024-07-16T07:34:42Z'
generation: 1
labels:
app.kubernetes.io/instance: podtato-head
name: available-cpus
namespace: podtato-kubectl
resourceVersion: '405403'
uid: c448a014-b6b6-45a4-91ff-89949b9d0fce
spec:
fetchIntervalSeconds: 10
provider:
name: my-provider
query: sum(kube_node_status_capacity{resource='cpu'})
status:
errMsg: ""
value: 100
lastUpdated: '2024-07-23T12:49:44Z'

View File

@@ -0,0 +1,21 @@
apiVersion: metrics.keptn.sh/v1
kind: KeptnMetric
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: >
{"apiVersion":"metrics.keptn.sh/v1","kind":"KeptnMetric","metadata":{"annotations":{},"labels":{"app.kubernetes.io/instance":"podtato-head"},"name":"available-cpus","namespace":"podtato-kubectl"},"spec":{"fetchIntervalSeconds":10,"provider":{"name":"my-provider"},"query":"sum(kube_node_status_capacity{resource='cpu'})"}}
creationTimestamp: '2024-07-16T07:34:42Z'
generation: 1
labels:
app.kubernetes.io/instance: podtato-head
name: available-cpus
namespace: podtato-kubectl
resourceVersion: '405403'
uid: c448a014-b6b6-45a4-91ff-89949b9d0fce
spec:
fetchIntervalSeconds: 10
provider:
name: my-provider
query: sum(kube_node_status_capacity{resource='cpu'})
status:
lastUpdated: '2024-07-23T12:49:44Z'