Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quark: Implement quark builder #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@ Cargo.lock
.idea
*.tar.gz
.vscode
ctr-bundle

# Generated on quark build
ctr-bundle
kaps
linux-cloud-hypervisor
alpine-minirootfs
initramfs.img
quark.json
*.qrk
7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = { version = "3.0.5", features = ["derive"] }
clap = { version = "3.0.5", features = ["derive"] }
git2 = "0.14.2"
serde = { version = "1.0.136", features = ["derive"] }
serde_json = "1.0.79"
tar = "0.4.38"
flate2 = "1.0.23"
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
# Lumper
# Quark

<img src="https://img.shields.io/github/workflow/status/virt-do/quark/quark%20build%20and%20unit%20tests?style=for-the-badge" />

## Build a quardle

Building a `quardle` with the container image bundled into the initramfs image :

```bash
quark build --image <container_image_url> --offline --quardle <quardle_name>
```

Building a `quardle` with the container image to be pulled from within the guest:

```bash
quark build --image <container_image_url> --quardle <quardle_name>
```

## Run a quardle

```bash
quark run --quardle <quardle> --output <output_file>
```
24 changes: 24 additions & 0 deletions scripts/mkbundle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# From https://github.com/virt-do/kaps/blob/main/hack/mkbundle.sh

# The URL of a container image archive should be supplied in parameter
# Example with alpine : https://dl-cdn.alpinelinux.org/alpine/v3.14/releases/x86_64/alpine-minirootfs-3.14.2-x86_64.tar.gz
if [[ $# -ne 1 ]]; then
echo "Missing container image URL"
exit 1
fi

DEST="ctr-bundle"
IMAGE_ARCHIVE_URL=$1
IMAGE_ARCHIVE_NAME="imageArchive"

rm -rf $DEST $IMAGE_ARCHIVE_NAME && mkdir -p "$DEST"/rootfs

# Download and untar the image
curl -sSL $IMAGE_ARCHIVE_URL -o $IMAGE_ARCHIVE_NAME
tar xf $IMAGE_ARCHIVE_NAME -C "$DEST"/rootfs
rm $IMAGE_ARCHIVE_NAME

pushd "$DEST" > /dev/null
# Generate a runtime spec
runc spec --rootless
popd > /dev/null
16 changes: 16 additions & 0 deletions scripts/mkkernel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# From https://github.com/virt-do/lumper/blob/main/kernel/mkkernel.sh

CONFIG_URL="https://raw.githubusercontent.com/virt-do/lumper/main/kernel/linux-config-x86_64"
LINUX_REPO=linux-cloud-hypervisor

if [ ! -d $LINUX_REPO ]
then
echo "Cloning linux-cloud-hypervisor git repository..."
git clone --depth 1 "https://github.com/cloud-hypervisor/linux.git" -b "ch-5.14" $LINUX_REPO
fi

pushd $LINUX_REPO > /dev/null
pwd
wget -qO .config $CONFIG_URL
make bzImage -j `nproc`
popd > /dev/null
34 changes: 34 additions & 0 deletions scripts/mkrootfs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# From https://github.com/virt-do/lumper/blob/main/rootfs/mkrootfs.sh

DEST="alpine-minirootfs"
IMAGE_ARCHIVE_URL="https://dl-cdn.alpinelinux.org/alpine/v3.14/releases/x86_64/alpine-minirootfs-3.14.2-x86_64.tar.gz"
IMAGE_ARCHIVE_NAME="imageArchive"

rm -rf $DEST $IMAGE_ARCHIVE_NAME && mkdir $DEST

# Download and untar the image
curl -sSL $IMAGE_ARCHIVE_URL -o $IMAGE_ARCHIVE_NAME
tar xf $IMAGE_ARCHIVE_NAME -C $DEST
rm $IMAGE_ARCHIVE_NAME

pushd "$DEST" > /dev/null
# Create an init file in the rootfs
cat > init <<EOF
#! /bin/sh
#
# /init executable file in the initramfs
#
mount -t devtmpfs dev /dev
mount -t proc proc /proc
mount -t sysfs sysfs /sys
ip link set up dev lo

exec /opt/kaps run --bundle /ctr-bundle
poweroff -f
EOF

chmod +x init

popd > /dev/null

# Here we do not create the rootfs image because we need to add some files in it later
Loading