1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2025-03-05 16:27:05 +00:00

Mount /usr/lib and /usr/src inside the Pod

Mount /usr/lib and /usr/src as /host-usr/lib and /host-usr/src inside the pod
to allow NFD to search for the kernel configuration file inside /usr.
This solves the problem of the kernel config file not being present in /boot
on s390x RHCOS.

Signed-off-by: Jan Schintag <jan.schintag@de.ibm.com>
This commit is contained in:
Jan Schintag 2021-04-19 13:41:37 +02:00
parent 77bd4e4cf6
commit 5871207588
7 changed files with 85 additions and 7 deletions

View file

@ -60,6 +60,12 @@ spec:
- name: host-sys - name: host-sys
mountPath: "/host-sys" mountPath: "/host-sys"
readOnly: true readOnly: true
- name: host-usr-lib
mountPath: "/host-usr/lib"
readOnly: true
- name: host-usr-src
mountPath: "/host-usr/src"
readOnly: true
- name: source-d - name: source-d
mountPath: "/etc/kubernetes/node-feature-discovery/source.d/" mountPath: "/etc/kubernetes/node-feature-discovery/source.d/"
readOnly: true readOnly: true
@ -86,6 +92,12 @@ spec:
- name: host-sys - name: host-sys
hostPath: hostPath:
path: "/sys" path: "/sys"
- name: host-usr-lib
hostPath:
path: "/usr/lib"
- name: host-usr-src
hostPath:
path: "/usr/src"
- name: source-d - name: source-d
hostPath: hostPath:
path: "/etc/kubernetes/node-feature-discovery/source.d/" path: "/etc/kubernetes/node-feature-discovery/source.d/"

View file

@ -104,6 +104,12 @@ spec:
- name: host-sys - name: host-sys
mountPath: "/host-sys" mountPath: "/host-sys"
readOnly: true readOnly: true
- name: host-usr-lib
mountPath: "/host-usr/lib"
readOnly: true
- name: host-usr-src
mountPath: "/host-usr/src"
readOnly: true
- name: source-d - name: source-d
mountPath: "/etc/kubernetes/node-feature-discovery/source.d/" mountPath: "/etc/kubernetes/node-feature-discovery/source.d/"
readOnly: true readOnly: true
@ -128,6 +134,12 @@ spec:
- name: host-sys - name: host-sys
hostPath: hostPath:
path: "/sys" path: "/sys"
- name: host-usr-lib
hostPath:
path: "/usr/lib"
- name: host-usr-src
hostPath:
path: "/usr/src"
- name: source-d - name: source-d
hostPath: hostPath:
path: "/etc/kubernetes/node-feature-discovery/source.d/" path: "/etc/kubernetes/node-feature-discovery/source.d/"

View file

@ -53,6 +53,12 @@ spec:
- name: host-sys - name: host-sys
mountPath: "/host-sys" mountPath: "/host-sys"
readOnly: true readOnly: true
- name: host-usr-lib
mountPath: "/host-usr/lib"
readOnly: true
- name: host-usr-src
mountPath: "/host-usr/src"
readOnly: true
- name: source-d - name: source-d
mountPath: "/etc/kubernetes/node-feature-discovery/source.d/" mountPath: "/etc/kubernetes/node-feature-discovery/source.d/"
readOnly: true readOnly: true
@ -81,6 +87,12 @@ spec:
- name: host-sys - name: host-sys
hostPath: hostPath:
path: "/sys" path: "/sys"
- name: host-usr-lib
hostPath:
path: "/usr/lib"
- name: host-usr-src
hostPath:
path: "/usr/src"
- name: source-d - name: source-d
hostPath: hostPath:
path: "/etc/kubernetes/node-feature-discovery/source.d/" path: "/etc/kubernetes/node-feature-discovery/source.d/"

View file

