From ae7a4eb06e1cceeb2255f7b0dd6a58159c298294 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Mass=C3=A9?= Date: Mon, 7 Jul 2025 17:56:56 +0200 Subject: [PATCH] wip --- base-image/jetpack-python/Containerfile | 10 ++ base-image/jetpack-python/build.sh | 38 +++++ base-image/jetpack/build.sh | 17 +- bootc/Containerfile | 52 +++--- bootc/Containerfile.vanilla | 55 +++++++ bootc/post/etc/git/.gitignore | 1 + bootc/post/etc/git/git-credentials.sample | 1 + bootc/post/etc/gitconfig | 2 + .../system-connections/webcam.nmconnection | 17 ++ .../containers/systemd/app-edge-ai.container | 7 +- .../root/etc/systemd/system/git-repo.service | 14 ++ tekton/README.md | 49 +++++- tekton/common/kustomization.yaml | 3 +- tekton/common/task-buildah-bootc.yaml | 90 ---------- tekton/common/task-buildah.yaml | 154 ++++++++++++++++++ tekton/common/task-rclone.yaml | 33 ++++ tekton/pipeline.yaml | 80 +++++++-- tekton/pipelinerun.yaml | 39 +++-- 18 files changed, 515 insertions(+), 147 deletions(-) create mode 100644 base-image/jetpack-python/Containerfile create mode 100755 base-image/jetpack-python/build.sh create mode 100644 bootc/Containerfile.vanilla create mode 100644 bootc/post/etc/git/.gitignore create mode 100644 bootc/post/etc/git/git-credentials.sample create mode 100644 bootc/post/etc/gitconfig create mode 100644 bootc/root/etc/NetworkManager/system-connections/webcam.nmconnection create mode 100644 bootc/root/etc/systemd/system/git-repo.service delete mode 100644 tekton/common/task-buildah-bootc.yaml create mode 100644 tekton/common/task-buildah.yaml create mode 100644 tekton/common/task-rclone.yaml diff --git a/base-image/jetpack-python/Containerfile b/base-image/jetpack-python/Containerfile new file mode 100644 index 0000000..50e6bfc --- /dev/null +++ b/base-image/jetpack-python/Containerfile @@ -0,0 +1,10 @@ +FROM artifactory.services.studio.airbushelicopters.com/poc-edge-ai/jetpack-base-image:r36.4.0 + +RUN < /etc/dnf/plugins/subscription-manager.conf +fi + +if [[ "$LOCAL_RPM_REPO" != "1" ]]; then + #dnf config-manager --enable codeready-builder-for-rhel-9-$(arch)-rpms + dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm +fi + +dnf install -y mkpasswd NetworkManager-wifi podman skopeo git + +if [ -n "$ADMIN_USERNAME" ]; then + useradd -m -G wheel -p "$(echo -n "$ADMIN_PASSWORD" | mkpasswd -m bcrypt --stdin)" "$ADMIN_USERNAME" +fi +EOF ADD --chown=root:root root / RUN set -Eeuo pipefail ; \ - systemctl enable nvidia-ctk-init.service + systemctl enable nvidia-ctk-init.service ; \ + systemctl enable git-repo.service diff --git a/bootc/Containerfile.vanilla b/bootc/Containerfile.vanilla new file mode 100644 index 0000000..408d4b9 --- /dev/null +++ b/bootc/Containerfile.vanilla @@ -0,0 +1,55 @@ +FROM registry.redhat.io/rhel9/rhel-bootc:9.4 + +ARG ADMIN_USERNAME=demo \ + ADMIN_PASSWORD=redhat \ + NVIDIA_KERNEL_VERSION=5.14.0-427.22.1.el9_4 \ + ENABLE_DNF_CACHE=1 \ + LOCAL_RPM_REPO=0 + +RUN < /etc/dnf/plugins/subscription-manager.conf +fi + +if [ -n "$NVIDIA_KERNEL_VERSION" ]; then + echo "Replacing current kernel with a version compatible with the kernel modules shipped by Nvidia" + mkdir -p /tmp/rpms + dnf download -y --destdir /tmp/rpms kernel{,-core,-modules,-modules-core}-$NVIDIA_KERNEL_VERSION + rpm-ostree override replace /tmp/rpms/*.rpm + rm -rf /tmp/rpms +fi + +if [[ "$LOCAL_RPM_REPO" != "1" ]]; then + dnf config-manager --enable codeready-builder-for-rhel-9-$(arch)-rpms + dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm +fi + +dnf install -y mkpasswd NetworkManager-wifi podman skopeo git +if [[ "$(arch)" == "aarch64" ]]; then + echo "Installing the Nvidia stuff..." ; \ + if [[ "$LOCAL_RPM_REPO" != "1" ]]; then + curl -sSfL -o /etc/yum.repos.d/nvidia-l4t.repo https://repo.download.nvidia.com/jetson/rhel-9.4/r36.3.1/nvidia-l4t.repo + curl -sSfL -o /etc/yum.repos.d/nvidia-container-toolkit.repo https://nvidia.github.io/libnvidia-container/stable/rpm/nvidia-container-toolkit.repo + dnf config-manager --enable nvidia-container-toolkit-experimental + fi + dnf install -y nvidia-jetpack-kmod nvidia-jetpack-all nvidia-container-toolkit-base +fi + +if [ -n "$ADMIN_USERNAME" ]; then + useradd -m -G wheel -p "$(echo -n "$ADMIN_PASSWORD" | mkpasswd -m bcrypt --stdin)" "$ADMIN_USERNAME" +fi +EOF + +ADD --chown=root:root root / + +RUN set -Eeuo pipefail ; \ + systemctl enable nvidia-ctk-init.service ; \ + systemctl enable git-repo.service diff --git a/bootc/post/etc/git/.gitignore b/bootc/post/etc/git/.gitignore new file mode 100644 index 0000000..c7e5685 --- /dev/null +++ b/bootc/post/etc/git/.gitignore @@ -0,0 +1 @@ +git-credentials diff --git a/bootc/post/etc/git/git-credentials.sample b/bootc/post/etc/git/git-credentials.sample new file mode 100644 index 0000000..af473c5 --- /dev/null +++ b/bootc/post/etc/git/git-credentials.sample @@ -0,0 +1 @@ +https://user:REDACTED@github.com diff --git a/bootc/post/etc/gitconfig b/bootc/post/etc/gitconfig new file mode 100644 index 0000000..0597c37 --- /dev/null +++ b/bootc/post/etc/gitconfig @@ -0,0 +1,2 @@ +[credential] + helper=store --file /etc/git/git-credentials diff --git a/bootc/root/etc/NetworkManager/system-connections/webcam.nmconnection b/bootc/root/etc/NetworkManager/system-connections/webcam.nmconnection new file mode 100644 index 0000000..ccfe0ef --- /dev/null +++ b/bootc/root/etc/NetworkManager/system-connections/webcam.nmconnection @@ -0,0 +1,17 @@ +[connection] +id=webcam +uuid=a97f051e-2924-4327-9838-80f85f9bcee8 +type=ethernet +interface-name=eth0 + +[ethernet] + +[ipv4] +address1=172.168.2.2/24 +method=manual + +[ipv6] +addr-gen-mode=default +method=disabled + +[proxy] diff --git a/bootc/root/etc/containers/systemd/app-edge-ai.container b/bootc/root/etc/containers/systemd/app-edge-ai.container index d174178..35c143f 100644 --- a/bootc/root/etc/containers/systemd/app-edge-ai.container +++ b/bootc/root/etc/containers/systemd/app-edge-ai.container @@ -1,9 +1,11 @@ [Unit] Description=AI application deployed at the Edge -After=local-fs.target +After=local-fs.target nvidia-ctk-init.service +Wants=nvidia-ctk-init.service [Service] ExecStartPre=-podman network create --ignore app +Environment=REGISTRY_AUTH_FILE=/etc/ostree/auth.json [Container] ContainerName=app-edge-ai @@ -11,8 +13,7 @@ Image=quay.io/nmasse-redhat/app-edge-ai:latest Network=app # Needed for Nvidia GPU Acceleration -PodmanArgs=--runtime /usr/bin/nvidia-container-runtime -GroupAdd=keep-groups +PodmanArgs=--runtime /usr/bin/nvidia-container-runtime --group-add=keep-groups SecurityLabelDisable=true Environment=NVIDIA_VISIBLE_DEVICES=nvidia.com/gpu=all diff --git a/bootc/root/etc/systemd/system/git-repo.service b/bootc/root/etc/systemd/system/git-repo.service new file mode 100644 index 0000000..cc4f8a1 --- /dev/null +++ b/bootc/root/etc/systemd/system/git-repo.service @@ -0,0 +1,14 @@ +[Unit] +Description=Sync the git repo +Wants=network-online.target +After=network-online.target + +[Service] +Type=oneshot +RemainAfterExit=yes +User=demo +Environment=GIT_REPO=https://github.com/nmasse-itix/bootc-edge-ai.git +ExecStart=/bin/sh -c 'if [ -d "$HOME/bootc-edge-ai" ]; then cd "$HOME/bootc-edge-ai" && git pull ; else git clone "$GIT_REPO" -b main "$HOME/bootc-edge-ai" ; fi' + +[Install] +WantedBy=multi-user.target diff --git a/tekton/README.md b/tekton/README.md index e567bde..32c4dcb 100644 --- a/tekton/README.md +++ b/tekton/README.md @@ -13,6 +13,12 @@ oc apply -k common/ oc apply -f pipeline.yaml ``` +## Authentication to Pypi + +```sh +oc create secret generic pypi-mirror '--from-literal=PYPI_MIRROR_URL=https://login:password@artifactory-host/artifactory/api/pypi/pypi-virtual/simple' +``` + ## Authentication to the registries ```sh @@ -32,6 +38,41 @@ data: EOF ``` +```sh +oc create configmap registries-conf --from-file=/etc/containers/registries.conf +``` + +## Authentication to GitHub + +```sh +cat > gitconfig < Buildah" + buildah version + echo + echo "---> bash" + bash --version + echo + echo "---> OS" + cat /etc/redhat-release + echo + + # Check what is available and set env variables + if [ -f /registries/registries.conf ]; then + export CONTAINERS_REGISTRIES_CONF=/registries/registries.conf + fi + if [ -f /auth/.dockerconfigjson ]; then + export REGISTRY_AUTH_FILE=/auth/.dockerconfigjson + fi + + # Extract the parent image name + FROM="$(sed -r 's/^FROM\s+(.*)\s*/\1/;t;d' "$(workspaces.source-workspace.path)/$(params.containerfile-path)")" + echo "Detected $FROM as parent image." + + # Build images + declare -A PODMAN_ARCH_OPTS=(["aarch64"]="--platform linux/arm64/v8" ["x86_64"]="--platform linux/amd64") + buildah manifest create localhost/image + for arch; do + declare -a PODMAN_OPTS=( ) + if [ -n "${PYPI_MIRROR_URL:}" ]; then + PODMAN_OPTS+=( "--build-arg" "PYPI_MIRROR_URL=${PYPI_MIRROR_URL}" ) + fi + if [ -f "/entitlements/$arch.tar" ]; then + echo "Using RHEL entitlements..." + rm -rf /tmp/entitlements + mkdir -p /tmp/entitlements + tar -xf /entitlements/$arch.tar -C /tmp/entitlements + PODMAN_OPTS+=( "-v" "/tmp/entitlements/etc/pki/entitlement/:/etc/pki/entitlement:z" ) + PODMAN_OPTS+=( "-v" "/tmp/entitlements/etc/rhsm:/etc/rhsm:z" ) + PODMAN_OPTS+=( "-v" "/tmp/entitlements/etc/pki/entitlement/:/run/secrets/etc-pki-entitlement:z" ) + PODMAN_OPTS+=( "-v" "/tmp/entitlements/etc/rhsm:/run/secrets/rhsm:z" ) + PODMAN_OPTS+=( "-v" "/tmp/entitlements/etc/rhsm:/run/secrets/rhsm:z" ) + PODMAN_OPTS+=( "-v" "/tmp/entitlements/etc/yum.repos.d:/etc/yum.repos.d:z" ) + fi + if [ -d "/caches/$arch/" ]; then + echo "Enabling cache..." + PODMAN_OPTS+=( "-v" "/caches/$arch/dnf:/var/cache/dnf:z" ) + PODMAN_OPTS+=( "-v" "/caches/$arch/rpm-ostree:/var/cache/rpm-ostree:z" ) + fi + if [ -d "/rpms/$arch/" ]; then + echo "Enabling RPM repositories..." + mkdir -p /tmp/rpms + cat > /tmp/rpms/local-rpms.repo <