Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Ceph cluster #106

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions modules/proxmox-ve/ceph.nix
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ let
description = "Ceph target allowing to start/stop all ceph-${daemonType} services at once";
partOf = [ "ceph.target" ];
wantedBy = [ "ceph.target" ];
wants = lib.mkIf (daemonType == "osd") (
map (daemonId: "ceph-volume@${daemonId}.service") cfg.osd.daemons
);
before = [ "ceph.target" ];
unitConfig.StopWhenUnneeded = true;
};
Expand Down Expand Up @@ -212,9 +215,9 @@ in

networking.firewall = lib.mkIf config.services.proxmox-ve.openFirewall {
allowedTCPPorts = lib.optionals cfg.mon.enable [
3300
6789
];
3300
6789
];
allowedTCPPortRanges = lib.optionals (cfg.osd.enable || cfg.msd.enable || cfg.mgr.enable) [
{
from = 6800;
Expand All @@ -240,6 +243,20 @@ in
lib.optional cfg.mon.enable (makeServices "mon" cfg.mon.daemons)
++ lib.optional cfg.mds.enable (makeServices "mds" cfg.mds.daemons)
++ lib.optional cfg.osd.enable (makeServices "osd" cfg.osd.daemons)
++ lib.optional cfg.osd.enable {
"ceph-volume@" = {
description = "Ceph Volume activation: %i";
after = [ "local-fs.target" ];
wants = [ "local-fs.target" ];
environment.CEPH_VOLUME_TIMEOUT = "10000";
serviceConfig = {
Type = "oneshot";
KillMode = "none";
ExecStart = "${pkgs.ceph}/bin/ceph-volume-systemd %i";
TimeoutSec = 0;
};
};
}
++ lib.optional cfg.rgw.enable (makeServices "rgw" cfg.rgw.daemons)
++ lib.optional cfg.mgr.enable (makeServices "mgr" cfg.mgr.daemons);
in
Expand Down
32 changes: 28 additions & 4 deletions tests/ceph.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
hashedPasswordFile = null;
};

virtualisation.emptyDiskImages = [ 1024 ];
virtualisation = {
emptyDiskImages = [ 1024 ];
memorySize = 2048;
};
};

pve2 = {
Expand All @@ -45,7 +48,10 @@
};
};

virtualisation.emptyDiskImages = [ 1024 ];
virtualisation = {
emptyDiskImages = [ 1024 ];
memorySize = 2048;
};
};

pve3 = {
Expand All @@ -62,7 +68,10 @@
};
};

virtualisation.emptyDiskImages = [ 1024 ];
virtualisation = {
emptyDiskImages = [ 1024 ];
memorySize = 2048;
};
};
};

Expand All @@ -87,10 +96,18 @@
time.sleep(10)
pve2.succeed(f"pvesh create /cluster/config/join --hostname 192.168.1.1 --fingerprint {fingerprint.strip()} --password 'mypassword'")

pve3.wait_for_unit("multi-user.target")
time.sleep(10)
pve3.succeed(f"pvesh create /cluster/config/join --hostname 192.168.1.1 --fingerprint {fingerprint.strip()} --password 'mypassword'")

assert "pve2" in pve1.succeed("pvecm nodes")
assert "pve3" in pve1.succeed("pvecm nodes")
assert "Yes" in pve1.succeed("pvecm status | grep Quorate")

pve1.succeed(
"pveceph init",
"pveceph mon create",
"pveceph mgr create",
"pveceph mon create",
"ceph-volume lvm create --osd-id 1 --data /dev/vdb --no-systemd"
)

Expand All @@ -105,5 +122,12 @@
"pveceph mon create",
"ceph-volume lvm create --osd-id 3 --data /dev/vdb --no-systemd"
)

pve1.wait_for_unit("ceph.target")
pve2.wait_for_unit("ceph.target")
pve3.wait_for_unit("ceph.target")

time.sleep(10)
assert "HEALTH_OK" in pve1.succeed("ceph status")
'';
}
2 changes: 1 addition & 1 deletion tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let
in
{
test-pve-basic = runTest ./basic.nix;
test-pve-ceph = runTest ./vm.nix;
test-pve-ceph = runTest ./ceph.nix;
test-pve-cluster = runTest ./cluster.nix;
# Disable this test until drdb gets unbroken in 24.11
# test-pve-linstor = runTest ./linstor.nix;
Expand Down