feat(issue/#17003): implement camel.apache.org/Integration CRD health checks (#17004)

* feat: implement camel.apache.org/Integration CRD health checks

Added custom health checks for Camel-K Integration CRDs

Signed-off-by: mdebarros <migueld@debarros.me>

* chore: cleanup up main health.lua

Signed-off-by: mdebarros <miguel@debarros.me>

---------

Signed-off-by: mdebarros <migueld@debarros.me>
Signed-off-by: mdebarros <miguel@debarros.me>
Co-authored-by: mdebarros <migueld@debarros.me>
This commit is contained in:
Miguel de Barros
2024-05-30 13:35:19 +02:00
committed by GitHub
parent 4d8436b7e1
commit 1e2f5987d2
5 changed files with 192 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
local hs = {}
if obj.status ~= nil then
if obj.status.conditions ~= nil then
for i, condition in ipairs(obj.status.conditions) do
-- Let's check if something is wrong with the CRD deployment
if condition.type == "Ready" and condition.status == "False" then
hs.status = "Degraded"
hs.message = condition.message
return hs
end
-- Let's check if things are healthy with the CRD deployment
if condition.type == "Ready" and condition.status == "True" then
hs.status = "Healthy"
hs.message = condition.message
return hs
end
end
end
end
-- Otherwise let's assume that we are still busy building/deploying the Integration
hs.status = "Progressing"
hs.message = "Waiting for Integration"
return hs

View File

@@ -0,0 +1,13 @@
tests:
- healthStatus:
status: Progressing
message: "Waiting for Integration"
inputPath: testdata/progressing.yaml
- healthStatus:
status: Healthy
message: ""
inputPath: testdata/healthy.yaml
- healthStatus:
status: Degraded
message: "back-off 40s restarting failed container=integration pod=camelk-example-deployment"
inputPath: testdata/degraded.yaml

View File

@@ -0,0 +1,58 @@
apiVersion: camel.apache.org/v1
kind: Integration
metadata:
annotations:
camel.apache.org/operator.id: camel-k
generation: 1
name: camelk-example
namespace: default
spec:
sources:
- content: |
from('timer:tick?period=3000')
.setBody().constant('Hello world from Camel-K')
.to('log:info')
name: camelk-example.groovy
traits: {}
status:
conditions:
- firstTruthyTime: "2024-01-26T16:01:50Z"
lastTransitionTime: "2024-01-26T16:01:50Z"
lastUpdateTime: "2024-01-26T16:01:50Z"
message: camel-k/camel-k
reason: IntegrationPlatformAvailable
status: "True"
type: IntegrationPlatformAvailable
- firstTruthyTime: "2024-01-26T16:01:52Z"
lastTransitionTime: "2024-01-26T16:01:52Z"
lastUpdateTime: "2024-01-26T16:01:52Z"
message: kit-cmkkksgve68c73e60i60
reason: IntegrationKitAvailable
status: "True"
type: IntegrationKitAvailable
- lastTransitionTime: "2024-01-26T16:01:52Z"
lastUpdateTime: "2024-01-26T16:01:52Z"
message: different controller strategy used (knative-service)
reason: CronJobNotAvailableReason
status: "False"
type: CronJobAvailable
- lastTransitionTime: "2024-01-26T16:01:52Z"
lastUpdateTime: "2024-01-26T16:01:52Z"
message: 'controller strategy: knative-service'
reason: DeploymentAvailable
status: "False"
type: DeploymentAvailable
- firstTruthyTime: "2024-01-26T16:01:52Z"
lastTransitionTime: "2024-01-26T16:01:52Z"
lastUpdateTime: "2024-01-26T16:01:52Z"
message: Knative service name is api-example
reason: KnativeServiceAvailable
status: "True"
type: KnativeServiceAvailable
- lastTransitionTime: "2024-01-26T16:01:52Z"
lastUpdateTime: "2024-01-26T16:02:55Z"
message: back-off 40s restarting failed container=integration pod=camelk-example-deployment
reason: Error
status: "False"
type: Ready
phase: Error

View File

@@ -0,0 +1,58 @@
apiVersion: camel.apache.org/v1
kind: Integration
metadata:
annotations:
camel.apache.org/operator.id: camel-k
generation: 1
name: camelk-example
namespace: default
spec:
sources:
- content: |
from('timer:tick?period=3000')
.setBody().constant('Hello world from Camel-K')
.to('log:info')
name: camelk-example.groovy
traits: {}
status:
conditions:
- firstTruthyTime: "2024-01-26T09:13:16Z"
lastTransitionTime: "2024-01-26T09:13:16Z"
lastUpdateTime: "2024-01-26T09:13:16Z"
message: camel-k/camel-k
reason: IntegrationPlatformAvailable
status: "True"
type: IntegrationPlatformAvailable
- firstTruthyTime: "2024-01-26T09:13:19Z"
lastTransitionTime: "2024-01-26T09:13:19Z"
lastUpdateTime: "2024-01-26T09:13:19Z"
message: kit-cmkkksgve68c73e60i60
reason: IntegrationKitAvailable
status: "True"
type: IntegrationKitAvailable
- lastTransitionTime: "2024-01-26T09:13:19Z"
lastUpdateTime: "2024-01-26T09:13:19Z"
message: different controller strategy used (knative-service)
reason: CronJobNotAvailableReason
status: "False"
type: CronJobAvailable
- lastTransitionTime: "2024-01-26T09:13:19Z"
lastUpdateTime: "2024-01-26T09:13:19Z"
message: 'controller strategy: knative-service'
reason: DeploymentAvailable
status: "False"
type: DeploymentAvailable
- firstTruthyTime: "2024-01-26T09:13:19Z"
lastTransitionTime: "2024-01-26T09:13:19Z"
lastUpdateTime: "2024-01-26T09:13:19Z"
message: Knative service name is camelk-example
reason: KnativeServiceAvailable
status: "True"
type: KnativeServiceAvailable
- firstTruthyTime: "2024-01-26T09:13:31Z"
lastTransitionTime: "2024-01-26T09:13:31Z"
lastUpdateTime: "2024-01-26T09:13:31Z"
reason: KnativeServiceReady
status: "True"
type: Ready
phase: Running

View File

@@ -0,0 +1,39 @@
apiVersion: camel.apache.org/v1
kind: Integration
metadata:
annotations:
camel.apache.org/operator.id: camel-k
generation: 1
name: camelk-example
namespace: default
spec:
sources:
- content: |
from('timer:tick?period=3000')
.setBody().constant('Hello world from Camel-K')
.to('log:info')
name: camelk-example.groovy
traits: {}
status:
conditions:
- firstTruthyTime: "2024-01-26T09:13:16Z"
lastTransitionTime: "2024-01-26T09:13:16Z"
lastUpdateTime: "2024-01-26T09:13:16Z"
message: camel-k/camel-k
reason: IntegrationPlatformAvailable
status: "True"
type: IntegrationPlatformAvailable
- firstTruthyTime: "2024-01-26T09:13:19Z"
lastTransitionTime: "2024-01-26T09:13:19Z"
lastUpdateTime: "2024-01-26T09:13:19Z"
message: kit-cmkkksgve68c73e60i60
reason: IntegrationKitAvailable
status: "True"
type: IntegrationKitAvailable
- lastTransitionTime: "2024-01-26T09:13:19Z"
lastUpdateTime: "2024-01-26T09:13:19Z"
message: different controller strategy used (knative-service)
reason: CronJobNotAvailableReason
status: "False"
type: CronJobAvailable
phase: Deploying