2023-01-01 02:14:11 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
2019-09-21 14:18:42 +00:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.virtualisation.cri-o;
|
2020-05-03 07:09:33 +00:00
|
|
|
|
2021-02-08 21:45:02 +00:00
|
|
|
crioPackage = pkgs.cri-o.override {
|
|
|
|
extraPackages = cfg.extraPackages
|
|
|
|
++ lib.optional (builtins.elem "zfs" config.boot.supportedFilesystems) config.boot.zfs.package;
|
|
|
|
};
|
2020-05-11 17:58:44 +00:00
|
|
|
|
2021-07-16 10:29:26 +00:00
|
|
|
format = pkgs.formats.toml { };
|
|
|
|
|
|
|
|
cfgFile = format.generate "00-default.conf" cfg.settings;
|
2019-09-21 14:18:42 +00:00
|
|
|
in
|
|
|
|
{
|
2020-04-23 22:07:38 +00:00
|
|
|
meta = {
|
2021-07-16 11:07:46 +00:00
|
|
|
maintainers = teams.podman.members;
|
2020-04-23 22:07:38 +00:00
|
|
|
};
|
|
|
|
|
2019-09-21 14:18:42 +00:00
|
|
|
options.virtualisation.cri-o = {
|
|
|
|
enable = mkEnableOption (lib.mdDoc "Container Runtime Interface for OCI (CRI-O)");
|
|
|
|
|
|
|
|
storageDriver = mkOption {
|
2021-02-08 21:45:02 +00:00
|
|
|
type = types.enum [ "aufs" "btrfs" "devmapper" "overlay" "vfs" "zfs" ];
|
2019-09-21 14:18:42 +00:00
|
|
|
default = "overlay";
|
|
|
|
description = lib.mdDoc "Storage driver to be used";
|
|
|
|
};
|
|
|
|
|
|
|
|
logLevel = mkOption {
|
2020-05-11 17:58:44 +00:00
|
|
|
type = types.enum [ "trace" "debug" "info" "warn" "error" "fatal" ];
|
2019-09-21 14:18:42 +00:00
|
|
|
default = "info";
|
|
|
|
description = lib.mdDoc "Log level to be used";
|
|
|
|
};
|
|
|
|
|
|
|
|
pauseImage = mkOption {
|
2020-05-06 23:13:27 +00:00
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
description = lib.mdDoc "Override the default pause image for pod sandboxes";
|
2021-10-03 16:06:03 +00:00
|
|
|
example = "k8s.gcr.io/pause:3.2";
|
2019-09-21 14:18:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
pauseCommand = mkOption {
|
2020-05-06 23:13:27 +00:00
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
description = lib.mdDoc "Override the default pause command";
|
2021-10-03 16:06:03 +00:00
|
|
|
example = "/pause";
|
2019-09-21 14:18:42 +00:00
|
|
|
};
|
2020-05-11 17:58:44 +00:00
|
|
|
|
2020-05-11 19:14:12 +00:00
|
|
|
runtime = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
description = lib.mdDoc "Override the default runtime";
|
2021-10-03 16:06:03 +00:00
|
|
|
example = "crun";
|
2020-05-11 19:14:12 +00:00
|
|
|
};
|
|
|
|
|
2020-05-11 17:58:44 +00:00
|
|
|
extraPackages = mkOption {
|
|
|
|
type = with types; listOf package;
|
|
|
|
default = [ ];
|
2021-10-03 16:06:03 +00:00
|
|
|
example = literalExpression ''
|
2020-05-11 17:58:44 +00:00
|
|
|
[
|
|
|
|
pkgs.gvisor
|
|
|
|
]
|
|
|
|
'';
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
Extra packages to be installed in the CRI-O wrapper.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2021-07-16 11:07:46 +00:00
|
|
|
package = mkOption {
|
2020-05-11 17:58:44 +00:00
|
|
|
type = types.package;
|
|
|
|
default = crioPackage;
|
|
|
|
internal = true;
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
The final CRI-O package (including extra packages).
|
|
|
|
'';
|
|
|
|
};
|
2020-09-16 09:44:27 +00:00
|
|
|
|
|
|
|
networkDir = mkOption {
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
default = null;
|
|
|
|
description = lib.mdDoc "Override the network_dir option.";
|
|
|
|
internal = true;
|
|
|
|
};
|
2021-07-16 10:29:26 +00:00
|
|
|
|
2021-07-16 11:07:46 +00:00
|
|
|
settings = mkOption {
|
2021-07-16 10:29:26 +00:00
|
|
|
type = format.type;
|
|
|
|
default = { };
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
Configuration for cri-o, see
|
|
|
|
<https://github.com/cri-o/cri-o/blob/master/docs/crio.conf.5.md>.
|
|
|
|
'';
|
|
|
|
};
|
2019-09-21 14:18:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2020-05-11 17:58:44 +00:00
|
|
|
environment.systemPackages = [ cfg.package pkgs.cri-tools ];
|
2020-05-03 07:09:33 +00:00
|
|
|
|
2023-01-01 02:14:11 +00:00
|
|
|
environment.etc."crictl.yaml".source = "${cfg.package}/etc/crictl.yaml";
|
2020-05-03 07:09:33 +00:00
|
|
|
|
2021-07-16 10:29:26 +00:00
|
|
|
virtualisation.cri-o.settings.crio = {
|
|
|
|
storage_driver = cfg.storageDriver;
|
|
|
|
|
|
|
|
image = {
|
2021-07-16 11:07:46 +00:00
|
|
|
pause_image = mkIf (cfg.pauseImage != null) cfg.pauseImage;
|
|
|
|
pause_command = mkIf (cfg.pauseCommand != null) cfg.pauseCommand;
|
2021-07-16 10:29:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
network = {
|
|
|
|
plugin_dirs = [ "${pkgs.cni-plugins}/bin" ];
|
2021-07-16 11:07:46 +00:00
|
|
|
network_dir = mkIf (cfg.networkDir != null) cfg.networkDir;
|
2021-07-16 10:29:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
runtime = {
|
|
|
|
cgroup_manager = "systemd";
|
|
|
|
log_level = cfg.logLevel;
|
|
|
|
manage_ns_lifecycle = true;
|
|
|
|
pinns_path = "${cfg.package}/bin/pinns";
|
|
|
|
hooks_dir =
|
|
|
|
optional (config.virtualisation.containers.ociSeccompBpfHook.enable)
|
|
|
|
config.boot.kernelPackages.oci-seccomp-bpf-hook;
|
|
|
|
|
2021-07-16 11:07:46 +00:00
|
|
|
default_runtime = mkIf (cfg.runtime != null) cfg.runtime;
|
|
|
|
runtimes = mkIf (cfg.runtime != null) {
|
2021-07-16 10:29:26 +00:00
|
|
|
"${cfg.runtime}" = { };
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2020-04-21 09:22:20 +00:00
|
|
|
|
2022-12-24 18:47:19 +00:00
|
|
|
environment.etc."cni/net.d/10-crio-bridge.conflist".source = "${cfg.package}/etc/cni/net.d/10-crio-bridge.conflist";
|
|
|
|
environment.etc."cni/net.d/99-loopback.conflist".source = "${cfg.package}/etc/cni/net.d/99-loopback.conflist";
|
2021-07-16 10:29:26 +00:00
|
|
|
environment.etc."crio/crio.conf.d/00-default.conf".source = cfgFile;
|
2019-09-21 14:18:42 +00:00
|
|
|
|
2020-04-24 05:28:06 +00:00
|
|
|
# Enable common /etc/containers configuration
|
2020-04-21 09:22:20 +00:00
|
|
|
virtualisation.containers.enable = true;
|
|
|
|
|
2019-09-21 14:18:42 +00:00
|
|
|
systemd.services.crio = {
|
|
|
|
description = "Container Runtime Interface for OCI (CRI-O)";
|
|
|
|
documentation = [ "https://github.com/cri-o/cri-o" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
2020-05-11 17:58:44 +00:00
|
|
|
path = [ cfg.package ];
|
2019-09-21 14:18:42 +00:00
|
|
|
serviceConfig = {
|
|
|
|
Type = "notify";
|
2020-05-11 17:58:44 +00:00
|
|
|
ExecStart = "${cfg.package}/bin/crio";
|
2019-09-21 14:18:42 +00:00
|
|
|
ExecReload = "/bin/kill -s HUP $MAINPID";
|
|
|
|
TasksMax = "infinity";
|
|
|
|
LimitNOFILE = "1048576";
|
|
|
|
LimitNPROC = "1048576";
|
|
|
|
LimitCORE = "infinity";
|
|
|
|
OOMScoreAdjust = "-999";
|
|
|
|
TimeoutStartSec = "0";
|
|
|
|
Restart = "on-abnormal";
|
|
|
|
};
|
2021-07-16 10:29:26 +00:00
|
|
|
restartTriggers = [ cfgFile ];
|
2019-09-21 14:18:42 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|