
When executing a reboot/shutdown k8s pods are not receiving the SIGTERM signal which leads some of them to unexpected behaviour such as generating huge coredumps. There is an upstream issue regarding this: https://github.com/kubernetes/kubernetes/issues/107158 The problem seems to be systemd related but this commit addresses the problem with a workaround. This commit introduces a new script that will cleanup all the remaing pods and will be run after kubelet is stopped. The script is executed successfully when kubelet stops and the pods are stopped before the system shuts down. Closes-bug: 1964111 Signed-off-by: Daniel Safta <daniel.safta@windriver.com> Change-Id: Ia0376aa510dd0dc3983e16cd89840726c15d6c92
19 lines
479 B
Bash
Executable File
19 lines
479 B
Bash
Executable File
#!/bin/bash
|
|
# Copyright (c) 2022 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
# The script will run everytime after the kubelet service is stopped.
|
|
#
|
|
# It will detect any unfinished pod and will try to send them SIGTERM
|
|
# within 5s. If it times out, SIGKILL will be sent.
|
|
#
|
|
|
|
state=$(timeout 10 systemctl is-system-running)
|
|
|
|
if [ "$state" = "stopping" ]; then
|
|
crictl ps | cut -d ' ' -f 1 | tail -n +2 | xargs -I {} crictl stop --timeout 5 {}
|
|
fi
|
|
|
|
exit 0
|