improve nomad deployment
This commit is contained in:
parent
c485214385
commit
08060dced9
|
@ -338,7 +338,12 @@
|
||||||
for h in server9 server10 ; do
|
for h in server9 server10 ; do
|
||||||
echo Sharing with $h
|
echo Sharing with $h
|
||||||
ssh root@$h.cluster.zentralwerk.org -- \
|
ssh root@$h.cluster.zentralwerk.org -- \
|
||||||
nix copy --from https://hydra.hq.c3d2.de $JOB
|
bash -e <<EOF
|
||||||
|
nix copy --from https://hydra.hq.c3d2.de $JOB
|
||||||
|
mkdir -p /glusterfs/fast/microvms/${name}
|
||||||
|
chown microvm:kvm /glusterfs/fast/microvms/${name}
|
||||||
|
chmod 0775 /glusterfs/fast/microvms/${name}
|
||||||
|
EOF
|
||||||
done
|
done
|
||||||
|
|
||||||
echo Now starting the job
|
echo Now starting the job
|
||||||
|
|
|
@ -5,13 +5,12 @@ let
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
microvm = {
|
microvm = {
|
||||||
hypervisor = "qemu";
|
|
||||||
mem = 2048;
|
mem = 2048;
|
||||||
};
|
};
|
||||||
|
|
||||||
c3d2.deployment = {
|
c3d2.deployment = {
|
||||||
server = "server10";
|
|
||||||
mounts = [ "etc" "home" "var"];
|
mounts = [ "etc" "home" "var"];
|
||||||
|
mountBase = "/glusterfs/fast/microvms/${config.networking.hostName}";
|
||||||
};
|
};
|
||||||
|
|
||||||
networking = {
|
networking = {
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
{
|
{
|
||||||
c3d2.deployment = {
|
c3d2.deployment = {
|
||||||
server = "server10";
|
server = "server10";
|
||||||
mounts = [ "etc" "var"];
|
mounts = [];
|
||||||
|
mountBase = "/glusterfs/fast/microvms/${config.networking.hostName}";
|
||||||
};
|
};
|
||||||
|
|
||||||
networking.hostName = "mucbot";
|
networking.hostName = "mucbot";
|
||||||
|
|
|
@ -29,7 +29,8 @@ in
|
||||||
{
|
{
|
||||||
options.c3d2.deployment = with lib; {
|
options.c3d2.deployment = with lib; {
|
||||||
server = mkOption {
|
server = mkOption {
|
||||||
type = types.enum [ "server9" "server10" ];
|
type = with types; nullOr (enum [ "server9" "server10" ]);
|
||||||
|
default = null;
|
||||||
description = "Server that is supposed to host this MicroVM.";
|
description = "Server that is supposed to host this MicroVM.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -47,6 +48,14 @@ in
|
||||||
type = with types; listOf str;
|
type = with types; listOf str;
|
||||||
default = [ "etc" ];
|
default = [ "etc" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mountBase = mkOption {
|
||||||
|
description = ''
|
||||||
|
Location (ZFS dataset, ...) where all the shares live.
|
||||||
|
'';
|
||||||
|
type = types.path;
|
||||||
|
default = "/var/lib/microvms/${hostName}";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config.system.build = with pkgs; {
|
config.system.build = with pkgs; {
|
||||||
|
@ -78,10 +87,11 @@ in
|
||||||
pkgs.writeScript "virtiofsd-${hostName}-${tag}" ''
|
pkgs.writeScript "virtiofsd-${hostName}-${tag}" ''
|
||||||
#!${pkgs.runtimeShell} -e
|
#!${pkgs.runtimeShell} -e
|
||||||
cd ${stateDir}
|
cd ${stateDir}
|
||||||
|
mkdir -p ${source}
|
||||||
exec ${pkgs.virtiofsd}/bin/virtiofsd \
|
exec ${pkgs.virtiofsd}/bin/virtiofsd \
|
||||||
--socket-path=${socket} \
|
--socket-path=${socket} \
|
||||||
--socket-group=kvm \
|
--socket-group=kvm \
|
||||||
--shared-dir=${builtins.replaceStrings ["/var/lib/microvms/${hostName}"] [stateDir] source} \
|
--shared-dir=${source} \
|
||||||
--sandbox=none
|
--sandbox=none
|
||||||
'';
|
'';
|
||||||
# change working directory before starting hypervisor,
|
# change working directory before starting hypervisor,
|
||||||
|
@ -99,7 +109,7 @@ in
|
||||||
datacenters = ["c3d2"]
|
datacenters = ["c3d2"]
|
||||||
type = "service"
|
type = "service"
|
||||||
|
|
||||||
group "microvm" {
|
group "nixos-${config.system.nixos.label}" {
|
||||||
count = 1
|
count = 1
|
||||||
restart { attempts = 1 }
|
restart { attempts = 1 }
|
||||||
${lib.concatMapStrings (interface@{ id, ... }: ''
|
${lib.concatMapStrings (interface@{ id, ... }: ''
|
||||||
|
@ -157,6 +167,10 @@ in
|
||||||
# No server/router runs any untrusted user code
|
# No server/router runs any untrusted user code
|
||||||
"mitigations=off"
|
"mitigations=off"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# stable uid is useful across glusterfs
|
||||||
|
users.users.microvm.uid = 997;
|
||||||
|
|
||||||
microvm = {
|
microvm = {
|
||||||
hypervisor = lib.mkDefault "cloud-hypervisor";
|
hypervisor = lib.mkDefault "cloud-hypervisor";
|
||||||
mem = lib.mkDefault 512;
|
mem = lib.mkDefault 512;
|
||||||
|
@ -183,7 +197,7 @@ in
|
||||||
else let
|
else let
|
||||||
tag = builtins.replaceStrings ["/"] ["_"] dir;
|
tag = builtins.replaceStrings ["/"] ["_"] dir;
|
||||||
in {
|
in {
|
||||||
source = "/var/lib/microvms/${hostName}/${dir}";
|
source = "${config.c3d2.deployment.mountBase}/${dir}";
|
||||||
mountPoint = "/${dir}";
|
mountPoint = "/${dir}";
|
||||||
inherit tag;
|
inherit tag;
|
||||||
proto = "virtiofs";
|
proto = "virtiofs";
|
||||||
|
|
Loading…
Reference in New Issue