[NixOS] Fix cdi issues with k3s containerd

This commit is contained in:
Your Name 2024-10-02 18:54:27 -06:00
parent bb259bf358
commit 618f927cb9
2 changed files with 18 additions and 11 deletions

View File

@ -1,4 +1,4 @@
{ config, lib, ... }:
{ pkgs, config, lib, ... }:
with lib;
let cfg = config.myModules.railbird-k3s;
in {
@ -22,19 +22,20 @@ in {
enableDelete = true;
enableGarbageCollect = true;
};
virtualisation.containerd = {
enable = true;
settings = {
plugins."io.containerd.grpc.v1.cri" = {
enable_cdi = true;
cdi_spec_dirs = [ "/var/run/cdi" ];
};
};
};
services.k3s = {
enable = true;
clusterInit = cfg.serverAddr == "";
serverAddr = cfg.serverAddr;
configPath = pkgs.writeTextFile {
name = "k3s-config.yaml";
text = ''
write-kubeconfig-mode: "0644"
kubelet-arg:
- "eviction-hard=nodefs.available<2Gi"
- "eviction-soft=nodefs.available<5Gi"
- "eviction-soft-grace-period=nodefs.available=5m"
'';
};
tokenFile = config.age.secrets."1896Folsom-k3s-token.age".path;
extraFlags = [
"--tls-san ryzen-shine.local"
@ -47,6 +48,9 @@ in {
containerdConfigTemplate = ''
{{ template "base" . }}
[plugins]
"io.containerd.grpc.v1.cri".enable_cdi = true
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.nvidia]
privileged_without_host_devices = false
runtime_engine = ""

View File

@ -4,7 +4,10 @@ makeEnable config "myModules.nvidia" false {
environment.systemPackages = with pkgs; [
nvidia-container-toolkit
];
hardware.nvidia-container-toolkit.enable = true;
hardware.nvidia-container-toolkit = {
enable = true;
mount-nvidia-executables = true;
};
hardware.nvidia.open = false;
hardware.graphics.extraPackages = [ pkgs.linuxPackages.nvidia_x11.out ];
hardware.graphics.extraPackages32 = [ pkgs.linuxPackages.nvidia_x11.lib32 ];