I use Kafka with the Python SDK and run the Code in a Kubernetes 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:
- Perform a HTTP request => does not work with Kafka
- Process the LAST log message and check the date. => does not work, since I don´t know when the next message will be processed.
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:
- Am I right and the readinessprobe and livenessProbe do absolutely nothing?
- If yes, what would be an option to perform these probs on my pods?