This is not related to exam. But i go struck with one of the work. I do have two . . .

Chandru M:
This is not related to exam. But i go struck with one of the work. I do have two containers in a single pod. One The actual service and the other is side car container writing logs to Kafka. When the pod is shutdown gracefully. i want to make sure the logs are completely written into Kafka. Any help will be much appreciated.

Mayur Sharma:
@Chandru M Solution already exist for this behavior like Fluentd.

check below to get started – https://www.youtube.com/watch?v=adbTN9h-u2M

Mayur Sharma:
Another one from Nana’s youtube channel – https://www.youtube.com/watch?v=5ofsNyHZwWE

Mariusz Gomse:
Adding to the above I think that case written by @Chandru M is perfect for PreStop container hook: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks

Chandru M:
Thanks for the suggestion. The side car container actually logs the data to Kafka. My only challenge is the Control pane should wait until the SIde car container completes the balance logging to the Kafka topic. I dont want to miss any data because of the control pane shutting down my pod. ie. The control pane should wait till the side car container completes logging.

Chandru M:
Control plane will not wait for the pre stop hook to complete its activity.

Rocky:
@Chandru M you can try increasing the termination grace period. Pls refer to the k8s doc mentioned above; let me know if I am missing anything.

“Kubernetes sends the preStop event immediately before the Container is terminated. Kubernetes’ management of the Container blocks until the preStop handler completes, unless the Pod’s grace period expires.”

unnivkn:
@Chandru why can’t you implement this with statefulsets ?