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

nixosModules.seaweedfs: Add Seaweedfs Module #353890

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

liberodark
Copy link
Contributor

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Nov 5, 2024
@liberodark liberodark force-pushed the seawedfs branch 2 times, most recently from f984c57 to ed49f65 Compare November 5, 2024 19:25
Copy link
Member

@BonusPlay BonusPlay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks quite ok, some initial feedback.

nixos/modules/services/network-filesystems/seaweedfs.nix Outdated Show resolved Hide resolved
nixos/modules/services/network-filesystems/seaweedfs.nix Outdated Show resolved Hide resolved
nixos/modules/services/network-filesystems/seaweedfs.nix Outdated Show resolved Hide resolved
nixos/modules/services/network-filesystems/seaweedfs.nix Outdated Show resolved Hide resolved
nixos/modules/services/network-filesystems/seaweedfs.nix Outdated Show resolved Hide resolved
@liberodark liberodark force-pushed the seawedfs branch 3 times, most recently from 017e2f1 to ebed001 Compare November 5, 2024 21:11
@liberodark liberodark marked this pull request as ready for review November 5, 2024 21:38
@liberodark
Copy link
Contributor Author

liberodark commented Nov 5, 2024

image

Some information in how to use :

This is for single Node use :

# Configuration master
  services.seaweedfs.master = {
    enable = true;
    ip = "192.168.0.185";  # IP locale
    ipBind = "0.0.0.0";
    port = 9333;
    peers = [
      "192.168.0.185:9333"  # Local IP
    ];
  };

  # Configuration volume
  services.seaweedfs.volume = {
    enable = true;
    ip = "192.168.0.185";  # IP locale
    ipBind = "0.0.0.0";
    port = 8080;
    master =  [
      "192.168.0.185:9333"  # Local IP
    ];
  };

  # Configuration filer
  services.seaweedfs.filer = {
    enable = true;
    ip = "192.168.0.185";  # IP locale
    ipBind = "0.0.0.0";
    port = 8888;
    master =  [
      "192.168.0.185:9333"  # Local IP
    ];
  };

This is for multi Node use :

# In the other node (192.168.0.186)
services.seaweedfs = {
  master = {
    enable = true;
    ip = "192.168.0.186";
    ipBind = "0.0.0.0";
    port = 9333;
    peers = [
      "192.168.0.185:9333"  # First node
      "192.168.0.186:9333"  # 2 node
      "192.168.0.187:9333"  # 3 node
    ];
  };

  volume = {
    enable = true;
    ip = "192.168.0.186";
    ipBind = "0.0.0.0";
    port = 8080;
    master = [
      "192.168.0.185:9333"  # First node
      "192.168.0.186:9333"  # 2 node
      "192.168.0.187:9333"  # 3 node
    ];
  };

  filer = {
    enable = true;
    ip = "192.168.0.186";
    ipBind = "0.0.0.0";
    port = 8888;
    master = [
      "192.168.0.185:9333"  # First node
      "192.168.0.186:9333"  # 2 node
      "192.168.0.187:9333"  # 3 node
    ];
  };
};

and add in first node :

services.seaweedfs.master = {
  peers = [
    "192.168.0.185:9333"
    "192.168.0.186:9333"
    "192.168.0.187:9333"
  ];
};

For mount seaweedfs :

systemd.services.mount-seaweedfs = {
    description = "Mount SeaweedFS";
    wantedBy = [ "multi-user.target" ];
    after = [ "network-online.target" ];
    wants = [ "network-online.target" ];
    
    serviceConfig = {
      Type = "simple";
      ExecStartPre = ''
        ${pkgs.coreutils}/bin/mkdir -p /mnt/seaweedfs
        ${pkgs.coreutils}/bin/mkdir -p /var/cache/weedfs-cache
      '';
      ExecStart = ''
        ${pkgs.seaweedfs}/bin/weed mount \
          -filer=192.168.0.185:8888,192.168.0.186:8888,192.168.0.187:8888 \
          -dir=/mnt/seaweedfs \
          -allowOthers \
          -cacheDir=/var/cache/weedfs-cache \
          -cacheCapacityMB=1000
      '';
      ExecStop = "${pkgs.fuse}/bin/fusermount -u /mnt/seaweedfs";
      Restart = "always";
      RestartSec = "10s";
      User = "root";  # needed for mount
    };
  };

  # create persistant cache
  systemd.tmpfiles.rules = [
    "d /var/cache/weedfs-cache 0755 root root -"
    ];

@liberodark liberodark marked this pull request as draft November 5, 2024 22:23
@liberodark liberodark marked this pull request as ready for review November 5, 2024 22:26
@liberodark liberodark force-pushed the seawedfs branch 3 times, most recently from b3fc391 to 319d5fa Compare November 6, 2024 07:00
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild 10.rebuild-linux: 1-10 labels Nov 6, 2024
@liberodark liberodark force-pushed the seawedfs branch 2 times, most recently from 0f7aca0 to d8e7400 Compare November 6, 2024 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants