Skip to content

Mount host kernel modules in build pods for in-tree dependency resolution#1222

Merged
k8s-ci-robot merged 1 commit intokubernetes-sigs:mainfrom
TomerNewman:mount-host-modules-in-build-pod
Feb 5, 2026
Merged

Mount host kernel modules in build pods for in-tree dependency resolution#1222
k8s-ci-robot merged 1 commit intokubernetes-sigs:mainfrom
TomerNewman:mount-host-modules-in-build-pod

Conversation

@TomerNewman
Copy link
Contributor

@TomerNewman TomerNewman commented Jan 22, 2026

Enable OOT modules to depend on in-tree modules by mounting the host's /lib/modules into pods at /host/lib/modules. The /host prefix avoids conflicts with Kaniko during builds.

Also removing /usr/lib/modules from worker and build pods.

Worker pods get both paths (/lib/modules and /host/lib/modules) for backward compatibility.

Docs in docs/mkdocs/documentation/kmod_image.md updated with usage example.


/cc @ybettan @yevgeny-shnaidman

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: TomerNewman

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@netlify
Copy link

netlify bot commented Jan 22, 2026

Deploy Preview for kubernetes-sigs-kmm ready!

Name Link
🔨 Latest commit 93fa153
🔍 Latest deploy log https://app.netlify.com/projects/kubernetes-sigs-kmm/deploys/69806301d149340008300bc9
😎 Deploy Preview https://deploy-preview-1222--kubernetes-sigs-kmm.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 22, 2026
@TomerNewman TomerNewman changed the title Mount host kernel modules in build pods for in-tree dependency resolu… Mount host kernel modules in build pods for in-tree dependency resolution Jan 22, 2026
@TomerNewman TomerNewman force-pushed the mount-host-modules-in-build-pod branch from 056a9b5 to ee9b60f Compare January 22, 2026 13:15
@codecov-commenter
Copy link

codecov-commenter commented Jan 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.75%. Comparing base (fa23a9b) to head (93fa153).
⚠️ Report is 345 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1222      +/-   ##
==========================================
- Coverage   79.09%   73.75%   -5.34%     
==========================================
  Files          51       66      +15     
  Lines        5109     4611     -498     
==========================================
- Hits         4041     3401     -640     
- Misses        882     1048     +166     
+ Partials      186      162      -24     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TomerNewman TomerNewman changed the title Mount host kernel modules in build pods for in-tree dependency resolution Mount host kernel modules in build pods for in-tree dependency resolution [WIP] Jan 22, 2026
{
Name: volNameLibModules,
MountPath: "/lib/modules",
MountPath: "/host/lib/modules",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to change the VolumeMount for worker pod? If we change it, then the current code won't work, i think

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it for consistency, Im reviewing it now since the e2e test failed.

@TomerNewman
Copy link
Contributor Author

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 22, 2026
@TomerNewman TomerNewman force-pushed the mount-host-modules-in-build-pod branch from ee9b60f to 5de5373 Compare January 26, 2026 12:49
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 26, 2026
`modprobe` can then follow that link and load the in-tree dependencies as needed.

In the example below, we use `host` as the symbolic link name under `/opt/usr/lib/modules/[kernel-version]`:
In the example below, we use `host` as the symbolic link name under `/opt/lib/modules/[kernel-version]`:
Copy link
Contributor Author

@TomerNewman TomerNewman Jan 26, 2026

Choose a reason for hiding this comment

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

This doc mistake is not related, but still thought to fix it here

@TomerNewman
Copy link
Contributor Author

/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 27, 2026
@TomerNewman TomerNewman changed the title Mount host kernel modules in build pods for in-tree dependency resolution [WIP] Mount host kernel modules in build pods for in-tree dependency resolution Jan 27, 2026
Comment on lines 375 to 392
{
Name: "host-lib-modules",
VolumeSource: v1.VolumeSource{
HostPath: &v1.HostPathVolumeSource{
Path: "/lib/modules",
Type: &hostPathDirectory,
},
},
},
{
Name: "host-usr-lib-modules",
VolumeSource: v1.VolumeSource{
HostPath: &v1.HostPathVolumeSource{
Path: "/usr/lib/modules",
Type: &hostPathDirectory,
},
},
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need additional volumes? They are already defined here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because I made the Build pod use /host/lib/modules to avoid Kaniko conflicts (kaniko extracts the base image into /).
The image Dockerfile create symlinks pointing there, so worker pod needs the same mount for those symlinks to work.

Copy link
Contributor

Choose a reason for hiding this comment

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

@TomerNewman i think we don't need to define the volumes twice, we can just define a new VolumeMount for the same volume and mount it into the /host/lib/modules/ etc'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh by bad, made a mix up with the volumeMount, fixing it now

Comment on lines 417 to 408
{
Name: "host-lib-modules",
MountPath: "/host/lib/modules",
ReadOnly: true,
},
{
Name: "host-usr-lib-modules",
MountPath: "/host/usr/lib/modules",
ReadOnly: true,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to mount it to 2 different paths? We already mount them at /lib/modules and /usr/lib/modules.
If we change it we need to make sure to also update the docs changes in this PR and the commit message.

Copy link
Contributor Author

@TomerNewman TomerNewman Jan 27, 2026

Choose a reason for hiding this comment

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

  1. Answered here.
  2. Np

Comment on lines 69 to 78
{
Name: "lib-modules",
ReadOnly: true,
MountPath: "/host/lib/modules",
},
{
Name: "usr-lib-modules",
ReadOnly: true,
MountPath: "/host/usr/lib/modules",
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't we mount it to the same location as the worker pods instead of setting a new paths and then adding this new path to the worker pod as well and in addition keep the old "legacy" path?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can't mount to /lib/modules in build pods because Kaniko extracts the base image to /, which conflicts with a mount in /lib/modules.

@TomerNewman TomerNewman force-pushed the mount-host-modules-in-build-pod branch 4 times, most recently from bfe60ca to 0a3376c Compare January 29, 2026 10:18
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 29, 2026
@TomerNewman TomerNewman force-pushed the mount-host-modules-in-build-pod branch from 0a3376c to 7559ca5 Compare January 29, 2026 10:22
VolumeSource: v1.VolumeSource{
HostPath: &v1.HostPathVolumeSource{
Path: "/lib/modules",
Type: &hostPathDirectory,
Copy link
Contributor

Choose a reason for hiding this comment

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

@TomerNewman TomerNewman force-pushed the mount-host-modules-in-build-pod branch 2 times, most recently from 63831e1 to a1ea805 Compare February 2, 2026 08:34
Enable OOT modules to depend on in-tree modules by mounting the host's
/lib/modules into pods at /host/lib/modules.
The /host prefix avoids conflicts with Kaniko during builds.

Also removing /usr/lib/modules mount from build and worker pods.

Worker pods get both paths (/lib/modules and /host/lib/modules) for
backward compatibility.

Docs in docs/mkdocs/documentation/kmod_image.md updated with usage example.
@TomerNewman TomerNewman force-pushed the mount-host-modules-in-build-pod branch from a1ea805 to 93fa153 Compare February 2, 2026 08:40
@ybettan
Copy link
Contributor

ybettan commented Feb 5, 2026

I am happy with this PR when @yevgeny-shnaidman is.

@yevgeny-shnaidman
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 5, 2026
@k8s-ci-robot k8s-ci-robot merged commit d8e8410 into kubernetes-sigs:main Feb 5, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants