2019-09-21 14:18:42 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.virtualisation.cri-o;
|
2020-05-03 07:09:33 +00:00
|
|
|
|
2020-05-11 17:58:44 +00:00
|
|
|
crioPackage = (pkgs.cri-o.override { inherit (cfg) extraPackages; });
|
|
|
|
|
2020-05-03 07:09:33 +00:00
|
|
|
# Copy configuration files to avoid having the entire sources in the system closure
|
2020-09-16 09:44:27 +00:00
|
|
|
copyFile = filePath: pkgs.runCommandNoCC (builtins.unsafeDiscardStringContext (builtins.baseNameOf filePath)) { } ''
|
2020-05-03 07:09:33 +00:00
|
|
|
cp ${filePath} $out
|
|
|
|
'';
|
2019-09-21 14:18:42 +00:00
|
|
|
in
|
|
|
|
{
|
2020-04-24 05:57:10 +00:00
|
|
|
imports = [
|
|
|
|
(mkRenamedOptionModule [ "virtualisation" "cri-o" "registries" ] [ "virtualisation" "containers" "registries" "search" ])
|
|
|
|
];
|
|
|
|
|
2020-04-23 22:07:38 +00:00
|
|
|
meta = {
|
|
|
|
maintainers = lib.teams.podman.members;
|
|
|
|
};
|
|
|
|
|
2019-09-21 14:18:42 +00:00
|
|
|
options.virtualisation.cri-o = {
|
|
|
|
enable = mkEnableOption "Container Runtime Interface for OCI (CRI-O)";
|
|
|
|
|
|
|
|
storageDriver = mkOption {
|
2020-05-11 17:58:44 +00:00
|
|
|
type = types.enum [ "btrfs" "overlay" "vfs" ];
|
2019-09-21 14:18:42 +00:00
|
|
|
default = "overlay";
|
|
|
|
description = "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 = "Log level to be used";
|
|
|
|
};
|
|
|
|
|
|
|
|
pauseImage = mkOption {
|
2020-05-06 23:13:27 +00:00
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
description = "Override the default pause image for pod sandboxes";
|
|
|
|
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 = "Override the default pause command";
|
|
|
|
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 = "Override the default runtime";
|
|
|
|
example = [ "crun" ];
|
|
|
|
};
|
|
|
|
|
2020-05-11 17:58:44 +00:00
|
|
|
extraPackages = mkOption {
|
|
|
|
type = with types; listOf package;
|
|
|
|
default = [ ];
|
|
|
|
example = lib.literalExample ''
|
|
|
|
[
|
|
|
|
pkgs.gvisor
|
|
|
|
]
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Extra packages to be installed in the CRI-O wrapper.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
package = lib.mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = crioPackage;
|
|
|
|
internal = true;
|
|
|
|
description = ''
|
|
|
|
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 = "Override the network_dir option.";
|
|
|
|
internal = true;
|
|
|
|
};
|
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
|
|
|
|
2020-05-11 17:58:44 +00:00
|
|
|
environment.etc."crictl.yaml".source = copyFile "${pkgs.cri-o-unwrapped.src}/crictl.yaml";
|
2020-05-03 07:09:33 +00:00
|
|
|
|
2020-08-16 10:34:51 +00:00
|
|
|
environment.etc."crio/crio.conf.d/00-default.conf".text = ''
|
2019-09-21 14:18:42 +00:00
|
|
|
[crio]
|
|
|
|
storage_driver = "${cfg.storageDriver}"
|
|
|
|
|
|
|
|
[crio.image]
|
2020-05-06 23:13:27 +00:00
|
|
|
${optionalString (cfg.pauseImage != null) ''pause_image = "${cfg.pauseImage}"''}
|
|
|
|
${optionalString (cfg.pauseCommand != null) ''pause_command = "${cfg.pauseCommand}"''}
|
2019-09-21 14:18:42 +00:00
|
|
|
|
2020-04-22 22:37:04 +00:00
|
|
|
[crio.network]
|
|
|
|
plugin_dirs = ["${pkgs.cni-plugins}/bin/"]
|
2020-09-16 09:44:27 +00:00
|
|
|
${optionalString (cfg.networkDir != null) ''network_dir = "${cfg.networkDir}"''}
|
2020-04-22 22:37:04 +00:00
|
|
|
|
2019-09-21 14:18:42 +00:00
|
|
|
[crio.runtime]
|
2020-04-29 07:22:10 +00:00
|
|
|
cgroup_manager = "systemd"
|
2019-09-21 14:18:42 +00:00
|
|
|
log_level = "${cfg.logLevel}"
|
2020-08-16 10:34:51 +00:00
|
|
|
pinns_path = "${cfg.package}/bin/pinns"
|
2020-08-31 13:57:04 +00:00
|
|
|
hooks_dir = []
|
2020-05-11 19:14:12 +00:00
|
|
|
|
|
|
|
${optionalString (cfg.runtime != null) ''
|
|
|
|
default_runtime = "${cfg.runtime}"
|
|
|
|
[crio.runtime.runtimes]
|
|
|
|
[crio.runtime.runtimes.${cfg.runtime}]
|
|
|
|
''}
|
2019-09-21 14:18:42 +00:00
|
|
|
'';
|
2020-04-21 09:22:20 +00:00
|
|
|
|
2020-05-11 17:58:44 +00:00
|
|
|
environment.etc."cni/net.d/10-crio-bridge.conf".source = copyFile "${pkgs.cri-o-unwrapped.src}/contrib/cni/10-crio-bridge.conf";
|
2020-08-22 20:49:05 +00:00
|
|
|
environment.etc."cni/net.d/99-loopback.conf".source = copyFile "${pkgs.cri-o-unwrapped.src}/contrib/cni/99-loopback.conf";
|
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";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|