@ -63,6 +63,12 @@ spec:
- name: host-sys - name: host-sys
mountPath: "/host-sys" mountPath: "/host-sys"
readOnly: true readOnly: true
- name: host-usr-lib
mountPath: "/host-usr/lib"
readOnly: true
- name: host-usr-src
mountPath: "/host-usr/src"
readOnly: true
- name: source-d - name: source-d
mountPath: "/etc/kubernetes/node-feature-discovery/source.d/" mountPath: "/etc/kubernetes/node-feature-discovery/source.d/"
readOnly: true readOnly: true
@ -95,6 +101,12 @@ spec:
- name: host-sys - name: host-sys
hostPath: hostPath:
path: "/sys" path: "/sys"
- name: host-usr-lib
hostPath:
path: "/usr/lib"
- name: host-usr-src
hostPath:
path: "/usr/src"
- name: source-d - name: source-d
hostPath: hostPath:
path: "/etc/kubernetes/node-feature-discovery/source.d/" path: "/etc/kubernetes/node-feature-discovery/source.d/"

View file

@ -28,6 +28,8 @@ var (
EtcDir = HostDir(pathPrefix + "etc") EtcDir = HostDir(pathPrefix + "etc")
// SysfsPath is where the /sys directory of the system to be inspected is located // SysfsPath is where the /sys directory of the system to be inspected is located
SysfsDir = HostDir(pathPrefix + "sys") SysfsDir = HostDir(pathPrefix + "sys")
// UsrPath is where the /usr directory of the system to be inspected is located
UsrDir = HostDir(pathPrefix + "usr")
) )
// HostDir is a helper for handling host system directories // HostDir is a helper for handling host system directories

View file

@ -62,19 +62,19 @@ func ParseKconfig(configPath string) (map[string]string, error) {
if err != nil { if err != nil {
searchPaths = []string{ searchPaths = []string{
"/proc/config.gz", "/proc/config.gz",
"/usr/src/linux/.config", source.UsrDir.Path("src/linux/.config"),
} }
} else { } else {
// from k8s.io/system-validator used by kubeadm // from k8s.io/system-validator used by kubeadm
// preflight checks // preflight checks
searchPaths = []string{ searchPaths = []string{
"/proc/config.gz", "/proc/config.gz",
"/usr/src/linux-" + kVer + "/.config", source.UsrDir.Path("src/linux-" + kVer + "/.config"),
"/usr/src/linux/.config", source.UsrDir.Path("src/linux/.config"),
"/usr/lib/modules/" + kVer + "/config", source.UsrDir.Path("lib/modules/" + kVer + "/config"),
"/usr/lib/ostree-boot/config-" + kVer, source.UsrDir.Path("lib/ostree-boot/config-" + kVer),
"/usr/lib/kernel/config-" + kVer, source.UsrDir.Path("lib/kernel/config-" + kVer),
"/usr/src/linux-headers-" + kVer + "/.config", source.UsrDir.Path("src/linux-headers-" + kVer + "/.config"),
"/lib/modules/" + kVer + "/build/.config", "/lib/modules/" + kVer + "/build/.config",
source.BootDir.Path("config-" + kVer), source.BootDir.Path("config-" + kVer),
} }

View file

@ -338,6 +338,16 @@ func nfdWorkerPodSpec(image string, extraArgs []string) v1.PodSpec {
MountPath: "/host-sys", MountPath: "/host-sys",
ReadOnly: true, ReadOnly: true,
}, },
{
Name: "host-usr-lib",
MountPath: "/host-usr/lib",
ReadOnly: true,
},
{
Name: "host-usr-src",
MountPath: "/host-usr/src",
ReadOnly: true,
},
}, },
}, },
}, },
@ -371,6 +381,24 @@ func nfdWorkerPodSpec(image string, extraArgs []string) v1.PodSpec {
}, },
}, },
}, },
{
Name: "host-usr-lib",
VolumeSource: v1.VolumeSource{
HostPath: &v1.HostPathVolumeSource{
Path: "/usr/lib",
Type: newHostPathType(v1.HostPathDirectory),
},
},
},
{
Name: "host-usr-src",
VolumeSource: v1.VolumeSource{
HostPath: &v1.HostPathVolumeSource{
Path: "/usr/src",
Type: newHostPathType(v1.HostPathDirectory),
},
},
},
}, },
} }