mirror of
https://github.com/argoproj/argo-cd.git
synced 2026-02-20 01:28:45 +01:00
feat: add health-checks for eck elastic beat (#16563)
* feat: add health-checks for eck elastic beat Signed-off-by: ebuildy <ebuildy@gmail.com> * fix tests Signed-off-by: ebuildy <ebuildy@gmail.com> --------- Signed-off-by: ebuildy <ebuildy@gmail.com>
This commit is contained in:
31
resource_customizations/beat.k8s.elastic.co/Beat/health.lua
Normal file
31
resource_customizations/beat.k8s.elastic.co/Beat/health.lua
Normal file
@@ -0,0 +1,31 @@
|
||||
local hs = {}
|
||||
|
||||
if obj.status ~= nil and (obj.status.health ~= nil or obj.status.expectedNodes ~= nil) then
|
||||
if obj.status.health == "red" then
|
||||
hs.status = "Degraded"
|
||||
hs.message = "Elastic Beat status is Red"
|
||||
return hs
|
||||
elseif obj.status.health == "green" then
|
||||
hs.status = "Healthy"
|
||||
hs.message = "Elastic Beat status is Green"
|
||||
return hs
|
||||
elseif obj.status.health == "yellow" then
|
||||
if obj.status.availableNodes ~= nil and obj.status.expectedNodes ~= nil then
|
||||
hs.status = "Progressing"
|
||||
hs.message = "Elastic Beat status is deploying, there is " .. obj.status.availableNodes .. " instance(s) on " .. obj.status.expectedNodes .. " expected"
|
||||
return hs
|
||||
else
|
||||
hs.status = "Progressing"
|
||||
hs.message = "Elastic Beat phase is progressing"
|
||||
return hs
|
||||
end
|
||||
elseif obj.status.health == nil then
|
||||
hs.status = "Progressing"
|
||||
hs.message = "Elastic Beat phase is progressing"
|
||||
return hs
|
||||
end
|
||||
end
|
||||
|
||||
hs.status = "Unknown"
|
||||
hs.message = "Elastic Beat status is unknown. Ensure your ArgoCD is current and then check for/file a bug report: https://github.com/argoproj/argo-cd/issues"
|
||||
return hs
|
||||
@@ -0,0 +1,29 @@
|
||||
tests:
|
||||
- healthStatus:
|
||||
status: Healthy
|
||||
message: "Elastic Beat status is Green"
|
||||
inputPath: testdata/ready_green.yaml
|
||||
- healthStatus:
|
||||
status: Progressing
|
||||
message: "Elastic Beat phase is progressing"
|
||||
inputPath: testdata/ready_yellow_single_node.yaml
|
||||
- healthStatus:
|
||||
status: Progressing
|
||||
message: "Elastic Beat status is deploying, there is 1 instance(s) on 2 expected"
|
||||
inputPath: testdata/ready_yellow.yaml
|
||||
- healthStatus:
|
||||
status: Progressing
|
||||
message: "Elastic Beat phase is progressing"
|
||||
inputPath: testdata/progressing.yaml
|
||||
- healthStatus:
|
||||
status: Degraded
|
||||
message: "Elastic Beat status is Red"
|
||||
inputPath: testdata/ready_red.yaml
|
||||
- healthStatus:
|
||||
status: Unknown
|
||||
message: "Elastic Beat status is unknown. Ensure your ArgoCD is current and then check for/file a bug report: https://github.com/argoproj/argo-cd/issues"
|
||||
inputPath: testdata/unknown.yaml
|
||||
- healthStatus:
|
||||
status: Unknown
|
||||
message: "Elastic Beat status is unknown. Ensure your ArgoCD is current and then check for/file a bug report: https://github.com/argoproj/argo-cd/issues"
|
||||
inputPath: testdata/invalid.yaml
|
||||
12
resource_customizations/beat.k8s.elastic.co/Beat/testdata/invalid.yaml
vendored
Normal file
12
resource_customizations/beat.k8s.elastic.co/Beat/testdata/invalid.yaml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
apiVersion: beat.k8s.elastic.co/v1beta1
|
||||
kind: Beat
|
||||
metadata:
|
||||
name: quickstart
|
||||
spec:
|
||||
version: 8.8.8
|
||||
type: metricbeat
|
||||
status:
|
||||
expectedNodes: 1
|
||||
health: invalid
|
||||
observedGeneration: 1
|
||||
version: 8.8.1
|
||||
11
resource_customizations/beat.k8s.elastic.co/Beat/testdata/progressing.yaml
vendored
Normal file
11
resource_customizations/beat.k8s.elastic.co/Beat/testdata/progressing.yaml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
apiVersion: beat.k8s.elastic.co/v1beta1
|
||||
kind: Beat
|
||||
metadata:
|
||||
name: quickstart
|
||||
spec:
|
||||
version: 8.8.8
|
||||
type: metricbeat
|
||||
status:
|
||||
expectedNodes: 1
|
||||
observedGeneration: 1
|
||||
version: 8.8.1
|
||||
13
resource_customizations/beat.k8s.elastic.co/Beat/testdata/ready_green.yaml
vendored
Normal file
13
resource_customizations/beat.k8s.elastic.co/Beat/testdata/ready_green.yaml
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
apiVersion: beat.k8s.elastic.co/v1beta1
|
||||
kind: Beat
|
||||
metadata:
|
||||
name: quickstart
|
||||
spec:
|
||||
version: 8.8.8
|
||||
type: metricbeat
|
||||
status:
|
||||
expectedNodes: 1
|
||||
availableNodes: 1
|
||||
health: green
|
||||
observedGeneration: 1
|
||||
version: 8.8.1
|
||||
10
resource_customizations/beat.k8s.elastic.co/Beat/testdata/ready_red.yaml
vendored
Normal file
10
resource_customizations/beat.k8s.elastic.co/Beat/testdata/ready_red.yaml
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
apiVersion: beat.k8s.elastic.co/v1beta1
|
||||
kind: Beat
|
||||
metadata:
|
||||
name: quickstart
|
||||
spec:
|
||||
version: 8.8.8
|
||||
type: metricbeat
|
||||
status:
|
||||
expectedNodes: 1
|
||||
health: red
|
||||
11
resource_customizations/beat.k8s.elastic.co/Beat/testdata/ready_yellow.yaml
vendored
Normal file
11
resource_customizations/beat.k8s.elastic.co/Beat/testdata/ready_yellow.yaml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
apiVersion: beat.k8s.elastic.co/v1beta1
|
||||
kind: Beat
|
||||
metadata:
|
||||
name: quickstart
|
||||
spec:
|
||||
version: 8.8.8
|
||||
type: metricbeat
|
||||
status:
|
||||
availableNodes: 1
|
||||
expectedNodes: 2
|
||||
health: yellow
|
||||
10
resource_customizations/beat.k8s.elastic.co/Beat/testdata/ready_yellow_single_node.yaml
vendored
Normal file
10
resource_customizations/beat.k8s.elastic.co/Beat/testdata/ready_yellow_single_node.yaml
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
apiVersion: beat.k8s.elastic.co/v1beta1
|
||||
kind: Beat
|
||||
metadata:
|
||||
name: quickstart
|
||||
spec:
|
||||
version: 8.8.8
|
||||
type: metricbeat
|
||||
status:
|
||||
expectedNodes: 1
|
||||
health: yellow
|
||||
8
resource_customizations/beat.k8s.elastic.co/Beat/testdata/unknown.yaml
vendored
Normal file
8
resource_customizations/beat.k8s.elastic.co/Beat/testdata/unknown.yaml
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
apiVersion: beat.k8s.elastic.co/v1beta1
|
||||
kind: Beat
|
||||
metadata:
|
||||
name: quickstart
|
||||
spec:
|
||||
version: 8.8.8
|
||||
type: metricbeat
|
||||
status: {}
|
||||
Reference in New Issue
Block a user