kind: patch for correct kernal module path

Signed-off-by: Atkins Chang <atkinschang@gmail.com>
This commit is contained in:
Atkins Chang 2021-08-06 22:09:02 +08:00
parent b626776ab2
commit 303f9b6b44
No known key found for this signature in database
GPG Key ID: EEB142DC0A799167
2 changed files with 52 additions and 0 deletions

View File

@ -13,6 +13,11 @@ buildGoModule rec {
sha256 = "sha256-pjg52ONseKNw06EOBzD6Elge+Cz+C3llPvjJPHkn1cw=";
};
patches = [
# fix kernel module path used by kind
./kernel-module-path.patch
];
vendorSha256 = "sha256-HiVdekSZrC/RkMSvcwm1mv6AE4bA5kayUsMdVCbckiE=";
doCheck = false;

View File

@ -0,0 +1,47 @@
diff --git a/pkg/cluster/internal/providers/common/getmodules.go b/pkg/cluster/internal/providers/common/getmodules.go
new file mode 100644
index 00000000..f42a883d
--- /dev/null
+++ b/pkg/cluster/internal/providers/common/getmodules.go
@@ -0,0 +1,15 @@
+package common
+
+import "os"
+
+const (
+ fhsKernalModulePath = "/lib/modules"
+ nixKernalModulePath = "/run/booted-system/kernel-modules/lib"
+)
+
+func GetKernelModulePath() string {
+ if _, err := os.Stat(nixKernalModulePath); !os.IsNotExist(err) {
+ return nixKernalModulePath
+ }
+ return fhsKernalModulePath
+}
diff --git a/pkg/cluster/internal/providers/docker/provision.go b/pkg/cluster/internal/providers/docker/provision.go
index 50161861..86d5b7b6 100644
--- a/pkg/cluster/internal/providers/docker/provision.go
+++ b/pkg/cluster/internal/providers/docker/provision.go
@@ -242,7 +242,7 @@ func runArgsForNode(node *config.Node, clusterIPFamily config.ClusterIPFamily, n
// (please don't depend on doing this though!)
"--volume", "/var",
// some k8s things want to read /lib/modules
- "--volume", "/lib/modules:/lib/modules:ro",
+ "--volume", fmt.Sprintf("%s:/lib/modules:ro", common.GetKernelModulePath()),
},
args...,
)
diff --git a/pkg/cluster/internal/providers/podman/provision.go b/pkg/cluster/internal/providers/podman/provision.go
index 51dce486..3bc36b42 100644
--- a/pkg/cluster/internal/providers/podman/provision.go
+++ b/pkg/cluster/internal/providers/podman/provision.go
@@ -205,7 +205,7 @@ func runArgsForNode(node *config.Node, clusterIPFamily config.ClusterIPFamily, n
// dev: devices on the volume will be able to be used by processes within the container
"--volume", fmt.Sprintf("%s:/var:suid,exec,dev", varVolume),
// some k8s things want to read /lib/modules
- "--volume", "/lib/modules:/lib/modules:ro",
+ "--volume", fmt.Sprintf("%s:/lib/modules:ro", common.GetKernelModulePath()),
},
args...,
)