I want the pods running in my cluster to save their logs just before termination somewhere, so that I can access these logs later and know the termination reason. <br /> Can this be accomplished using the PreStop hook? If yes, please guide me how to do so. <br /> Any other approaches are also welcomed.
Use fluentd or fluent bit to send logs to a log aggregator system such as elastic search(EFK stack) or splunk.
Fluentd can run as daemonset in each node and send logs to EFK/Splunk.
Fluentbit can run as a sidecar and send logs to EFK/Splunk
https://kubernetes.io/docs/concepts/cluster-administration/logging/#basic-logging-in-kubernetes