node/core: add sysctls

Change-Id: I47b0d639a62f73f134430c5164a35eef2b5622d7
Reviewed-on: https://review.monogon.dev/c/monogon/+/2273
Tested-by: Jenkins CI
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
diff --git a/metropolis/node/core/sysctl.go b/metropolis/node/core/sysctl.go
new file mode 100644
index 0000000..eb72aa3
--- /dev/null
+++ b/metropolis/node/core/sysctl.go
@@ -0,0 +1,26 @@
+package main
+
+import (
+	"context"
+	"strconv"
+
+	"source.monogon.dev/metropolis/pkg/supervisor"
+	"source.monogon.dev/metropolis/pkg/sysctl"
+)
+
+func nodeSysctls(ctx context.Context) error {
+	const vmMaxMapCount = 2<<30 - 1
+	options := sysctl.Options{
+		// We increase the max mmap count to nearly the maximum, as it gets
+		// accounted by the cgroup memory limit.
+		"vm.max_map_count": strconv.Itoa(vmMaxMapCount),
+	}
+
+	if err := options.Apply(); err != nil {
+		return err
+	}
+
+	supervisor.Signal(ctx, supervisor.SignalHealthy)
+	supervisor.Signal(ctx, supervisor.SignalDone)
+	return nil
+}