f3c18b0f79
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
20 lines
1.2 KiB
Plaintext
20 lines
1.2 KiB
Plaintext
# Note: This dropin only works with kubeadm and kubelet v1.11+
|
|
[Service]
|
|
Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf"
|
|
Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml"
|
|
# This is a file that "kubeadm init" and "kubeadm join" generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically
|
|
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env
|
|
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use
|
|
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.
|
|
EnvironmentFile=-/etc/sysconfig/kubelet
|
|
ExecStart=
|
|
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS
|
|
ExecStartPre=-/usr/local/sbin/sanitize_kubelet_reserved_cpus.sh /etc/sysconfig/kubelet
|
|
ExecStartPre=-/usr/bin/kubelet-cgroup-setup.sh
|
|
ExecStartPost=/bin/bash -c 'echo $MAINPID > /var/run/kubelet.pid;'
|
|
ExecStopPost=/bin/rm -f /var/run/kubelet.pid
|
|
ExecStopPost=-/usr/local/sbin/k8s-container-cleanup
|
|
Restart=always
|
|
StartLimitInterval=0
|
|
RestartSec=10
|