diff --git a/sysbox-eks.pkr.hcl b/sysbox-eks.pkr.hcl index e54de6a..21b42b6 100644 --- a/sysbox-eks.pkr.hcl +++ b/sysbox-eks.pkr.hcl @@ -136,6 +136,21 @@ build { ] } + provisioner "file" { + source = "systemd" + destination = "/home/ubuntu" + } + + provisioner "shell" { + inline_shebang = "/usr/bin/env bash" + inline = [ + "echo '>>> Configuring Systemd for Sysbox'", + "sudo mv /home/ubuntu/systemd/system/sysbox-mgr.service /lib/systemd/system/sysbox-mgr.service", + "sudo mv /home/ubuntu/systemd/system/sysbox-fs.service /lib/systemd/system/sysbox-fs.service", + "sudo mv /home/ubuntu/systemd/system/sysbox.service /lib/systemd/system/sysbox.service", + ] + } + provisioner "shell" { inline_shebang = "/usr/bin/env bash" inline = [ diff --git a/systemd/system/sysbox-fs.service b/systemd/system/sysbox-fs.service new file mode 100644 index 0000000..0920e71 --- /dev/null +++ b/systemd/system/sysbox-fs.service @@ -0,0 +1,24 @@ +[Unit] +Description=sysbox-fs (part of the Sysbox container runtime) +PartOf=sysbox.service +After=sysbox-mgr.service + +[Service] +Type=simple +Type=notify +ExecStart=/usr/bin/sysbox-fs +Restart=always +TimeoutStartSec=10 +TimeoutStopSec=10 +StartLimitInterval=0 +NotifyAccess=main +OOMScoreAdjust=-500 + +# The number of files opened by sysbox-fs is a function of the number of +# containers and the workloads within them. Thus we set the limit to +# infinite so to prevent "too many open files" errors. +LimitNOFILE=infinity +LimitNPROC=infinity + +[Install] +WantedBy=sysbox.service diff --git a/systemd/system/sysbox-mgr.service b/systemd/system/sysbox-mgr.service new file mode 100644 index 0000000..72f0c4b --- /dev/null +++ b/systemd/system/sysbox-mgr.service @@ -0,0 +1,23 @@ +[Unit] +Description=sysbox-mgr (part of the Sysbox container runtime) +PartOf=sysbox.service + +[Service] +Type=simple +Type=notify +ExecStart=/usr/bin/sysbox-mgr +Restart=always +TimeoutStartSec=45 +TimeoutStopSec=90 +StartLimitInterval=0 +NotifyAccess=main +OOMScoreAdjust=-500 + +# The number of files opened by sysbox-mgr is a function of the number of +# containers and the size of the rootfs within them. Thus we set the limit to +# infinite so to prevent "too many open files" errors. +LimitNOFILE=infinity +LimitNPROC=infinity + +[Install] +WantedBy=sysbox.service diff --git a/systemd/system/sysbox.service b/systemd/system/sysbox.service new file mode 100644 index 0000000..a9224e0 --- /dev/null +++ b/systemd/system/sysbox.service @@ -0,0 +1,26 @@ +# Sysbox unit to act as a wrapper of sysbox's inner components/daemons: +# sysbox-mgr and sysbox-fs. + +[Unit] +Description=Sysbox container runtime +Documentation=https://github.com/nestybox/sysbox +# rahul: using BindsTo + PartOf prevents the services that are bound +# from restarting on failure. For example, if sysbox-mgr.service is +# killed, sysbox.service will stop because of the 'BindsTo' constraint. +# However, because sysbox-mgr.service is 'PartOf' sysbox.service, +# sysbox-mgr.service will not restart until sysbox.service has started +# BindsTo=sysbox-mgr.service sysbox-fs.service +After=sysbox-mgr.service sysbox-fs.service + +# Must start before Docker/containerd to ensure "docker --restart" works +# properly with Sysbox. +Before=docker.service containerd.service + +[Service] +Type=exec +ExecStart=/bin/sh -c "/usr/bin/sysbox-runc --version && /usr/bin/sysbox-mgr --version && /usr/bin/sysbox-fs --version && /bin/sleep infinity" +Restart=always + +[Install] +# Components of this application should be started at boot time +WantedBy=multi-user.target