다음 YAML 파일은 리포지토리의 소스 코드를 사용하여 새 컨테이너 이미지를 빌드합니다. 생성된 이미지는 임시 이름으로 레지스트리에 다시 저장되며 이 임시 이미지는 sign 섹션의 매개변수를 사용하여 서명됩니다.
임시 이미지 이름은 최종 이미지 이름을 기반으로 하며 < containerImage>:<tag>-<namespace>_<module name>_kmm_unsigned 로 설정됩니다.
예를 들어, 다음 YAML 파일을 사용하여 커널 모듈 관리(KMM)는 서명되지 않은 kmods가 포함된 빌드가 포함된 example.org/repository/minimal-driver:final-default_example-module_kmm_unsigned 이미지를 빌드하여 레지스트리로 내보냅니다. 그런 다음 서명된 kmods가 포함된 example.org/repository/minimal-driver:final 이라는 두 번째 이미지를 생성합니다. DaemonSet 오브젝트에서 로드하고 kmods를 클러스터 노드에 배포하는 두 번째 이미지입니다.
서명된 후에는 레지스트리에서 임시 이미지를 안전하게 삭제할 수 있습니다. 필요한 경우 다시 빌드됩니다.
사전 요구 사항
keySecret 및 certSecret 시크릿이 생성되었습니다.
절차
YAML 파일을 적용합니다.
---
apiVersion: v1
kind: ConfigMap
metadata:
name: example-module-dockerfile
namespace: default
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/ubi8/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: default
spec:
moduleLoader:
serviceAccountName: default
container:
modprobe:
moduleName: simple_kmod
kernelMappings:
- regexp: '^.*\.x86_64$'
containerImage: < the name of the final driver container to produce>
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
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/ubi8/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: default
2
spec:moduleLoader:serviceAccountName: default
3
container:modprobe:moduleName: simple_kmod
kernelMappings:-regexp:'^.*\.x86_64$'containerImage: < the name of the final driver container to produce>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: