feat: Implement KafkaConnector,KafkaBridge CRD health checks (#18316)

This commit is contained in:
lenglet-k
2024-05-21 11:10:53 +02:00
committed by GitHub
parent e0968177e0
commit f13861740c
10 changed files with 333 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
local hs = {}
if obj.status ~= nil then
if obj.status.conditions ~= nil then
for i, condition in ipairs(obj.status.conditions) do
if condition.type == "NotReady" and condition.status == "True" then
hs.status = "Degraded"
hs.message = condition.message
return hs
end
if condition.type == "Ready" and condition.status == "True" then
hs.status = "Healthy"
hs.message = ""
return hs
end
end
end
end
hs.status = "Progressing"
hs.message = "Waiting for KafkaBridge"
return hs

View File

@@ -0,0 +1,12 @@
tests:
- healthStatus:
status: Progressing
message: "Waiting for KafkaBridge"
inputPath: testdata/progressing_noStatus.yaml
- healthStatus:
status: Degraded
message: "Error"
inputPath: testdata/degraded.yaml
- healthStatus:
status: Healthy
inputPath: testdata/healthy.yaml

View File

@@ -0,0 +1,54 @@
apiVersion: kafka.strimzi.io/v1beta1
kind: KafkaBridge
metadata:
creationTimestamp: "2020-02-13T14:03:15Z"
deletionGracePeriodSeconds: 0
deletionTimestamp: "2020-05-28T10:29:44Z"
finalizers:
- foregroundDeletion
generation: 25
labels:
app.kubernetes.io/instance: kafka-bridge
name: kafka-bridge
namespace: strimzi
resourceVersion: "43088521"
selfLink: /apis/kafka.strimzi.io/v1beta1/namespaces/strimzi/kafkabridge/kafka
uid: 941ae21d-4e69-11ea-a53d-06e66a171f98
spec:
authentication:
passwordSecret:
password: password
secretName: kafka-bridge
type: scram-sha-512
username: kafka-bridge
bootstrapServers: 'kafka-bootstrap:9095'
enableMetrics: true
http:
port: 8080
logging:
loggers:
kafka.root.logger.level: DEBUG
logger.send.level: DEBUG
logger.send.name: http.openapi.operation.send
type: inline
producer:
config:
ssl.cipher.suites: TLS_AES_256_GCM_SHA384
ssl.enabled.protocols: TLSv1.3
ssl.protocol: TLSv1.3
replicas: 1
tls:
trustedCertificates:
- certificate: ca.crt
secretName: kafka-cluster-cluster-ca-cert
status:
conditions:
- lastTransitionTime: '2024-05-15T09:34:44.930056634Z'
status: "True"
type: NotReady
message: "Error"
labelSelector: >-
strimzi.io/cluster=kafka-bridge,strimzi.io/name=kafka-bridge-bridge,strimzi.io/kind=KafkaBridge
observedGeneration: 14
replicas: 1
url: 'http://kafka-bridge-bridge-service.strimzi.svc:8080'

View File

@@ -0,0 +1,53 @@
apiVersion: kafka.strimzi.io/v1beta1
kind: KafkaBridge
metadata:
creationTimestamp: "2020-02-13T14:03:15Z"
deletionGracePeriodSeconds: 0
deletionTimestamp: "2020-05-28T10:29:44Z"
finalizers:
- foregroundDeletion
generation: 25
labels:
app.kubernetes.io/instance: kafka-bridge
name: kafka-bridge
namespace: strimzi
resourceVersion: "43088521"
selfLink: /apis/kafka.strimzi.io/v1beta1/namespaces/strimzi/kafkabridge/kafka
uid: 941ae21d-4e69-11ea-a53d-06e66a171f98
spec:
authentication:
passwordSecret:
password: password
secretName: kafka-bridge
type: scram-sha-512
username: kafka-bridge
bootstrapServers: 'kafka-bootstrap:9095'
enableMetrics: true
http:
port: 8080
logging:
loggers:
kafka.root.logger.level: DEBUG
logger.send.level: DEBUG
logger.send.name: http.openapi.operation.send
type: inline
producer:
config:
ssl.cipher.suites: TLS_AES_256_GCM_SHA384
ssl.enabled.protocols: TLSv1.3
ssl.protocol: TLSv1.3
replicas: 1
tls:
trustedCertificates:
- certificate: ca.crt
secretName: kafka-cluster-cluster-ca-cert
status:
conditions:
- lastTransitionTime: '2024-05-15T09:34:44.930056634Z'
status: 'True'
type: Ready
labelSelector: >-
strimzi.io/cluster=kafka-bridge,strimzi.io/name=kafka-bridge-bridge,strimzi.io/kind=KafkaBridge
observedGeneration: 14
replicas: 1
url: 'http://kafka-bridge-bridge-service.strimzi.svc:8080'

View File

@@ -0,0 +1,43 @@
apiVersion: kafka.strimzi.io/v1beta1
kind: KafkaBridge
metadata:
creationTimestamp: "2020-02-13T14:03:15Z"
deletionGracePeriodSeconds: 0
deletionTimestamp: "2020-05-28T10:29:44Z"
finalizers:
- foregroundDeletion
generation: 25
labels:
app.kubernetes.io/instance: kafka-bridge
name: kafka-bridge
namespace: strimzi
resourceVersion: "43088521"
selfLink: /apis/kafka.strimzi.io/v1beta1/namespaces/strimzi/kafkabridge/kafka
uid: 941ae21d-4e69-11ea-a53d-06e66a171f98
spec:
authentication:
passwordSecret:
password: password
secretName: kafka-bridge
type: scram-sha-512
username: kafka-bridge
bootstrapServers: 'kafka-bootstrap:9095'
enableMetrics: true
http:
port: 8080
logging:
loggers:
kafka.root.logger.level: DEBUG
logger.send.level: DEBUG
logger.send.name: http.openapi.operation.send
type: inline
producer:
config:
ssl.cipher.suites: TLS_AES_256_GCM_SHA384
ssl.enabled.protocols: TLSv1.3
ssl.protocol: TLSv1.3
replicas: 1
tls:
trustedCertificates:
- certificate: ca.crt
secretName: kafka-cluster-cluster-ca-cert

View File

@@ -0,0 +1,21 @@
local hs = {}
if obj.status ~= nil then
if obj.status.conditions ~= nil then
for i, condition in ipairs(obj.status.conditions) do
if condition.type == "NotReady" and condition.status == "True" then
hs.status = "Degraded"
hs.message = condition.message
return hs
end
if condition.type == "Ready" and condition.status == "True" then
hs.status = "Healthy"
hs.message = ""
return hs
end
end
end
end
hs.status = "Progressing"
hs.message = "Waiting for KafkaConnector"
return hs

View File

@@ -0,0 +1,12 @@
tests:
- healthStatus:
status: Progressing
message: "Waiting for KafkaConnector"
inputPath: testdata/progressing_noStatus.yaml
- healthStatus:
status: Degraded
message: "The following tasks have failed: 0, see connectorStatus for more details."
inputPath: testdata/degraded.yaml
- healthStatus:
status: Healthy
inputPath: testdata/healthy.yaml

View File

@@ -0,0 +1,51 @@
apiVersion: kafka.strimzi.io/v1beta1
kind: KafkaConnector
metadata:
creationTimestamp: "2020-02-13T14:03:15Z"
deletionGracePeriodSeconds: 0
deletionTimestamp: "2020-05-28T10:29:44Z"
finalizers:
- foregroundDeletion
generation: 25
labels:
app.kubernetes.io/instance: kafka-connect
strimzi.io/cluster: strimzi-connect-cluster
name: my-connector
namespace: strimzi
resourceVersion: "43088521"
selfLink: /apis/kafka.strimzi.io/v1beta1/namespaces/strimzi/kafkaconnector/kafka
uid: 941ae21d-4e69-11ea-a53d-06e66a171f98
spec:
class: org.apache.kafka.connect.file.FileStreamSourceConnector
tasksMax: 2
config:
file: "/opt/kafka/LICENSE"
topic: my-topic
status:
autoRestart:
count: 1
lastRestartTimestamp: '2024-05-17T15:55:21.611546835Z'
conditions:
- lastTransitionTime: '2024-05-17T15:57:09.059039185Z'
message: >-
The following tasks have failed: 0, see connectorStatus for more
details.
reason: Throwable
status: 'True'
type: NotReady
connectorStatus:
connector:
state: RUNNING
worker_id: >-
kafka-connect-cluster-connect-0.kafka-connect-cluster-connect.strimzi.svc:8083
name: my-connector
tasks:
- id: 0
state: FAILED
trace: "org.apache.kafka.connect.errors.ConnectException: Tolerance exceeded in error handler..."
worker_id: >-
kafka-connect-cluster-connect-0.kafka-connect-cluster-connect.strimzi.svc:8083
type: source
observedGeneration: 1
tasksMax: 1
topics: []

View File

@@ -0,0 +1,43 @@
apiVersion: kafka.strimzi.io/v1beta1
kind: KafkaConnector
metadata:
creationTimestamp: "2020-02-13T14:03:15Z"
deletionGracePeriodSeconds: 0
deletionTimestamp: "2020-05-28T10:29:44Z"
finalizers:
- foregroundDeletion
generation: 25
labels:
app.kubernetes.io/instance: kafka-connect
strimzi.io/cluster: strimzi-connect-cluster
name: my-connector
namespace: strimzi
resourceVersion: "43088521"
selfLink: /apis/kafka.strimzi.io/v1beta1/namespaces/strimzi/kafkaconnector/kafka
uid: 941ae21d-4e69-11ea-a53d-06e66a171f98
spec:
class: org.apache.kafka.connect.file.FileStreamSourceConnector
tasksMax: 2
config:
file: "/opt/kafka/LICENSE"
topic: my-topic
status:
conditions:
- lastTransitionTime: '2024-05-17T15:55:22.356665885Z'
status: 'True'
type: Ready
connectorStatus:
connector:
state: RUNNING
worker_id: >-
kafka-connect-cluster-connect-0.kafka-connect-cluster-connect.strimzi.svc:8083
name: my-connector
tasks:
- id: 0
state: RUNNING
worker_id: >-
kafka-connect-cluster-connect-0.kafka-connect-cluster-connect.strimzi.svc:8083
type: source
observedGeneration: 1
tasksMax: 1
topics: []

View File

@@ -0,0 +1,23 @@
apiVersion: kafka.strimzi.io/v1beta1
kind: KafkaConnector
metadata:
creationTimestamp: "2020-02-13T14:03:15Z"
deletionGracePeriodSeconds: 0
deletionTimestamp: "2020-05-28T10:29:44Z"
finalizers:
- foregroundDeletion
generation: 25
labels:
app.kubernetes.io/instance: kafka-connect
strimzi.io/cluster: strimzi-connect-cluster
name: my-connector
namespace: strimzi
resourceVersion: "43088521"
selfLink: /apis/kafka.strimzi.io/v1beta1/namespaces/strimzi/kafkaconnector/kafka
uid: 941ae21d-4e69-11ea-a53d-06e66a171f98
spec:
class: org.apache.kafka.connect.file.FileStreamSourceConnector
tasksMax: 2
config:
file: "/opt/kafka/LICENSE"
topic: my-topic