2018-05-21 01:09:31 +00:00
|
|
|
|
{ config, lib, pkgs, ...}:
|
2021-10-20 20:31:12 +00:00
|
|
|
|
with lib;
|
2018-05-21 01:09:31 +00:00
|
|
|
|
let
|
|
|
|
|
cfg = config.services.hadoop;
|
2021-10-20 20:31:12 +00:00
|
|
|
|
hadoopConf = "${import ./conf.nix { inherit cfg pkgs lib; }}/";
|
|
|
|
|
restartIfChanged = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
description = ''
|
|
|
|
|
Automatically restart the service on config change.
|
|
|
|
|
This can be set to false to defer restarts on clusters running critical applications.
|
|
|
|
|
Please consider the security implications of inadvertently running an older version,
|
|
|
|
|
and the possibility of unexpected behavior caused by inconsistent versions across a cluster when disabling this option.
|
|
|
|
|
'';
|
|
|
|
|
default = false;
|
|
|
|
|
};
|
2018-05-21 01:09:31 +00:00
|
|
|
|
in
|
|
|
|
|
{
|
|
|
|
|
options.services.hadoop.yarn = {
|
2021-10-20 20:31:12 +00:00
|
|
|
|
resourcemanager = {
|
2022-01-08 07:18:23 +00:00
|
|
|
|
enable = mkEnableOption "Hadoop YARN ResourceManager";
|
2021-10-20 20:31:12 +00:00
|
|
|
|
inherit restartIfChanged;
|
|
|
|
|
openFirewall = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = true;
|
|
|
|
|
description = ''
|
|
|
|
|
Open firewall ports for resourcemanager
|
|
|
|
|
'';
|
|
|
|
|
};
|
2018-05-21 01:09:31 +00:00
|
|
|
|
};
|
2021-10-20 20:31:12 +00:00
|
|
|
|
nodemanager = {
|
2022-01-08 07:18:23 +00:00
|
|
|
|
enable = mkEnableOption "Hadoop YARN NodeManager";
|
2021-10-20 20:31:12 +00:00
|
|
|
|
inherit restartIfChanged;
|
|
|
|
|
addBinBash = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = true;
|
|
|
|
|
description = ''
|
|
|
|
|
Add /bin/bash. This is needed by the linux container executor's launch script.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
openFirewall = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = true;
|
|
|
|
|
description = ''
|
|
|
|
|
Open firewall ports for nodemanager.
|
|
|
|
|
Because containers can listen on any ephemeral port, TCP ports 1024–65535 will be opened.
|
|
|
|
|
'';
|
|
|
|
|
};
|
2018-05-21 01:09:31 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
config = mkMerge [
|
|
|
|
|
(mkIf (
|
2021-11-02 16:16:48 +00:00
|
|
|
|
cfg.yarn.resourcemanager.enable || cfg.yarn.nodemanager.enable
|
2018-05-21 01:09:31 +00:00
|
|
|
|
) {
|
|
|
|
|
|
2018-07-02 15:57:31 +00:00
|
|
|
|
users.users.yarn = {
|
2018-05-21 01:09:31 +00:00
|
|
|
|
description = "Hadoop YARN user";
|
|
|
|
|
group = "hadoop";
|
|
|
|
|
uid = config.ids.uids.yarn;
|
|
|
|
|
};
|
|
|
|
|
})
|
|
|
|
|
|
2021-11-02 16:16:48 +00:00
|
|
|
|
(mkIf cfg.yarn.resourcemanager.enable {
|
2019-08-13 21:52:01 +00:00
|
|
|
|
systemd.services.yarn-resourcemanager = {
|
2018-05-21 01:09:31 +00:00
|
|
|
|
description = "Hadoop YARN ResourceManager";
|
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2021-10-20 20:31:12 +00:00
|
|
|
|
inherit (cfg.yarn.resourcemanager) restartIfChanged;
|
2018-05-21 01:09:31 +00:00
|
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
|
User = "yarn";
|
|
|
|
|
SyslogIdentifier = "yarn-resourcemanager";
|
|
|
|
|
ExecStart = "${cfg.package}/bin/yarn --config ${hadoopConf} " +
|
|
|
|
|
" resourcemanager";
|
2021-10-20 20:31:12 +00:00
|
|
|
|
Restart = "always";
|
2018-05-21 01:09:31 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
2021-10-20 20:31:12 +00:00
|
|
|
|
networking.firewall.allowedTCPPorts = (mkIf cfg.yarn.resourcemanager.openFirewall [
|
|
|
|
|
8088 # resourcemanager.webapp.address
|
|
|
|
|
8030 # resourcemanager.scheduler.address
|
|
|
|
|
8031 # resourcemanager.resource-tracker.address
|
|
|
|
|
8032 # resourcemanager.address
|
2021-11-02 06:29:58 +00:00
|
|
|
|
8033 # resourcemanager.admin.address
|
2021-10-20 20:31:12 +00:00
|
|
|
|
]);
|
2018-05-21 01:09:31 +00:00
|
|
|
|
})
|
|
|
|
|
|
2021-11-02 16:16:48 +00:00
|
|
|
|
(mkIf cfg.yarn.nodemanager.enable {
|
2021-10-20 20:31:12 +00:00
|
|
|
|
# Needed because yarn hardcodes /bin/bash in container start scripts
|
|
|
|
|
# These scripts can't be patched, they are generated at runtime
|
|
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
|
(mkIf cfg.yarn.nodemanager.addBinBash "L /bin/bash - - - - /run/current-system/sw/bin/bash")
|
|
|
|
|
];
|
|
|
|
|
|
2019-08-13 21:52:01 +00:00
|
|
|
|
systemd.services.yarn-nodemanager = {
|
2018-05-21 01:09:31 +00:00
|
|
|
|
description = "Hadoop YARN NodeManager";
|
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2021-10-20 20:31:12 +00:00
|
|
|
|
inherit (cfg.yarn.nodemanager) restartIfChanged;
|
2018-05-21 01:09:31 +00:00
|
|
|
|
|
2021-10-20 20:31:12 +00:00
|
|
|
|
preStart = ''
|
|
|
|
|
# create log dir
|
|
|
|
|
mkdir -p /var/log/hadoop/yarn/nodemanager
|
|
|
|
|
chown yarn:hadoop /var/log/hadoop/yarn/nodemanager
|
|
|
|
|
|
|
|
|
|
# set up setuid container executor binary
|
|
|
|
|
rm -rf /run/wrappers/yarn-nodemanager/ || true
|
|
|
|
|
mkdir -p /run/wrappers/yarn-nodemanager/{bin,etc/hadoop}
|
|
|
|
|
cp ${cfg.package}/lib/${cfg.package.untarDir}/bin/container-executor /run/wrappers/yarn-nodemanager/bin/
|
|
|
|
|
chgrp hadoop /run/wrappers/yarn-nodemanager/bin/container-executor
|
|
|
|
|
chmod 6050 /run/wrappers/yarn-nodemanager/bin/container-executor
|
|
|
|
|
cp ${hadoopConf}/container-executor.cfg /run/wrappers/yarn-nodemanager/etc/hadoop/
|
|
|
|
|
'';
|
2018-05-21 01:09:31 +00:00
|
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
|
User = "yarn";
|
|
|
|
|
SyslogIdentifier = "yarn-nodemanager";
|
2021-10-20 20:31:12 +00:00
|
|
|
|
PermissionsStartOnly = true;
|
2018-05-21 01:09:31 +00:00
|
|
|
|
ExecStart = "${cfg.package}/bin/yarn --config ${hadoopConf} " +
|
|
|
|
|
" nodemanager";
|
2021-10-20 20:31:12 +00:00
|
|
|
|
Restart = "always";
|
2018-05-21 01:09:31 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
2021-10-20 20:31:12 +00:00
|
|
|
|
|
|
|
|
|
networking.firewall.allowedTCPPortRanges = [
|
|
|
|
|
(mkIf (cfg.yarn.nodemanager.openFirewall) {from = 1024; to = 65535;})
|
|
|
|
|
];
|
2018-05-21 01:09:31 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
];
|
|
|
|
|
}
|