about summary refs log tree commit diff
path: root/pkgs/applications/networking/cluster/rke2/default.nix
diff options
context:
space:
mode:
authorMogeko <zhengjunyi@live.com>2024-05-11 06:40:35 +0200
committerMogeko <zhengjunyi@live.com>2024-05-28 10:16:25 +0800
commit398992986d223d333d5f40422b978512427bca0a (patch)
treeac9024ad64c3fc034e59b8e12116c98093235646 /pkgs/applications/networking/cluster/rke2/default.nix
parent0a77146e7ad07ee20d6fa576669dd41c55fb5730 (diff)
rke2: add runtime dependencies for kubelet
See: https://github.com/kubernetes/kubernetes/issues/26093#issuecomment-237202494

Setup `passthru.updateScript`.

Only build or run rke2 in linux.
Diffstat (limited to 'pkgs/applications/networking/cluster/rke2/default.nix')
-rw-r--r--pkgs/applications/networking/cluster/rke2/default.nix33
1 files changed, 31 insertions, 2 deletions
diff --git a/pkgs/applications/networking/cluster/rke2/default.nix b/pkgs/applications/networking/cluster/rke2/default.nix
index 99b0998582f4e..a2ddd220dc939 100644
--- a/pkgs/applications/networking/cluster/rke2/default.nix
+++ b/pkgs/applications/networking/cluster/rke2/default.nix
@@ -1,4 +1,11 @@
-{ lib, stdenv, buildGoModule, fetchFromGitHub }:
+{ lib, stdenv, buildGoModule, fetchFromGitHub, makeWrapper, nix-update-script
+
+# Runtime dependencies
+, procps, coreutils, util-linux, ethtool, socat, iptables, bridge-utils, iproute2, kmod, lvm2
+
+# Testing dependencies
+, nixosTests, testers, rke2
+}:
 
 buildGoModule rec {
   pname = "rke2";
@@ -21,14 +28,36 @@ buildGoModule rec {
     sed -e 's/STATIC_FLAGS=.*/STATIC_FLAGS=/g' -i scripts/build-binary
   '';
 
+  nativeBuildInputs = [ makeWrapper ];
+
+  # Important utilities used by the kubelet.
+  # See: https://github.com/kubernetes/kubernetes/issues/26093#issuecomment-237202494
+  # Notice the list in that issue is stale, but as a redundancy reservation.
+  buildInputs = [
+    procps # pidof pkill
+    coreutils # uname touch env nice du
+    util-linux # lsblk fsck mkfs nsenter mount umount
+    ethtool # ethtool
+    socat # socat
+    iptables # iptables iptables-restore iptables-save
+    bridge-utils # brctl
+    iproute2 # ip tc
+    kmod # modprobe
+    lvm2 # dmsetup
+  ];
+
   buildPhase = ''
     DRONE_TAG="v${version}" ./scripts/build-binary
   '';
 
   installPhase = ''
     install -D ./bin/rke2 $out/bin/rke2
+    wrapProgram $out/bin/rke2 \
+      --prefix PATH : ${lib.makeBinPath buildInputs}
   '';
 
+  passthru.updateScript = nix-update-script { };
+
   meta = with lib; {
     homepage = "https://github.com/rancher/rke2";
     description = "RKE2, also known as RKE Government, is Rancher's next-generation Kubernetes distribution.";
@@ -36,6 +65,6 @@ buildGoModule rec {
     license = licenses.asl20;
     maintainers = with maintainers; [ zimbatm zygot ];
     mainProgram = "rke2";
-    broken = stdenv.isDarwin;
+    platforms = platforms.linux;
   };
 }