Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / development / tools / kind / kernel-module-path.patch
blobdd04c9ec3050af11c2740d914b3c73d9a23680ba
1 diff --git a/pkg/cluster/internal/providers/common/getmodules.go b/pkg/cluster/internal/providers/common/getmodules.go
2 new file mode 100644
3 index 00000000..1cce5675
4 --- /dev/null
5 +++ b/pkg/cluster/internal/providers/common/getmodules.go
6 @@ -0,0 +1,15 @@
7 +package common
9 +import "os"
11 +const (
12 + fhsKernelModulePath = "/lib/modules"
13 + nixKernelModulePath = "/run/booted-system/kernel-modules/lib/modules"
16 +func GetKernelModulePath() string {
17 + if _, err := os.Stat(nixKernelModulePath); !os.IsNotExist(err) {
18 + return nixKernelModulePath
19 + }
20 + return fhsKernelModulePath
22 diff --git a/pkg/cluster/internal/providers/docker/provision.go b/pkg/cluster/internal/providers/docker/provision.go
23 index 97b05594..3aaa9830 100644
24 --- a/pkg/cluster/internal/providers/docker/provision.go
25 +++ b/pkg/cluster/internal/providers/docker/provision.go
26 @@ -230,7 +230,7 @@ func runArgsForNode(node *config.Node, clusterIPFamily config.ClusterIPFamily, n
27 // (please don't depend on doing this though!)
28 "--volume", "/var",
29 // some k8s things want to read /lib/modules
30 - "--volume", "/lib/modules:/lib/modules:ro",
31 + "--volume", fmt.Sprintf("%s:/lib/modules:ro", common.GetKernelModulePath()),
32 // propagate KIND_EXPERIMENTAL_CONTAINERD_SNAPSHOTTER to the entrypoint script
33 "-e", "KIND_EXPERIMENTAL_CONTAINERD_SNAPSHOTTER",
35 diff --git a/pkg/cluster/internal/providers/podman/provision.go b/pkg/cluster/internal/providers/podman/provision.go
36 index 50aa7018..7e25a4de 100644
37 --- a/pkg/cluster/internal/providers/podman/provision.go
38 +++ b/pkg/cluster/internal/providers/podman/provision.go
39 @@ -203,7 +203,7 @@ func runArgsForNode(node *config.Node, clusterIPFamily config.ClusterIPFamily, n
40 // dev: devices on the volume will be able to be used by processes within the container
41 "--volume", fmt.Sprintf("%s:/var:suid,exec,dev", varVolume),
42 // some k8s things want to read /lib/modules
43 - "--volume", "/lib/modules:/lib/modules:ro",
44 + "--volume", fmt.Sprintf("%s:/lib/modules:ro", common.GetKernelModulePath()),
45 // propagate KIND_EXPERIMENTAL_CONTAINERD_SNAPSHOTTER to the entrypoint script
46 "-e", "KIND_EXPERIMENTAL_CONTAINERD_SNAPSHOTTER",