From 12d1f1056b17312cd59eabc22d52fbf4c02abb54 Mon Sep 17 00:00:00 2001 From: valtzu Date: Sun, 15 Sep 2024 21:01:24 +0300 Subject: [PATCH] Add k3s services --- .../lib/systemd/system-preset/00-mkosi.preset | 5 ++-- .../usr/lib/systemd/system/k3s-agent.service | 27 +++++++++++++++++++ .../usr/lib/systemd/system/k3s.service | 27 +++++++++++++++++++ 3 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 mkosi.extra/usr/lib/systemd/system/k3s-agent.service create mode 100644 mkosi.extra/usr/lib/systemd/system/k3s.service diff --git a/mkosi.extra/usr/lib/systemd/system-preset/00-mkosi.preset b/mkosi.extra/usr/lib/systemd/system-preset/00-mkosi.preset index d6ca243..d482340 100644 --- a/mkosi.extra/usr/lib/systemd/system-preset/00-mkosi.preset +++ b/mkosi.extra/usr/lib/systemd/system-preset/00-mkosi.preset @@ -1,4 +1,5 @@ enable sshd-keygen.service -# systemd-repart already runs in initrd, no reason to re-run it after switching to rootfs -disable systemd-repart.service +# Make sure k3s is not enabled by default +disable k3s.service +disable k3s-agent.service diff --git a/mkosi.extra/usr/lib/systemd/system/k3s-agent.service b/mkosi.extra/usr/lib/systemd/system/k3s-agent.service new file mode 100644 index 0000000..59ed781 --- /dev/null +++ b/mkosi.extra/usr/lib/systemd/system/k3s-agent.service @@ -0,0 +1,27 @@ +[Unit] +Description=K3s agent +Documentation=https://k3s.io +Wants=network-online.target +After=network-online.target + +[Install] +WantedBy=multi-user.target + +[Service] +Type=notify +EnvironmentFile=-/etc/systemd/system/%n.env +KillMode=process +Delegate=yes +# Having non-zero Limit*s causes performance problems due to accounting overhead +# in the kernel. We recommend using cgroups to do container-local accounting. +LimitNOFILE=1048576 +LimitNPROC=infinity +LimitCORE=infinity +TasksMax=infinity +TimeoutStartSec=0 +Restart=always +RestartSec=5s +ExecStartPre=/bin/sh -xc '! /usr/bin/systemctl is-enabled --quiet nm-cloud-setup.service' +ExecStartPre=-/sbin/modprobe br_netfilter +ExecStartPre=-/sbin/modprobe overlay +ExecStart=/usr/bin/k3s agent diff --git a/mkosi.extra/usr/lib/systemd/system/k3s.service b/mkosi.extra/usr/lib/systemd/system/k3s.service new file mode 100644 index 0000000..3a211a2 --- /dev/null +++ b/mkosi.extra/usr/lib/systemd/system/k3s.service @@ -0,0 +1,27 @@ +[Unit] +Description=K3s server +Documentation=https://k3s.io +Wants=network-online.target +After=network-online.target + +[Install] +WantedBy=multi-user.target + +[Service] +Type=notify +EnvironmentFile=-/etc/systemd/system/%n.env +KillMode=process +Delegate=yes +# Having non-zero Limit*s causes performance problems due to accounting overhead +# in the kernel. We recommend using cgroups to do container-local accounting. +LimitNOFILE=1048576 +LimitNPROC=infinity +LimitCORE=infinity +TasksMax=infinity +TimeoutStartSec=0 +Restart=always +RestartSec=5s +ExecStartPre=/bin/sh -xc '! /usr/bin/systemctl is-enabled --quiet nm-cloud-setup.service' +ExecStartPre=-/sbin/modprobe br_netfilter +ExecStartPre=-/sbin/modprobe overlay +ExecStart=/usr/bin/k3s server