4.13. kmod イメージのビルドと署名
ソースコードがあり、最初にイメージをビルドする必要がある場合は、この手順を使用します。
次の YAML ファイルは、リポジトリーのソースコードを使用して新しいコンテナーイメージをビルドします。生成されたイメージは一時的な名前でレジストリーに保存され、この一時的なイメージは sign
セクションのパラメーターを使用して署名されます。
一時的なイメージ名は最終的なイメージ名に基づいており、<containerImage>:<tag>-<namespace>_<module name>_kmm_unsigned
に設定されています。
たとえば、Kernel Module Management (KMM) は、次の YAML ファイルを使用して、署名のない kmod を含むビルドを含む example.org/repository/minimal-driver:final-default_example-module_kmm_unsigned
という名前のイメージをビルドし、レジストリーにプッシュします。次に、署名された kmod を含む example.org/repository/minimal-driver:final
という名前の 2 番目のイメージを作成します。この 2 番目のイメージは、ワーカー Pod によってプルされ、クラスターノードにロードされる kmod を含んでいます。
一時的なイメージは、署名後にレジストリーから安全に削除できます。必要に応じて再構築されます。
前提条件
-
keySecret
およびcertSecret
シークレットが、残りのリソースと同じ namespace に作成されている。
手順
YAML ファイルを適用します。
Copy to Clipboard Copied! Toggle word wrap Toggle overflow --- apiVersion: v1 kind: ConfigMap metadata: name: example-module-dockerfile namespace: <namespace> data: Dockerfile: | ARG DTK_AUTO ARG KERNEL_VERSION FROM ${DTK_AUTO} as builder WORKDIR /build/ RUN git clone -b main --single-branch https://github.com/rh-ecosystem-edge/kernel-module-management.git WORKDIR kernel-module-management/ci/kmm-kmod/ RUN make FROM registry.access.redhat.com/ubi9/ubi:latest ARG KERNEL_VERSION RUN yum -y install kmod && yum clean all RUN mkdir -p /opt/lib/modules/${KERNEL_VERSION} COPY --from=builder /build/kernel-module-management/ci/kmm-kmod/*.ko /opt/lib/modules/${KERNEL_VERSION}/ RUN /usr/sbin/depmod -b /opt --- apiVersion: kmm.sigs.x-k8s.io/v1beta1 kind: Module metadata: name: example-module namespace: <namespace> spec: moduleLoader: serviceAccountName: default container: modprobe: moduleName: simple_kmod kernelMappings: - regexp: '^.*\.x86_64$' containerImage: <final_driver_container_name> build: dockerfileConfigMap: name: example-module-dockerfile sign: keySecret: name: <private_key_secret_name> certSecret: name: <certificate_secret_name> filesToSign: - /opt/lib/modules/4.18.0-348.2.1.el8_5.x86_64/kmm_ci_a.ko imageRepoSecret: name: repo-pull-secret selector: # top-level selector kubernetes.io/arch: amd64
--- apiVersion: v1 kind: ConfigMap metadata: name: example-module-dockerfile namespace: <namespace>
1 data: Dockerfile: | ARG DTK_AUTO ARG KERNEL_VERSION FROM ${DTK_AUTO} as builder WORKDIR /build/ RUN git clone -b main --single-branch https://github.com/rh-ecosystem-edge/kernel-module-management.git WORKDIR kernel-module-management/ci/kmm-kmod/ RUN make FROM registry.access.redhat.com/ubi9/ubi:latest ARG KERNEL_VERSION RUN yum -y install kmod && yum clean all RUN mkdir -p /opt/lib/modules/${KERNEL_VERSION} COPY --from=builder /build/kernel-module-management/ci/kmm-kmod/*.ko /opt/lib/modules/${KERNEL_VERSION}/ RUN /usr/sbin/depmod -b /opt --- apiVersion: kmm.sigs.x-k8s.io/v1beta1 kind: Module metadata: name: example-module namespace: <namespace>
2 spec: moduleLoader: serviceAccountName: default
3 container: modprobe: moduleName: simple_kmod kernelMappings: - regexp: '^.*\.x86_64$' containerImage: <final_driver_container_name> build: dockerfileConfigMap: name: example-module-dockerfile sign: keySecret: name: <private_key_secret_name> certSecret: name: <certificate_secret_name> filesToSign: - /opt/lib/modules/4.18.0-348.2.1.el8_5.x86_64/kmm_ci_a.ko imageRepoSecret:
4 name: repo-pull-secret selector: # top-level selector kubernetes.io/arch: amd64
関連情報