From e85854dfe6d0503539b0105d0868a6f3707b252b Mon Sep 17 00:00:00 2001 From: Itxaka Date: Wed, 20 Jul 2022 17:40:30 +0200 Subject: [PATCH] Rework image/iso/artifacts building (#178) * Drop all the ci stuff Also generate docs added to makefile Signed-off-by: Itxaka * Create elemental image from current code and use it for the iso Signed-off-by: Itxaka * Pin teal repo to v0.8.14-22 Signed-off-by: Itxaka * Run elemental-operator on livecd boot Signed-off-by: Itxaka * Add back end2end workflow, not fully done Signed-off-by: Itxaka * Drop elemental-operator service and use cloud-config instead Signed-off-by: Itxaka * Rename the livecd config and use the REPO name on iso building Signed-off-by: Itxaka * Fix yaml Signed-off-by: Itxaka * bump operator image Signed-off-by: Itxaka * Add defaults to makefile for docker builds Signed-off-by: Itxaka * Allow setting the elemental version on the grub line Easier to identify the current used version Signed-off-by: Itxaka * update jobs Signed-off-by: Itxaka * Fix docker version image Signed-off-by: Itxaka * Add ipxe target Signed-off-by: Itxaka * Add ipxe and build ipxe by default Signed-off-by: Itxaka * Make makefile targets more simple Signed-off-by: Itxaka * upload files separatedly Signed-off-by: Itxaka * fix e2e yaml Signed-off-by: Itxaka --- .github/workflows/e2e-tests.yaml | 158 ------------ .github/workflows/e2e.yaml | 54 ++++ .github/workflows/image.yaml | 50 ++++ .github/workflows/images-dev.yaml | 30 --- .github/workflows/integration-tests.yaml | 214 ---------------- .github/workflows/release.yaml | 17 +- Dockerfile.dapper | 24 -- Dockerfile.docs | 3 - Dockerfile.e2e | 35 --- Dockerfile.image | 68 +++++ Dockerfile.iso | 12 +- Dockerfile.kvm | 53 ---- Makefile | 200 ++++++++------- framework/files/etc/cos/config | 2 +- framework/files/etc/luet/luet.yaml | 16 ++ .../rancher-system-agent.service | 1 + .../ros-installer.service | 1 - .../ros-installer.service.d/override.conf | 3 - .../files/system/oem/01_elemental-rootfs.yaml | 4 + .../system/oem/05_motd_and_autologin.yaml | 2 +- .../system/oem/99_elemental-operator.yaml | 7 + .../system/rancher-system-agent.service | 19 ++ .../lib/systemd/system/ros-installer.service | 16 -- framework/files/usr/sbin/ros-operator-install | 45 ---- iso/grub.cfg | 11 +- ros-image-build | 241 ------------------ system/README.md | 1 - system/files/etc/bash.bashrc.local | 19 -- system/files/etc/os-release.tmpl | 9 - 29 files changed, 346 insertions(+), 969 deletions(-) delete mode 100644 .github/workflows/e2e-tests.yaml create mode 100644 .github/workflows/e2e.yaml create mode 100644 .github/workflows/image.yaml delete mode 100644 .github/workflows/images-dev.yaml delete mode 100644 .github/workflows/integration-tests.yaml delete mode 100644 Dockerfile.dapper delete mode 100644 Dockerfile.docs delete mode 100644 Dockerfile.e2e create mode 100644 Dockerfile.image delete mode 100644 Dockerfile.kvm create mode 100644 framework/files/etc/luet/luet.yaml create mode 120000 framework/files/etc/systemd/system/multi-user.target.wants/rancher-system-agent.service delete mode 120000 framework/files/etc/systemd/system/multi-user.target.wants/ros-installer.service delete mode 100644 framework/files/etc/systemd/system/ros-installer.service.d/override.conf create mode 100644 framework/files/system/oem/99_elemental-operator.yaml create mode 100644 framework/files/usr/lib/systemd/system/rancher-system-agent.service delete mode 100644 framework/files/usr/lib/systemd/system/ros-installer.service delete mode 100755 framework/files/usr/sbin/ros-operator-install delete mode 100755 ros-image-build delete mode 100644 system/README.md delete mode 100644 system/files/etc/bash.bashrc.local delete mode 100644 system/files/etc/os-release.tmpl diff --git a/.github/workflows/e2e-tests.yaml b/.github/workflows/e2e-tests.yaml deleted file mode 100644 index 92b6ec263..000000000 --- a/.github/workflows/e2e-tests.yaml +++ /dev/null @@ -1,158 +0,0 @@ -name: Elemental End-To-End tests with Rancher - -on: - push: - branches: [ master ] - paths-ignore: - - 'docs/**' - - '*docs*' - - 'README.md' - workflow_dispatch: - -env: - REPO: quay.io/costoolkit/os2-ci -jobs: - build: - runs-on: build-host - container: - image: ubuntu:latest - env: - DOCKER_USERNAME: ${{ secrets.QUAY_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.QUAY_PASSWORD }} - DOCKER_REGISTRY: quay.io - steps: - - name: Install dependencies - run: | - apt-get update - apt-get install -y sudo make curl docker.io - - name: Checkout - uses: actions/checkout@v3 - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2 - - name: Make images (container/iso/qcow2/etc.) - run: make ci - - name: Cache data - uses: actions/cache@v3 - id: cache-artifacts - with: - path: dist/artifacts/* - key: ${{ github.sha }}-${{ github.repository }}-artifacts - - name: Upload .txt - uses: actions/upload-artifact@v3 - with: - name: txt - path: dist/artifacts/*.txt - if-no-files-found: warn - e2e-tests: - runs-on: kvm-host - needs: build - container: - image: opensuse/leap:latest - env: - CLUSTER_NAME: cluster-k3s - CLUSTER_NS: fleet-default - INSTALL_K3S_VERSION: v1.21.9+k3s1 - INSTALL_K3S_SKIP_ENABLE: true - KUBECONFIG: /etc/rancher/k3s/k3s.yaml - PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - ARCH: amd64 - options: --privileged - steps: - - name: Install dependencies - run: zypper -n in -l qemu-kvm libvirt virt-install curl helm git-core tar make gcc - - name: Checkout - uses: actions/checkout@v3 - - name: Install Go - uses: actions/setup-go@v3 - with: - go-version: '~1.17' - - name: Download cache - uses: actions/cache@v3 - id: cache-artifacts - with: - path: dist/artifacts/* - key: ${{ github.sha }}-${{ github.repository }}-artifacts - - name: Move artifacts - run: | - ls -l dist/artifacts/ - mv dist/artifacts/* . - - name: E2E - Clean local Helm repositorie - run: | - # Clean Helm repo - HELM_REPO=$(helm repo list 2>/dev/null | awk '(NR>1) { print $1 }') - [[ -n "${HELM_REPO}" ]] && helm repo remove ${HELM_REPO} || true - - name: E2E - Install Rancher - run: cd tests && make e2e-install-rancher - - name: E2E - Bootstrap node 1 with current build - env: - VM_INDEX: 1 - run: cd tests && make e2e-bootstrap-node - - name: E2E - Bootstrap node 2 with current build - env: - VM_INDEX: 2 - run: cd tests && make e2e-bootstrap-node - - name: E2E - Upgrade node 2 (with UpgradeChannel method) to latest released build - env: - UPGRADE_TYPE: managedOSVersionName - VM_INDEX: 2 - run: | - VERSION=$(curl -s ${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/latest \ - | sed -n -E '/"tag_name":/s/.*"([^"]+)".*/\1/p') - # This variable is used to check the OS version after upgrade - export CONTAINER_IMAGE=:${VERSION}-${ARCH} - # Execute test - cd tests && make e2e-upgrade-node - - name: E2E - Backup current build - run: mkdir -p backup && mv -f rancheros-${GITHUB_SHA::7}-${ARCH}* $_ - - name: E2E - Download latest release - uses: robinraju/release-downloader@v1.3 - with: - repository: ${{ github.repository }} - latest: true - fileName: "*" - - name: E2E - Bootstrap node 3 with latest released build - env: - VM_INDEX: 3 - run: cd tests && make e2e-bootstrap-node - - name: E2E - Upgrade node 3 (with osImage method) to current build - env: - UPGRADE_TYPE: osImage - VM_INDEX: 3 - run: | - # This variable is used to upgrade the OS and check the OS version after upgrade - export CONTAINER_IMAGE=${REPO}:${GITHUB_SHA::7}-${ARCH} - # Execute test - cd tests && make e2e-upgrade-node - - name: E2E - Bootstrap node 4 with latest released build - env: - VM_INDEX: 4 - run: cd tests && make e2e-bootstrap-node - - name: E2E - Upgrade node 4 (with manual method) to current build - env: - UPGRADE_TYPE: manual - VM_INDEX: 4 - run: | - # This variable is used to upgrade the OS and check the OS version after upgrade - export CONTAINER_IMAGE=${REPO}:${GITHUB_SHA::7}-${ARCH} - # Execute test - cd tests && make e2e-upgrade-node - - name: Upload logs - uses: actions/upload-artifact@v3 - if: failure() - with: - name: k3s-install.log - path: /tmp/k3s.log - if-no-files-found: warn - - name: Release space from container ♻ - if: always() - run: | - rm -rf build bin dist - cleanup: - runs-on: kvm-host - if: always() - needs: e2e-tests - steps: - - name: Release space from worker ♻ - run: | - sudo docker system prune -f -a --volumes diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml new file mode 100644 index 000000000..c6bfeb4ec --- /dev/null +++ b/.github/workflows/e2e.yaml @@ -0,0 +1,54 @@ +name: e2e + +on: + push: + branches: + - master + pull_request: + +jobs: + build-all-artifacts: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Export tag + id: export_tag + run: | + git describe --abbrev=0 --tags + TAG=`git describe --abbrev=0 --tags 2>/dev/null || echo "v0.0.0"` + echo "::set-output name=elemental_tag::$TAG" + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y genisoimage + - name: Build image + run: | + make build + make dump_image + + - name: Build iso + run: | + make iso + - name: Build ipxe artifacts + run: | + make extract_kernel_init_squash + make ipxe + - uses: actions/upload-artifact@v3 + with: + name: docker-image + path: build/*.tar + - uses: actions/upload-artifact@v3 + with: + name: iso-image + path: build/*.iso + - uses: actions/upload-artifact@v3 + with: + name: ipxe-artifacts + path: | + build/*-kernel + build/*-initrd + build/*.squashfs + build/*.ipxe \ No newline at end of file diff --git a/.github/workflows/image.yaml b/.github/workflows/image.yaml new file mode 100644 index 000000000..6137ea8d0 --- /dev/null +++ b/.github/workflows/image.yaml @@ -0,0 +1,50 @@ +name: Build elemental docker image + +on: + push: + branches: + - master + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + env: + REPO: ttl.sh/elemental-ci + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Export tag + id: export_tag + run: | + git describe --abbrev=0 --tags + TAG=`git describe --abbrev=0 --tags 2>/dev/null || echo "v0.0.0"` + echo "::set-output name=elemental_tag::$TAG" + - name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + images: | + ${{ env.REPO }} + tags: | + type=semver,pattern=v{{version}} + type=sha,format=short,prefix=${{ steps.export_tag.outputs.elemental_tag }}- + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + - name: Build image + uses: docker/build-push-action@v2 + with: + context: . + tags: ${{ steps.meta.outputs.tags }} + # cache into GitHub actions cache, nice + cache-from: type=gha + cache-to: type=gha,mode=max + target: default + file: Dockerfile.image + build-args: | + IMAGE_TAG=${{ steps.meta.outputs.version }} + IMAGE_COMMIT=${{ github.sha }} + IMAGE_REPO=${{ env.REPO }} \ No newline at end of file diff --git a/.github/workflows/images-dev.yaml b/.github/workflows/images-dev.yaml deleted file mode 100644 index a14986660..000000000 --- a/.github/workflows/images-dev.yaml +++ /dev/null @@ -1,30 +0,0 @@ -name: Build images - -on: - workflow_dispatch: - -concurrency: - group: images-dev-${{ github.head_ref || github.ref }}-${{ github.repository }} - cancel-in-progress: true - -jobs: - build: - runs-on: ubuntu-latest - env: - REPO: quay.io/costoolkit/os2 - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Login to Container Registry - uses: docker/login-action@v2 - with: - registry: quay.io - username: ${{ secrets.QUAY_USERNAME }} - password: ${{ secrets.QUAY_PASSWORD }} - - name: Build and push - run: make build push - - name: Release space from worker ♻ - if: always() - run: | - sudo rm -rf build bin dist || true - docker system prune -f -a --volumes || true diff --git a/.github/workflows/integration-tests.yaml b/.github/workflows/integration-tests.yaml deleted file mode 100644 index e5df270e0..000000000 --- a/.github/workflows/integration-tests.yaml +++ /dev/null @@ -1,214 +0,0 @@ -name: Integration tests -on: - push: - branches: - - master - pull_request: - -concurrency: - group: integration-tests=full-${{ github.head_ref || github.ref }}-${{ github.repository }} - cancel-in-progress: true - -env: - REPO: ttl.sh/os2-ci - TAG: ${{ github.sha }} -jobs: - build: - runs-on: ubuntu-latest - env: - DOCKER_REGISTRY: ttl.sh - PUSH: "true" - # Disable KVM for Vagrant image (can be forced during execution if needed) - NO_KVM: 1 - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2 - - name: Make images (container/iso/qcow2/etc.) - run: make ci - - name: Upload results - uses: actions/upload-artifact@v3 - with: - name: artifacts - path: | - dist/artifacts/* - !dist/artifacts/*.iso - !dist/artifacts/*.qcow.gz - !dist/artifacts/*.box - if-no-files-found: error - - name: Upload ISO - uses: actions/upload-artifact@v3 - with: - name: iso - path: dist/artifacts/*.iso - if-no-files-found: warn - - name: Upload QCOW - uses: actions/upload-artifact@v3 - with: - name: qcow - path: dist/artifacts/*.qcow.gz - if-no-files-found: warn - - name: Upload BOX - uses: actions/upload-artifact@v3 - with: - name: box - path: dist/artifacts/*.box - if-no-files-found: warn - - name: Upload .txt - uses: actions/upload-artifact@v3 - with: - name: txt - path: dist/artifacts/*.txt - if-no-files-found: warn - - name: Release space from worker ♻ - if: always() - run: | - sudo rm -rf build bin dist || true - docker system prune -f -a --volumes || true - tests-installer: - runs-on: macos-10.15 - needs: build - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Install Go - uses: actions/setup-go@v3 - with: - go-version: '~1.17' - - name: Install dependencies - run: brew install cdrtools jq - - name: Download artifacts - uses: actions/download-artifact@v3 - with: - name: iso - path: artifacts - - name: Run tests - env: - BOX_URL: ${{ github.event.inputs.box-image }} - run: | - ls -liah - ls -liah artifacts - mv artifacts/*.iso ros.iso - rm -rf artifacts - export COS_HOST=127.0.0.1:2222 - export ISO=$PWD/ros.iso - export CONTAINER_IMAGE=$REPO:$TAG - make deps - cd tests && make installer-tests - - name: Upload logs - uses: actions/upload-artifact@v3 - if: failure() - with: - name: ros-vbox.logs.zip - path: tests/**/logs/* - if-no-files-found: warn - - name: Release space from worker ♻ - if: always() - run: | - cd tests && make clean || true - sudo rm -rf build bin dist || true - docker system prune -f -a --volumes || true - tests-vbox: - runs-on: macos-10.15 - needs: build - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Install Go - uses: actions/setup-go@v3 - with: - go-version: '~1.17' - - name: Install dependencies - run: brew install cdrtools jq - - name: Download artifacts - uses: actions/download-artifact@v3 - with: - name: iso - path: artifacts - - name: Run tests - env: - BOX_URL: ${{ github.event.inputs.box-image }} - run: | - ls -liah - ls -liah artifacts - mv artifacts/*.iso ros.iso - rm -rf artifacts - export COS_HOST=127.0.0.1:2222 - export ISO=$PWD/ros.iso - make deps - cd tests && make vbox-tests - - name: Upload logs - uses: actions/upload-artifact@v3 - if: failure() - with: - name: ros-vbox.logs.zip - path: tests/**/logs/* - if-no-files-found: warn - - name: Release space from worker ♻ - if: always() - run: | - cd tests && make clean || true - sudo rm -rf build bin dist || true - docker system prune -f -a --volumes || true - tests: - runs-on: ubuntu-latest - needs: build - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Install Go - uses: actions/setup-go@v3 - with: - go-version: '~1.17' - - name: Download artifacts - uses: actions/download-artifact@v3 - with: - name: box - path: artifacts - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get remove -y apparmor* - sudo apt-get install -y qemu-system-x86 make libvirt-daemon-system bridge-utils ovmf curl - curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - - sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" - sudo apt-get update && sudo apt-get install vagrant - sudo apt-get install -y qemu libvirt-daemon-system libvirt-clients ebtables dnsmasq-base - sudo apt-get install -y libxslt-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev - sudo apt-get install -y libguestfs-tools gcc - vagrant plugin install vagrant-libvirt - - name: Prepare libvirt - run: | - # Create bridge conf - sudo mkdir -p /etc/qemu/ - echo "allow all" | sudo tee -a /etc/qemu/bridge.conf - sudo chmod u+r /etc/qemu/bridge.conf - sudo chmod u+s $(find /usr/ -name qemu-bridge-helper -print -quit|xargs) - - # sudo /usr/sbin/libvirtd & - # sleep 5 - # Set a static ip for our VM - sudo virsh net-update default add ip-dhcp-host "" --live --config || true - - name: Run tests - run: | - ls -liah - ls -liah artifacts - mv artifacts/*.box ros.box - rm -rf artifacts - export BOX=$PWD/ros.box - make integration-tests - - name: Upload logs - uses: actions/upload-artifact@v3 - if: failure() - with: - name: ros-libvirt.logs.zip - path: tests/**/logs/* - if-no-files-found: warn - - name: Release space from worker ♻ - if: always() - run: | - cd tests && make clean || true - sudo rm -rf build bin dist || true - docker system prune -f -a --volumes || true diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index b1326f766..9b1659e01 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -4,7 +4,6 @@ on: push: tags: - 'v*' - jobs: build: runs-on: build-host @@ -14,26 +13,18 @@ jobs: DOCKER_USERNAME: ${{ secrets.QUAY_USERNAME }} DOCKER_PASSWORD: ${{ secrets.QUAY_PASSWORD }} DOCKER_REGISTRY: quay.io - REPO: quay.io/costoolkit/os2 - # Disable KVM for Vagrant image (can be forced during execution if needed) + REPO: quay.io/costoolkit/elemental NO_KVM: 1 steps: - - name: Install dependencies - run: | - apt-get update - apt-get install -y sudo make curl docker.io - name: Checkout uses: actions/checkout@v3 - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2 - - name: Make images (container/iso/qcow2/etc.) - run: make ci + - name: Build Artifacts + run: echo "Build" - name: Release uses: rancher-sandbox/github-action-ghr@v1 if: startsWith(github.ref, 'refs/tags/') env: - GHR_PATH: dist/artifacts/ + GHR_PATH: build/ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GHR_PARALLELISM: "1" - name: Release space from worker ♻ diff --git a/Dockerfile.dapper b/Dockerfile.dapper deleted file mode 100644 index 40ecb9cd2..000000000 --- a/Dockerfile.dapper +++ /dev/null @@ -1,24 +0,0 @@ -FROM opensuse/leap:15.3 -RUN sed -i -s 's/^# rpm.install.excludedocs/rpm.install.excludedocs/' /etc/zypp/zypp.conf -RUN zypper ref - -ARG DAPPER_HOST_ARCH -ENV ARCH $DAPPER_HOST_ARCH - -RUN zypper in -y bash git gcc docker vim less file curl wget ca-certificates make mkisofs go1.16 qemu-tools trousers-devel helm mtools tar gzip openssl-devel -RUN go get golang.org/x/tools/cmd/goimports -RUN if [ "${ARCH}" == "amd64" ]; then \ - curl -sL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.40.1; \ - fi - -ENV DOCKER_BUILDKIT 1 -ENV DOCKER_CLI_EXPERIMENTAL enabled -ENV DAPPER_ENV REPO TAG DRONE_TAG PUSH CROSS DOCKER_REGISTRY DOCKER_USERNAME DOCKER_PASSWORD AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_DEFAULT_REGION GITHUB_REPOSITORY UPGRADECHANNEL_DISCOVERY_IMAGE NO_KVM -ENV DAPPER_SOURCE /go/src/github.com/rancher-sandbox/os2/ -ENV DAPPER_OUTPUT ./bin ./dist -ENV DAPPER_DOCKER_SOCKET true -ENV DAPPER_RUN_ARGS "-v ros-go16-pkg-1:/go/pkg -v ros-go16-cache-1:/root/.cache/go-build" -WORKDIR ${DAPPER_SOURCE} - -ENTRYPOINT ["./scripts/entry"] -CMD ["ci"] diff --git a/Dockerfile.docs b/Dockerfile.docs deleted file mode 100644 index afb16870b..000000000 --- a/Dockerfile.docs +++ /dev/null @@ -1,3 +0,0 @@ -FROM squidfunk/mkdocs-material -RUN pip install mkdocs-markdownextradata-plugin -RUN apk add -U git openssh diff --git a/Dockerfile.e2e b/Dockerfile.e2e deleted file mode 100644 index 3bdb7301e..000000000 --- a/Dockerfile.e2e +++ /dev/null @@ -1,35 +0,0 @@ -ARG BASE_IMAGE=registry.opensuse.org/home/kwk/elemental/images/sle_15_sp3/rancher/rancher-node-image/5.2 -FROM $BASE_IMAGE - -# Framework files -COPY framework/cos/ / -COPY framework/files/ / - -# Copy in some local OS customizations -COPY system/files / - -ARG IMAGE_TAG=latest -RUN cat /etc/os-release.tmpl | env \ - "VERSION=${IMAGE_TAG}" \ - "VERSION_ID=$(echo ${IMAGE_TAG} | sed s/^v//)" \ - "PRETTY_NAME=RancherOS ${IMAGE_TAG}" \ - envsubst > /etc/os-release && \ - rm /etc/os-release.tmpl - -# IMPORTANT: Setup rancheros-release used for versioning/upgrade. The -# values here should reflect the tag of the image being built -ARG IMAGE_REPO=norepo -RUN echo "IMAGE_REPO=${IMAGE_REPO}" > /usr/lib/rancheros-release && \ - echo "IMAGE_TAG=${IMAGE_TAG}" >> /usr/lib/rancheros-release && \ - echo "IMAGE=${IMAGE_REPO}:${IMAGE_TAG}" >> /usr/lib/rancheros-release - -# Rebuild initrd to setup dracut with the boot configurations -RUN mkinitrd && \ - # aarch64 has an uncompressed kernel so we need to link it to vmlinuz - kernel=$(ls /boot/Image-* | head -n1) && \ - if [ -e "$kernel" ]; then ln -sf "${kernel#/boot/}" /boot/vmlinuz; fi - -# Save some space -RUN rm -rf /var/log/update* && \ - >/var/log/lastlog && \ - rm -rf /boot/vmlinux* \ No newline at end of file diff --git a/Dockerfile.image b/Dockerfile.image new file mode 100644 index 000000000..5577eea0e --- /dev/null +++ b/Dockerfile.image @@ -0,0 +1,68 @@ +# ARGS go first if used on FROM +ARG OPERATOR_IMAGE=quay.io/costoolkit/elemental-operator:v0.3.0 +ARG SYSTEM_AGENT_IMAGE=rancher/system-agent:v0.2.9 +# Binaries and files needed from elemental-toolkit repository +ARG LUET_VERSION=0.32.5 +FROM quay.io/luet/base:$LUET_VERSION AS framework-build +COPY framework/files/etc/luet/luet.yaml /etc/luet/luet.yaml +ENV LUET_NOLOCK=true +SHELL ["/usr/bin/luet", "install", "-y", "--system-target", "/framework"] + +RUN utils/k9s +RUN utils/nerdctl +RUN utils/rancherd +RUN toolchain/elemental-cli +RUN toolchain/cosign +RUN selinux/rancher + + +# elemental-operator +FROM $OPERATOR_IMAGE as elemental-operator + +# rancher-system-agent +FROM $SYSTEM_AGENT_IMAGE as system-agent + + +# Base os +FROM registry.suse.com/suse/sle-micro-rancher/5.2:latest as default + +# Copy installed files from the luet repos +COPY --from=framework-build /framework / +# Copy elemental-operator +COPY --from=elemental-operator /usr/sbin/elemental-operator /usr/sbin/elemental-operator +# Copy rancher-system-agent +COPY --from=system-agent /usr/bin/rancher-system-agent /usr/sbin/rancher-system-agent + +# Copy local framework files +COPY framework/cos/ / +COPY framework/files/ / + +ARG IMAGE_TAG=latest +ARG IMAGE_COMMIT="" +RUN echo NAME="Elemental" > /etc/os-release +RUN echo ID="elemental" >> /etc/os-release +RUN echo ID_LIKE="suse opensuse" >> /etc/os-release +RUN echo BUG_REPORT_URL="https://github.com/rancher/elemental/issues" >> /etc/os-release +RUN echo HOME_URL="https://github.com/rancher/elemental" >> /etc/os-release +RUN echo "VERSION=${IMAGE_TAG}" >> /etc/os-release +RUN echo "VERSION_ID=$(echo ${IMAGE_TAG} | sed s/^v//)" >> /etc/os-release +RUN echo "PRETTY_NAME=Elemental ${IMAGE_TAG}" >> /etc/os-release +RUN echo "COMMIT=${IMAGE_COMMIT}" >> /etc/os-release + +# IMPORTANT: Setup rancheros-release used for versioning/upgrade. The +# values here should reflect the tag of the image being built +ARG IMAGE_REPO=norepo +RUN echo "IMAGE_REPO=${IMAGE_REPO}" > /usr/lib/rancheros-release +RUN echo "IMAGE_TAG=${IMAGE_TAG}" >> /usr/lib/rancheros-release +RUN echo "IMAGE=${IMAGE_REPO}:${IMAGE_TAG}" >> /usr/lib/rancheros-release + +# Rebuild initrd to setup dracut with the boot configurations +RUN mkinitrd && \ + # aarch64 has an uncompressed kernel so we need to link it to vmlinuz + kernel=$(ls /boot/Image-* | head -n1) && \ + if [ -e "$kernel" ]; then ln -sf "${kernel#/boot/}" /boot/vmlinuz; fi + +# Save some space +RUN rm -rf /var/log/update* && \ + >/var/log/lastlog && \ + rm -rf /boot/vmlinux* \ No newline at end of file diff --git a/Dockerfile.iso b/Dockerfile.iso index a03b04657..26b934f19 100644 --- a/Dockerfile.iso +++ b/Dockerfile.iso @@ -1,10 +1,16 @@ -FROM registry.opensuse.org/isv/rancher/elemental/teal52/15.3/rancher/elemental-node-image/5.2:latest AS os -FROM registry.opensuse.org/isv/rancher/elemental/teal52/15.3/rancher/elemental-builder-image as tools +ARG OS_IMAGE=registry.opensuse.org/isv/rancher/elemental/teal52/15.3/rancher/elemental-node-image/5.2:latest +ARG TOOL_IMAGE=registry.opensuse.org/isv/rancher/elemental/teal52/15.3/rancher/elemental-builder-image + +FROM $OS_IMAGE AS os +FROM $TOOL_IMAGE as tools FROM tools AS default WORKDIR /iso COPY --from=os / rootfs COPY iso/grub.cfg overlay/boot/grub2/grub.cfg ARG CLOUD_CONFIG_FILE=iso/config -COPY $CLOUD_CONFIG_FILE overlay/config +COPY $CLOUD_CONFIG_FILE overlay/livecd-cloud-config.yaml +ARG ELEMENTAL_VERSION="" +RUN echo $ELEMENTAL_VERSION +RUN grub2-editenv overlay/boot/grub2/elementalversion set version=$ELEMENTAL_VERSION ENTRYPOINT ["/usr/bin/elemental"] diff --git a/Dockerfile.kvm b/Dockerfile.kvm deleted file mode 100644 index 6b10fd2d0..000000000 --- a/Dockerfile.kvm +++ /dev/null @@ -1,53 +0,0 @@ -FROM opensuse/leap:15.3 -RUN sed -i -s 's/^# rpm.install.excludedocs/rpm.install.excludedocs/' /etc/zypp/zypp.conf -RUN zypper ref -RUN zypper install -y socat net-tools-deprecated libtasn1-devel gnutls-devel libseccomp-devel json-glib-devel system-user-tss git -RUN zypper install -y autoconf -RUN zypper install -y automake -RUN git clone https://github.com/stefanberger/swtpm.git /usr/src/swtpm -RUN zypper install -y libtool -RUN zypper install -y gcc -RUN zypper install -y libopenssl-devel -RUN git clone https://github.com/stefanberger/libtpms.git /usr/src/libtpms -RUN zypper install -y gcc-c++ -RUN zypper install -y make -RUN zypper install -y expect -RUN zypper install -y sudo -RUN zypper install -y bridge-utils -RUN cd /usr/src/libtpms && \ - ./autogen.sh --with-openssl --with-tpm2 && \ - make -j4 && \ - make install -RUN cd /usr/src/swtpm && \ - ./autogen.sh --prefix=/usr --libdir=/usr/lib64 --with-openssl --with-tss-user=root --with-tss-group=tss && \ - make -j4 && \ - sudo make -j4 && \ - sudo make install -RUN zypper install -y qemu-x86 qemu-arm qemu-tools -RUN zypper in -y curl -RUN zypper in -y git -RUN cd /usr/src && \ - git clone git://git.ipxe.org/ipxe.git -RUN zypper in -y xz-devel -RUN zypper in -y syslinux -RUN zypper in -y mkisofs -RUN cd /usr/src/ipxe/src && \ - sed -i 's/undef\tDOWNLOAD_PROTO_HTTPS/define\tDOWNLOAD_PROTO_HTTPS/' config/general.h && \ - sed -i 's/define OCSP_CHECK/undef\tOCSP_CHECK/' config/crypto.h && \ - make DEBUG=httpcore:3 bin/ipxe.iso && \ - mkdir -p /usr/share/ipxe/ && \ - cp bin/ipxe.iso /usr/share/ipxe/ - -RUN zypper in -y iproute2 -RUN zypper in -y dnsmasq -RUN zypper in -y bind-utils - -COPY scripts/qemu-in-container /usr/bin/ -COPY scripts/startvm /usr/bin/ -ENTRYPOINT ["/usr/bin/qemu-in-container"] - -RUN chmod +s /usr/lib/qemu-bridge-helper -RUN echo 'allow all' > /etc/qemu/bridge.conf - -VOLUME /tmp/emulated_tpm -VOLUME /image diff --git a/Makefile b/Makefile index ceb6639b3..b2984de8e 100644 --- a/Makefile +++ b/Makefile @@ -1,119 +1,123 @@ -.DEFAULT_GOAL := package -REPO?=quay.io/costoolkit/os2 -TAG?=dev -IMAGE=${REPO}:${TAG} +GIT_COMMIT ?= $(shell git rev-parse HEAD) +GIT_COMMIT_SHORT ?= $(shell git rev-parse --short HEAD) +GIT_TAG ?= $(shell git describe --abbrev=0 --tags 2>/dev/null || echo "v0.0.0" ) +TAG ?= ${GIT_TAG}-${GIT_COMMIT_SHORT} +REPO?=ttl.sh/elemental-ci +IMAGE=${REPO}:${GIT_TAG} ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) SUDO?=sudo FRAMEWORK_PACKAGES?=meta/cos-light CLOUD_CONFIG_FILE?="iso/config" - -.dapper: - @echo Downloading dapper - @curl -sL https://releases.rancher.com/dapper/latest/dapper-$$(uname -s)-$$(uname -m) > .dapper.tmp - @@chmod +x .dapper.tmp - @./.dapper.tmp -v - @mv .dapper.tmp .dapper - -.PHONY: ci -ci: .dapper - ./.dapper ci - -.PHONY: package -package: .dapper - ./.dapper package +# This are the default images already in the dockerfile but we want to be able to override them +OPERATOR_IMAGE?=quay.io/costoolkit/elemental-operator:v0.3.0 +SYSTEM_AGENT_IMAGE?=rancher/system-agent:v0.2.9 +TOOL_IMAGE?=quay.io/costoolkit/elemental:v0.0.15-f1fabd4 +# Used to know if this is a release or just a normal dev build +RELEASE_TAG?=false + +# Set tag based on release status for ease of use +ifeq ($(RELEASE_TAG), "true") +FINAL_TAG=$(GIT_TAG) +else +FINAL_TAG=$(TAG) +endif .PHONY: clean clean: - rm -rf build dist - -.PHONY: build-test -build-test: - docker build \ - --build-arg CACHEBUST=${CACHEBUST} \ - --build-arg IMAGE_TAG=${TAG} \ + rm -rf build + +# Build elemental docker images +.PHONY: build +build: + @DOCKER_BUILDKIT=1 docker build -f Dockerfile.image \ + --target default \ + --build-arg IMAGE_TAG=${FINAL_TAG} \ + --build-arg IMAGE_COMMIT=${GIT_COMMIT} \ --build-arg IMAGE_REPO=${REPO} \ - -t ${IMAGE} \ - -f Dockerfile.e2e . - mkdir -p dist/artifacts - docker run --name build_tmp -d ${IMAGE} sleep 5 - docker cp ${ROOT_DIR}/scripts build_tmp:/scripts - docker exec build_tmp /bin/sh -c '/scripts/package-info.sh > /packages.txt' - docker cp build_tmp:/packages.txt dist/artifacts/packages.txt - docker rm -f build_tmp + --build-arg OPERATOR_IMAGE=${OPERATOR_IMAGE} \ + --build-arg SYSTEM_AGENT_IMAGE=${SYSTEM_AGENT_IMAGE} \ + -t ${REPO}:${FINAL_TAG} \ + . -.PHONY: push -push: - docker push ${IMAGE} +.PHONY: dump_image +dump_image: + @mkdir -p build + @docker save ${REPO}:${FINAL_TAG} -o build/elemental_${FINAL_TAG}.tar +# Build iso with the elemental image as base .PHONY: iso iso: - ./ros-image-build ${IMAGE} iso - @echo "INFO: ISO available at build/output.iso" - -.PHONY: proper_iso +ifeq ($(CLOUD_CONFIG_FILE),"iso/config") + @echo "No CLOUD_CONFIG_FILE set, using the default one at ${CLOUD_CONFIG_FILE}" +endif + @mkdir -p build + @DOCKER_BUILDKIT=1 docker build -f Dockerfile.iso \ + --target default \ + --build-arg CLOUD_CONFIG_FILE=${CLOUD_CONFIG_FILE} \ + --build-arg OS_IMAGE=${REPO}:${FINAL_TAG} \ + --build-arg TOOL_IMAGE=${TOOL_IMAGE} \ + --build-arg ELEMENTAL_VERSION=${FINAL_TAG} \ + -t iso:${FINAL_TAG} . + @DOCKER_BUILDKIT=1 docker run --rm -v $(PWD)/build:/mnt \ + iso:${FINAL_TAG} \ + --debug build-iso \ + -o /mnt \ + --squash-no-compression \ + -n elemental-${FINAL_TAG} \ + --overlay-iso overlay dir:rootfs + @echo "INFO: ISO available at build/elemental-${FINAL_TAG}.iso" + +# Build an iso with the OBS base containers +.PHONY: remote_iso proper_iso: ifeq ($(CLOUD_CONFIG_FILE),"iso/config") @echo "No CLOUD_CONFIG_FILE set, using the default one at ${CLOUD_CONFIG_FILE}" endif - @mkdir -p dist/artifacts - @DOCKER_BUILDKIT=1 docker build -f Dockerfile.iso --target default --build-arg CLOUD_CONFIG_FILE=${CLOUD_CONFIG_FILE} -t elemental/iso:latest . - @DOCKER_BUILDKIT=1 docker run --rm -v $(PWD)/dist/artifacts:/mnt elemental/iso:latest --debug build-iso -o /mnt --squash-no-compression -n elemental-${TAG} --overlay-iso overlay dir:rootfs - @echo "INFO: ISO available at dist/artifacts/elemental-${TAG}.iso" + @mkdir -p build + @DOCKER_BUILDKIT=1 docker build -f Dockerfile.iso \ + --target default \ + --build-arg CLOUD_CONFIG_FILE=${CLOUD_CONFIG_FILE} \ + -t iso:latest . + @DOCKER_BUILDKIT=1 docker run --rm -v $(PWD)/build:/mnt \ + iso:latest \ + --debug build-iso \ + -o /mnt \ + --squash-no-compression \ + -n elemental-${FINAL_TAG} \ + --overlay-iso overlay dir:rootfs + @echo "INFO: ISO available at build/elemental-${FINAL_TAG}.iso" .PHONY: extract_kernel_init_squash - isoinfo -x /rootfs.squashfs -R -i dist/artifacts/elemental-${TAG}.iso > build/output.squashfs - isoinfo -x /boot/kernel.xz -R -i dist/artifacts/elemental-${TAG}.iso > build/output-kernel - isoinfo -x /boot/rootfs.xz -R -i dist/artifacts/elemental-${TAG}.iso > build/output-initrd - - -.PHONY: qcow -qcow: - ./ros-image-build ${IMAGE} qcow - @echo "INFO: QCOW image available at build/output.qcow.gz" - -.PHONY: ami-% -ami-%: - AWS_DEFAULT_REGION=$* ./ros-image-build ${IMAGE} ami - -.PHONY: ami -ami: - ./ros-image-build ${IMAGE} ami - -.PHONY: run -run: - ./scripts/run - -.PHONY: run -pxe: - ./scripts/run pxe - -serve-docs: mkdocs - docker run -p 8000:8000 --rm -it -v $${PWD}:/docs mkdocs serve -a 0.0.0.0:8000 - -mkdocs: - docker build -t mkdocs -f Dockerfile.docs . - -all-amis: \ - ami-us-west-1 \ - ami-us-west-2 - #ami-ap-east-1 \ - #ami-ap-northeast-1 \ - #ami-ap-northeast-2 \ - #ami-ap-northeast-3 \ - #ami-ap-southeast-1 \ - #ami-ap-southeast-2 \ - #ami-ca-central-1 \ - #ami-eu-central-1 \ - #ami-eu-south-1 \ - #ami-eu-west-1 \ - #ami-eu-west-2 \ - #ami-eu-west-3 \ - #ami-me-south-1 \ - #ami-sa-east-1 \ - #ami-us-east-1 \ - #ami-us-east-2 \ - -deps: +extract_kernel_init_squash: + isoinfo -x /rootfs.squashfs -R -i build/elemental-${FINAL_TAG}.iso > build/elemental-${FINAL_TAG}.squashfs + isoinfo -x /boot/kernel.xz -R -i build/elemental-${FINAL_TAG}.iso > build/elemental-${FINAL_TAG}-kernel + isoinfo -x /boot/rootfs.xz -R -i build/elemental-${FINAL_TAG}.iso > build/elemental-${FINAL_TAG}-initrd + +.PHONY: ipxe +ipxe: + echo "#!ipxe" > build/elemental-${FINAL_TAG}.ipxe + echo "set arch amd64" >> build/elemental-${FINAL_TAG}.ipxe +ifeq ($(RELEASE_TAG), "true") + echo "set url https://github.com/rancher/elemental/releases/download/${FINAL_TAG}" >> build/elemental-${FINAL_TAG}.ipxe +else + echo "set url tftp://10.0.2.2/${TAG}" >> build/elemental-${FINAL_TAG}.ipxe +endif + echo "set kernel elemental-${FINAL_TAG}-kernel" >> build/elemental-${FINAL_TAG}.ipxe + echo "set initrd elemental-${FINAL_TAG}-initrd" >> build/elemental-${FINAL_TAG}.ipxe + echo "set rootfs elemental-${FINAL_TAG}.squashfs" >> build/elemental-${FINAL_TAG}.ipxe + echo "set iso elemental-${FINAL_TAG}.iso" >> build/elemental-${FINAL_TAG}.ipxe #not used anymore, check if we can boot from iso directly with sanboot? + echo "kernel ${url}/${kernel} initrd=${initrd} ip=dhcp rd.cos.disable root=live:${url}/${rootfs} console=tty1 console=ttyS0 ${cmdline}" >> build/elemental-${FINAL_TAG}.ipxe + echo "initrd ${url}${initrd}" >> build/elemental-${FINAL_TAG}.ipxe + echo "boot" >> build/elemental-${FINAL_TAG}.ipxe + +.PHONY: build_all +build_all: build iso extract_kernel_init_squash ipxe + +.PHONY: docs +docs: + mkdocs build + +deps: go install -mod=mod github.com/onsi/ginkgo/v2/ginkgo@latest go get github.com/onsi/gomega/... diff --git a/framework/files/etc/cos/config b/framework/files/etc/cos/config index 0134b4183..680630f6e 100644 --- a/framework/files/etc/cos/config +++ b/framework/files/etc/cos/config @@ -17,7 +17,7 @@ CHANNEL_UPGRADES=false #RECOVERY_IMAGE="quay.io/mudler/cos-test:cos-standard" # GRUB entry to display on boot. ( defaults: cOS ) -GRUB_ENTRY_NAME="RancherOS" +GRUB_ENTRY_NAME="Elemental" # Space separated list of additional paths that are used to # source cloud-config from. ( defaults paths are: /system/oem /oem/ /usr/local/cloud-config/ ) diff --git a/framework/files/etc/luet/luet.yaml b/framework/files/etc/luet/luet.yaml new file mode 100644 index 000000000..6fea5d14a --- /dev/null +++ b/framework/files/etc/luet/luet.yaml @@ -0,0 +1,16 @@ +repositories: + - &cos + name: "cos" + description: "cOS official" + type: "docker" + cached: true + priority: 1 + arch: "amd64" + reference: v0.8.14-22-repository.yaml + verify: false + urls: + - "quay.io/costoolkit/releases-teal" + - <<: *cos + arch: "arm64" + urls: + - "quay.io/costoolkit/releases-teal-arm64" \ No newline at end of file diff --git a/framework/files/etc/systemd/system/multi-user.target.wants/rancher-system-agent.service b/framework/files/etc/systemd/system/multi-user.target.wants/rancher-system-agent.service new file mode 120000 index 000000000..2942d631b --- /dev/null +++ b/framework/files/etc/systemd/system/multi-user.target.wants/rancher-system-agent.service @@ -0,0 +1 @@ +/usr/lib/systemd/system/rancher-system-agent.service \ No newline at end of file diff --git a/framework/files/etc/systemd/system/multi-user.target.wants/ros-installer.service b/framework/files/etc/systemd/system/multi-user.target.wants/ros-installer.service deleted file mode 120000 index c80e1a312..000000000 --- a/framework/files/etc/systemd/system/multi-user.target.wants/ros-installer.service +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/ros-installer.service \ No newline at end of file diff --git a/framework/files/etc/systemd/system/ros-installer.service.d/override.conf b/framework/files/etc/systemd/system/ros-installer.service.d/override.conf deleted file mode 100644 index 39c4dd87a..000000000 --- a/framework/files/etc/systemd/system/ros-installer.service.d/override.conf +++ /dev/null @@ -1,3 +0,0 @@ -[Unit] -After= -After=cos-setup-network.service \ No newline at end of file diff --git a/framework/files/system/oem/01_elemental-rootfs.yaml b/framework/files/system/oem/01_elemental-rootfs.yaml index 9218d09ec..f8ecdd2f1 100644 --- a/framework/files/system/oem/01_elemental-rootfs.yaml +++ b/framework/files/system/oem/01_elemental-rootfs.yaml @@ -78,4 +78,8 @@ stages: commands: - elemental cloud-init -s initramfs /oem/userdata - elemental cloud-init -s boot /oem/userdata + - rm -rf /oem/userdata_load + - if: '[ -f oem/userdata_load ]' + name: Clear any userdata leftovers + commands: - rm -rf /oem/userdata_load \ No newline at end of file diff --git a/framework/files/system/oem/05_motd_and_autologin.yaml b/framework/files/system/oem/05_motd_and_autologin.yaml index 458ac91bb..b83c51527 100644 --- a/framework/files/system/oem/05_motd_and_autologin.yaml +++ b/framework/files/system/oem/05_motd_and_autologin.yaml @@ -7,7 +7,7 @@ stages: content: | Installation is in progress. - You can "journalctl -f -u elemental-operator" to view progress + You can "journalctl -f -t elemental" to view progress permissions: 0644 - path: /etc/systemd/system/serial-getty@ttyS0.service.d/override.conf diff --git a/framework/files/system/oem/99_elemental-operator.yaml b/framework/files/system/oem/99_elemental-operator.yaml new file mode 100644 index 000000000..fe9b12a6e --- /dev/null +++ b/framework/files/system/oem/99_elemental-operator.yaml @@ -0,0 +1,7 @@ +name: "Elemental operator bootstrap" +stages: + network: + # run only if on live cd and there is a config file + - if: '[ -f /run/cos/live_mode ] && [ -f /run/initramfs/live/livecd-cloud-config.yaml ]' + commands: + - elemental-operator register --debug /run/initramfs/live/ \ No newline at end of file diff --git a/framework/files/usr/lib/systemd/system/rancher-system-agent.service b/framework/files/usr/lib/systemd/system/rancher-system-agent.service new file mode 100644 index 000000000..b3ce26dc1 --- /dev/null +++ b/framework/files/usr/lib/systemd/system/rancher-system-agent.service @@ -0,0 +1,19 @@ +[Unit] +Description=Rancher System Agent +Documentation=https://github.com/rancher/system-agent +Wants=network-online.target +After=network-online.target +ConditionPathExists=!/run/cos/live_mode +ConditionPathExists=!/opt/rancher-system-agent + +[Install] +WantedBy=multi-user.target + +[Service] +Type=simple +Restart=always +RestartSec=5s +StandardOutput=journal+console +StandardError=journal+console +Environment="CATTLE_AGENT_CONFIG=/etc/rancher/agent/config.yaml" +ExecStart=/usr/sbin/rancher-system-agent sentinel diff --git a/framework/files/usr/lib/systemd/system/ros-installer.service b/framework/files/usr/lib/systemd/system/ros-installer.service deleted file mode 100644 index db1e5b087..000000000 --- a/framework/files/usr/lib/systemd/system/ros-installer.service +++ /dev/null @@ -1,16 +0,0 @@ -[Unit] -Description=RancherOS Automatic Installation -Documentation=https://github.com/rancher-sandbox/os2 -Wants=network-online.target -After=network-online.target - -[Install] -WantedBy=multi-user.target - -[Service] -Type=oneshot -EnvironmentFile=-/etc/default/%N -EnvironmentFile=-/etc/sysconfig/%N -TimeoutStartSec=0 -StandardOutput=journal+console -ExecStart=/usr/sbin/ros-installer -automatic diff --git a/framework/files/usr/sbin/ros-operator-install b/framework/files/usr/sbin/ros-operator-install deleted file mode 100755 index bdcb89997..000000000 --- a/framework/files/usr/sbin/ros-operator-install +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash -set -x -e - -source /usr/lib/rancheros-release - -manifest() { - cat << EOF -kind: ManagedOSImage -apiVersion: rancheros.cattle.io/v1 -metadata: - name: default-os-image - namespace: fleet-local -spec: - osImage: "${IMAGE}" -EOF -} - -if [ -e /etc/rancher/rke2/rke2.yaml ]; then - export KUBECONFIG=/etc/rancher/rke2/rke2.yaml -elif [ -e /etc/rancher/k3s/k3s.yaml ]; then - export KUBECONFIG=/etc/rancher/k3s/k3s.yaml -else - exit 0 -fi - -PULL_POLICY=IfNotPresent -if [ "$IMAGE_TAG" = dev ]; then - PULL_POLICY=Always -fi - -helm upgrade \ - --install \ - --create-namespace \ - -n cattle-rancheros-operator-system \ - --set image.imagePullPolicy=${PULL_POLICY} \ - rancheros-operator /usr/share/rancher/os2/rancheros-operator-chart.tgz - -while ! kubectl get crd managedosimages.rancheros.cattle.io; do - echo Waiting for RancherOS Operator to be running - sleep 15 -done - -while ! manifest | kubectl apply -f -; do - sleep 15 -done diff --git a/iso/grub.cfg b/iso/grub.cfg index 63ae2dddc..651b496b1 100644 --- a/iso/grub.cfg +++ b/iso/grub.cfg @@ -1,4 +1,13 @@ search --file --set=root /boot/kernel.xz + +# Load custom config file +set custom="/boot/grub2/elementalversion" +search --no-floppy --file --set=custom_blk "${custom}" +if [ "${custom_blk}" ] ; then + load_env -f "(${custom_blk})${custom}" +fi + + set default=0 set timeout=10 set timeout_style=menu @@ -19,7 +28,7 @@ set font=($root)/boot/${grub_cpu}/loader/grub2/fonts/unicode.pf2 if [ -f ${font} ];then loadfont ${font} fi -menuentry "Elemental Teal Install" --class os --unrestricted { +menuentry "Elemental Teal Install ${version}" --class os --unrestricted { echo Loading kernel... $linux ($root)/boot/kernel.xz cdroot root=live:CDLABEL=COS_LIVE rd.live.dir=/ rd.live.squashimg=rootfs.squashfs console=tty1 console=ttyS0 rd.cos.disable elemental.install.automatic=true elemental.install.config_url=/run/initramfs/live/config echo Loading initrd... diff --git a/ros-image-build b/ros-image-build deleted file mode 100755 index 1e3de353b..000000000 --- a/ros-image-build +++ /dev/null @@ -1,241 +0,0 @@ -#!/bin/bash -# Note: ros-image-build requires the input image to be pushed -# due to buildx usage. - -# Export this here so users dont need to -export DOCKER_BUILDKIT=1 - -set -e - -build() -{ - dockerfile | docker build -f - --build-arg IMAGE="${IMAGE}" . "${@}" -} - -dockerfile() -{ - cat << "EOF" -ARG IMAGE=rancher/os2:dev - -FROM ${IMAGE} AS os - -FROM quay.io/costoolkit/elemental:v0.0.14-5bdba36 AS elemental - -# Keep using leap 15.3. libslirp looks broken and incompatible with packer -FROM opensuse/leap:15.3 AS tools -COPY --from=elemental /usr/bin/elemental /usr/bin - -RUN sed -i -s 's/^# rpm.install.excludedocs/rpm.install.excludedocs/' /etc/zypp/zypp.conf -RUN zypper ref -ENV LUET_NOLOCK=true -# Copy luet from the official images -RUN zypper in -y squashfs xorriso curl unzip git qemu-arm qemu-x86 qemu-tools tar e2fsprogs dosfstools pigz go1.16 qemu-uefi-aarch64 mtools rsync - -RUN cd /usr/sbin && \ - rm packer && \ - SUFFIX=amd64 && \ - if [ "$(uname -m)" = "aarch64" ]; then SUFFIX=arm64; fi && \ - curl https://releases.hashicorp.com/packer/1.7.4/packer_1.7.4_linux_${SUFFIX}.zip > tmp && \ - unzip tmp && \ - rm tmp -RUN cd /usr/src && \ - git clone https://github.com/rancher-sandbox/cOS-toolkit && \ - cd cOS-toolkit && git checkout ${COS_VERSION} -b build -RUN mkdir -p /iso/iso-overlay/boot/grub2 -RUN echo -e \ -'search --file --set=root /boot/kernel.xz\n'\ -'set default=0\n'\ -'set timeout=10\n'\ -'set timeout_style=menu\n'\ -'set linux=linux\n'\ -'set initrd=initrd\n'\ -'if [ "${grub_cpu}" = "x86_64" -o "${grub_cpu}" = "i386" -o "${grub_cpu}" = "arm64" ];then\n'\ -' if [ "${grub_platform}" = "efi" ]; then\n'\ -' if [ "${grub_cpu}" != "arm64" ]; then\n'\ -' set linux=linuxefi\n'\ -' set initrd=initrdefi\n'\ -' fi\n'\ -' fi\n'\ -'fi\n'\ -'if [ "${grub_platform}" = "efi" ]; then\n'\ -' echo "Please press 't' to show the boot menu on this console"\n'\ -'fi\n'\ -'set font=($root)/boot/${grub_cpu}/loader/grub2/fonts/unicode.pf2\n'\ -'if [ -f ${font} ];then\n'\ -' loadfont ${font}\n'\ -'fi\n'\ -'menuentry "RancherOS Install" --class os --unrestricted {\n'\ -' echo Loading kernel...\n'\ -' $linux ($root)/boot/kernel.xz cdroot root=live:CDLABEL=COS_LIVE rd.live.dir=/ rd.live.squashimg=rootfs.squashfs console=tty1 console=ttyS0 rd.cos.disable rancheros.install.automatic=true rancheros.install.config_url=/run/initramfs/live/config\n'\ -' echo Loading initrd...\n'\ -' $initrd ($root)/boot/rootfs.xz\n'\ -'}\n'\ -'\n'\ -'if [ "${grub_platform}" = "efi" ]; then\n'\ -' hiddenentry "Text mode" --hotkey "t" {\n'\ -' set textmode=true\n'\ -' terminal_output console\n'\ -' }\n'\ -'fi\n' > /iso/iso-overlay/boot/grub2/grub.cfg -RUN echo -e '#cloud-config\n'\ -'rancheros:\n'\ -' install:\n'\ -' automatic: false\n' > /iso/iso-overlay/config -ARG CONFIG -RUN if [ -n "$CONFIG" ]; then echo "$CONFIG" > /iso/iso-overlay/config; fi -WORKDIR /usr/src/cOS-toolkit/packer - -FROM tools AS iso-build -COPY --from=os / /iso/overlay -RUN cd /iso && \ - elemental --debug build-iso -n output --overlay-iso /iso/iso-overlay /iso/overlay - -FROM iso-build AS qcow-build -ARG ACCEL=tcg -RUN SUFFIX= && \ - FIRMWARE= && \ - if [ "$(uname -m)" = "aarch64" ]; then SUFFIX=-arm64; FIRMWARE=/usr/share/qemu/qemu-uefi-aarch64.bin; fi && \ - echo '#!/bin/bash' > /usr/bin/image && \ - echo 'set -e -x' >> /usr/bin/image && \ - echo PACKER_LOG=1 packer build \ - -var "aws_temporary_security_group_source_cidr=$(curl -sf https://api.ipify.org)/32" \ - -var "root_password=ros" \ - -var "firmware=${FIRMWARE}" \ - -var "memory=1024" \ - -var "iso=/iso/output.iso" \ - -var "accelerator=${ACCEL}" \ - -only qemu.cos${SUFFIX} . >> /usr/bin/image && \ - chmod +x /usr/bin/image -RUN echo 'mkdir /output &&' >> /usr/bin/image && \ - echo 'mv *.box /output/output.box' >> /usr/bin/image && \ - echo 'pigz -dc *.tar.gz | tar xvf -' >> /usr/bin/image && \ - echo 'cat cOS | pigz -c > /output/output.qcow.gz'>> /usr/bin/image -ENTRYPOINT /usr/bin/image - -FROM qcow-build AS qcow-build2 -RUN bash -x /usr/bin/image - -FROM scratch AS qcow -COPY --from=qcow-build2 /output/ / - -FROM scratch AS iso -COPY --from=iso-build /iso/output.iso / - -FROM tools AS ami -ARG AWS_ACCESS_KEY_ID -ARG AWS_SECRET_ACCESS_KEY -ARG AWS_DEFAULT_REGION -ARG IMAGE=rancher/os2:dev -ARG NAME=RancherOS-Image-dev -ARG VERSION=1 -ARG GIT_COMMIT=HEAD -RUN packer build \ - -var "cos_version=${VERSION}" \ - -var "git_sha=${GIT_COMMIT}" \ - -var 'aws_instance_type=t3.medium' \ - -var 'aws_source_ami_filter_owners=["053594193760"]' \ - -var "aws_cos_deploy_args=cos-deploy --no-verify --no-cosign --docker-image ${IMAGE}" \ - -var "name=${NAME}" \ - -only amazon-ebs.cos . - -FROM scratch AS default -COPY --from=iso / / -COPY --from=qcow / / -EOF -} - - -iso() -{ - if [ -n "$CONFIG" ]; then - CONFIG_DATA="$(<$CONFIG)" - fi - build --target iso -o build/ --build-arg CONFIG="${CONFIG_DATA}" -} - -qcow() -{ - ID=qcow-${RANDOM} - if docker run -i --device /dev/kvm busybox /bin/true && [[ -z "${NO_KVM}" ]]; then - build --target qcow-build --build-arg ACCEL=kvm -t $ID - docker run --net=host -i --device /dev/kvm --name $ID $ID - else - build --target qcow-build --build-arg ACCEL=tcg -t $ID - docker run --net=host -i --name $ID $ID - fi || { - docker rm -fv $ID - docker rmi $ID - exit 1 - } - mkdir -p build/ - docker export $ID | tar xvf - -C build/ output/ --strip-components=1 - docker rm -fv $ID - docker rmi $ID -} - -ami() -{ - if [ -z "${AWS_ACCESS_KEY_ID}" ] || [ -z "${AWS_SECRET_ACCESS_KEY}" ] || [ -z "${AWS_DEFAULT_REGION}" ]; then - echo ERROR: The following environment variables must be set: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY AWS_DEFAULT_REGION - exit 1 - fi - - build --target ami \ - --build-arg AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \ - --build-arg AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \ - --build-arg AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION} \ - --build-arg NAME="${NAME}" \ - --build-arg GIT_COMMIT="${GIT_COMMIT}" \ - --build-arg VERSION="${VERSION}" -} - -usage() -{ - echo "Usage:" - echo " $0 IMAGE OUTPUT [ISO_CLOUD_CONFIG]" - echo - echo " IMAGE: a Docker image" - echo " OUTPUT: Comma seperated value of output image formats. Valid: aws,iso,qcow" - echo " ISO_CLOUD_CONFIG: An option file that will be used as the default cloud-init in an ISO" -} - -IMAGE=$1 -OUTPUT=$2 -CONFIG=$3 -VERSION=${IMAGE##*:} -GIT_COMMIT=${GIT_COMMIT:-HEAD} -NAME=${IMAGE%%:${VERSION}} -NAME=${NAME//[^a-zA-Z0-9-@.\/_]/-} -COS_VERSION=${COS_VERSION:-e95d49a66605d6622776391e95e175a80528e872} - -if [ "$1" == dockerfile ]; then - dockerfile - exit 0 -fi - -if [ -z "${OUTPUT}" ] || [ -z "${IMAGE}" ] || echo "$@" | grep -q -- -h; then - usage - exit 1 -fi - -{ - IFS=, - for i in ${OUTPUT}; do - case $i in - ami) - ami - ;; - qcow) - qcow - ;; - iso) - iso - ;; - *) - echo Unknown format $i - echo - usage - exit 1 - esac - done -} diff --git a/system/README.md b/system/README.md deleted file mode 100644 index 22a284701..000000000 --- a/system/README.md +++ /dev/null @@ -1 +0,0 @@ -Here are stored OS specific configuration files which are not directly pertinent to cOS. \ No newline at end of file diff --git a/system/files/etc/bash.bashrc.local b/system/files/etc/bash.bashrc.local deleted file mode 100644 index b9579df56..000000000 --- a/system/files/etc/bash.bashrc.local +++ /dev/null @@ -1,19 +0,0 @@ -if [ -z "$KUBECONFIG" ]; then - if [ -e /etc/rancher/rke2/rke2.yaml ]; then - export KUBECONFIG="/etc/rancher/rke2/rke2.yaml" - else - export KUBECONFIG="/etc/rancher/k3s/k3s.yaml" - fi -fi -export PATH="${PATH}:/var/lib/rancher/rke2/bin" -if [ -z "$CONTAINER_RUNTIME_ENDPOINT" ]; then - export CONTAINER_RUNTIME_ENDPOINT=unix:///var/run/k3s/containerd/containerd.sock -fi -if [ -z "$IMAGE_SERVICE_ENDPOINT" ]; then - export IMAGE_SERVICE_ENDPOINT=unix:///var/run/k3s/containerd/containerd.sock -fi - -# For ctr -if [ -z "$CONTAINERD_ADDRESS" ]; then - export CONTAINERD_ADDRESS=/run/k3s/containerd/containerd.sock -fi diff --git a/system/files/etc/os-release.tmpl b/system/files/etc/os-release.tmpl deleted file mode 100644 index 3e9e4f3f6..000000000 --- a/system/files/etc/os-release.tmpl +++ /dev/null @@ -1,9 +0,0 @@ -NAME="RancherOS" -ID="rancheros" -ID_LIKE="suse opensuse" -BUG_REPORT_URL="https://github.com/rancher-sandbox/os2/issues" -HOME_URL="https://github.com/rancher-sandbox/os2" - -VERSION="${VERSION}" -VERSION_ID="${VERSION_ID}" -PRETTY_NAME="${PRETTY_NAME}"