Skip to content

Build and load Kernel Model

Note

We need an entitlement to install kernel sources.

Service account & privileges

1
oc apply -f https://examples.openshift.pub/cluster-configuration/build-load-kernel-module/service-account-and-rbac.yaml.yaml
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
apiVersion: v1
kind: ServiceAccount
metadata:
  name: privileged
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: privileged
rules:
- apiGroups:
  - security.openshift.io
  resourceNames:
  - privileged
  resources:
  - securitycontextconstraints
  verbs:
  - use
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: sa-to-privileged
subjects:
  - kind: ServiceAccount
    name: privileged
roleRef:
  kind: Role
  name: privileged
  apiGroup: rbac.authorization.k8s.io

Entitlement

1
2
3
oc create secret generic etc-pki-entitlement \
  --from-file=entitlement.pem=./export/entitlement_certificates/xxx.pem
  --from-file entitlement-key.pem=./export/entitlement_certificates/xxx.pem

DaemonSet / Deployment (Build & Run/Load)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: nuc-led-kernel-module
spec:
  updateStrategy:
    type: OnDelete
  selector:
    matchLabels:
      name: nuc-led-kernel-module
  template:
    metadata:
      labels:
        name: nuc-led-kernel-module
    spec:
      tolerations:
        - operator: Exists
      hostname: nuc-led-kernel-module
      serviceAccount: privileged
      serviceAccountName: privileged
      volumes:
      - name: etc-pki-entitlement
        secret:
          defaultMode: 420
          secretName: etc-pki-entitlement
      containers:
        - name: rhel
          image: registry.access.redhat.com/ubi8/s2i-base:latest
          lifecycle:
            preStop:
              exec:
                command:
                  - /usr/bin/bash
                  - -c
                  - |
                    set -euxo pipefail
                    rmmod nuc_led
          command:
            - /usr/bin/bash
            - -c
            - |

              set -euxo pipefail

              rm /etc/rhsm-host

              dnf install -y gcc-toolset-10-gcc kernel-devel \
                             kernel-headers kernel-modules \
                             elfutils-libelf-devel


              git clone https://github.com/nomego/intel_nuc_led
              cd intel_nuc_led

              make
              make install
              modprobe nuc_led

              while true; do
                date
                cat  /proc/acpi/nuc_led
                sleep 60
              done

              sleep infinity

          securityContext:
            privileged: true
            runAsUser: 0

          volumeMounts:
          - mountPath: /etc/pki/entitlement
            name: etc-pki-entitlement
1
oc apply -f https://examples.openshift.pub/cluster-configuration/build-load-kernel-module/daemonset.yaml

Last update: August 3, 2021
Back to top