I use Kafka with the Python SDK and run the Code in a Kube.netes Cluster. The "main" consumer function looks like this:
def consume(self):
logger.info("Consumer starting listening.")
try:
while True:
msg = self.consumer.poll(timeout=0.1)
if msg is None:
continue
if msg.error():
if msg.error().code() == KafkaError._PARTITION_EOF:
continue
continue
try:
received_message = self.json_deserialize(msg.value())
except ValidationError as err:
self.consumer.commit(message=msg)
continue
processed_message = self.processor(received_message)
self.producer.send_object(
processed_message,
topic=self.producer.topics[0], # Success topic (aus config)
trace_id=processed_message.header.trace_id,
)
self.consumer.commit(message=msg)
except KeyboardInterrupt:
logger.info("Received keyboard interrupt signal")
finally:
self.stop()
So the code performs a while
loop and processes the message.
I have researched the following options:
My colleagues gave me the following probes, but in my Opinion they do absolutly nothing?!
readinessProbe:
exec:
command: [ '/bin/bash' ]
args: [ '-c', 'echo readinessProbe erfolgreich' ]
initialDelaySeconds: ${{READINESS_INITIAL_DELAY_SECONDS}}
timeoutSeconds: ${{READINESS_TIMEOUT}}
livenessProbe:
exec:
command: [ '/bin/bash' ]
args: [ '-c', 'echo livenessProbe erfolgreich' ]
initialDelaySeconds: ${{LIVENESS_INITIAL_DELAY_SECONDS}}
timeoutSeconds: ${{LIVENESS_TIMEOUT}}
So my main Questions are:
If your probes are meant to be checking your Python pod, it doesn't matter what Kafka supports. You can wrap your Python code in a simple web server.
You're correct that echoing something is useless for checking something is ready or healthy
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.