Skip to content

Instantly share code, notes, and snippets.

@mak3r
Created July 1, 2024 14:17
Show Gist options
  • Save mak3r/daa7c84c24f2c0e4faac6e2ca16e6d27 to your computer and use it in GitHub Desktop.
Save mak3r/daa7c84c24f2c0e4faac6e2ca16e6d27 to your computer and use it in GitHub Desktop.
Explicitly kill all k3s containers at system shutdown

Explicitly kill all k3s containers at system shutdown

Put the file in /etc/systemd/system/shutdown-k3s.service and then enable the service using

systemctl enable shutdown-k3s.service

Also note that this service name shutdown-k3s must not start with k3s-, otherwise the k3s-killall.sh script would also try to stop this service and cause problems.

[Unit]
Description=Kill containerd-shims on shutdown
DefaultDependencies=false
Before=shutdown.target umount.target
[Service]
ExecStart=/usr/local/bin/k3s-killall.sh
Type=oneshot
[Install]
WantedBy=shutdown.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment