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

feat(*): use published images instead of locally built ones #820

Merged
merged 4 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
11 changes: 11 additions & 0 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Build artifacts and pull images
description: 'Build artifacts and pull images'

runs:
using: composite
steps:
- name: Build and pull
shell: bash
run: |
make OPT_PROFILE=release build install
sudo make pull
9 changes: 9 additions & 0 deletions .github/actions/setup-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Setup Environment
description: 'Common environment setup'

runs:
using: composite
steps:
- name: Setup OS dependencies
shell: bash
run: ./scripts/setup-$(echo "$RUNNER_OS" | tr '[:upper:]' '[:lower:]').sh
6 changes: 1 addition & 5 deletions .github/workflows/action-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ jobs:
run: |
echo "::notice::Running job with os: '${{ inputs.os }}', arch: '${{ inputs.arch }}', slug: '${{ inputs.slug }}', runtime: '${{ inputs.runtime }}', target: '${{ inputs.target }}'"
- uses: actions/checkout@v4
- name: Setup build env
run: |
os=$(echo "$RUNNER_OS" | tr '[:upper:]' '[:lower:]')
./scripts/setup-$os.sh
shell: bash
- uses: ./.github/actions/setup-env
- uses: actions-rust-lang/setup-rust-toolchain@v1
env:
RUST_CACHE_KEY_OS: rust-cache-${{ inputs.os }}-${{ inputs.slug }}
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/action-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ jobs:
with:
components: rustfmt, clippy
rustflags: '' #Disable. By default this action sets environment variable is set to -D warnings. We manage this in the Makefile
- name: Setup build env
run: |
os=$(echo "$RUNNER_OS" | tr '[:upper:]' '[:lower:]')
./scripts/setup-$os.sh
shell: bash
- uses: ./.github/actions/setup-env
- run:
# needed to run rustfmt in nightly toolchain
rustup toolchain install nightly --component rustfmt
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/action-test-k3s.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ jobs:
runs-on: ${{ inputs.os }}
steps:
- uses: actions/checkout@v4
- name: Setup build env
run: ./scripts/setup-linux.sh
shell: bash
- uses: ./.github/actions/setup-env
- name: Download artifacts
uses: actions/download-artifact@master
with:
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/action-test-kind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ jobs:
runs-on: ${{ inputs.os }}
steps:
- uses: actions/checkout@v4
- name: Setup build env
run: ./scripts/setup-linux.sh
shell: bash
- uses: ./.github/actions/setup-env
- name: Download artifacts
uses: actions/download-artifact@master
with:
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/action-test-smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ jobs:
runs-on: ${{ inputs.os }}
steps:
- uses: actions/checkout@v4
- name: Setup build env
run: ./scripts/setup-linux.sh
shell: bash
- uses: ./.github/actions/setup-env
- name: Download artifacts
uses: actions/download-artifact@master
with:
Expand All @@ -44,8 +42,8 @@ jobs:
run: |
ls -alh dist
ls -alh dist/bin
make load
sudo cp -f dist/bin/* /usr/local/bin
sudo make pull-app
sudo ctr run --rm --runtime=io.containerd.${{ inputs.runtime }}.v1 ghcr.io/containerd/runwasi/wasi-demo-app:latest testwasm /wasi-demo-app.wasm echo 'hello'
- name: Verify Jaeger traces
run: |
Expand Down
33 changes: 6 additions & 27 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,8 @@ jobs:
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
rustflags: '' #Disable. By default this action sets environment variable is set to -D warnings. We manage this in the Makefile
- name: Setup build environment
shell: bash
run: |
os=$(echo "$RUNNER_OS" | tr '[:upper:]' '[:lower:]')
./scripts/setup-$os.sh
- name: Build and load shims and wasi-demo-app
shell: bash
run: |
make OPT_PROFILE=release build install test-image load test-image/oci load/oci
- uses: ./.github/actions/setup-env
- uses: ./.github/actions/build
- name: Run Benchmarks
shell: bash
run: |
Expand Down Expand Up @@ -61,15 +54,8 @@ jobs:
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
rustflags: '' #Disable. By default this action sets environment variable is set to -D warnings. We manage this in the Makefile
- name: Setup build environment
shell: bash
run: |
os=$(echo "$RUNNER_OS" | tr '[:upper:]' '[:lower:]')
./scripts/setup-$os.sh
- name: Build and load shims and wasi-demo-app
shell: bash
run: |
make OPT_PROFILE=release build install test-image load test-image/oci load/oci
- uses: ./.github/actions/setup-env
- uses: ./.github/actions/build
- name: Run Benchmarks
shell: bash
run: |
Expand Down Expand Up @@ -105,15 +91,8 @@ jobs:
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
rustflags: '' #Disable. By default this action sets environment variable is set to -D warnings. We manage this in the Makefile
- name: Setup build environment
shell: bash
run: |
os=$(echo "$RUNNER_OS" | tr '[:upper:]' '[:lower:]')
./scripts/setup-$os.sh
- name: Build and load shims and wasi-demo-app
shell: bash
run: |
make OPT_PROFILE=release build install test-image/http load/http
- uses: ./.github/actions/setup-env
- uses: ./.github/actions/build
- name: Start wasmtime shim
shell: bash
run: |
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup build env
run: ./scripts/setup-linux.sh
shell: bash
- uses: ./.github/actions/setup-env
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: Swatinem/rust-cache@v2
- name: Check documentation
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/release-wasi-demo-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ jobs:
wasi_http: ${{ steps.get_digests.outputs.wasi_http }}
steps:
- uses: actions/checkout@v4
- name: Setup build env
run: ./scripts/setup-linux.sh
- uses: ./.github/actions/setup-env
- name: Install Rust and wasm32-wasi target
uses: actions-rs/toolchain@v1
with:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ jobs:
run: |
echo "::notice::Running job with dry_run: '${{ inputs.dry_run }}', crate: '${{ matrix.crate }}', version: '${{ matrix.version }}', runtime: '${{ matrix.runtime }}', and is_shim: '${{ matrix.is_shim }}'."
- uses: actions/checkout@v4
- name: Setup build env
run: ./scripts/setup-linux.sh
- uses: ./.github/actions/setup-env
- name: Download artifacts
if: ${{ matrix.is_shim == 'true' }}
uses: actions/download-artifact@master
Expand Down
44 changes: 22 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -215,27 +215,30 @@ dist/img-oci-artifact.tar: target/wasm32-wasip1/$(OPT_PROFILE)/img-oci-artifact.
@mkdir -p "dist/"
cp "$<" "$@"

load: dist/img.tar
sudo ctr -n $(CONTAINERD_NAMESPACE) image import --all-platforms $<
.PHONY: pull pull-app pull-oci pull-oci-artifact pull-http
pull: pull-app pull-oci pull-oci-artifact pull-http
echo "Pulled all images"

pull-app:
ctr image pull ghcr.io/containerd/runwasi/wasi-demo-app:latest

pull-oci:
ctr image pull ghcr.io/containerd/runwasi/wasi-demo-oci:latest

pull-oci-artifact:
ctr image pull ghcr.io/containerd/runwasi/wasi-demo-oci-artifact:latest

pull-http:
ctr image pull ghcr.io/containerd/runwasi/wasi-http:latest

docker/load: dist/img.tar
docker load -i $<

CTR_VERSION := $(shell sudo ctr version | sed -n -e '/Version/ {s/.*: *//p;q;}')
load/oci: dist/img-oci.tar dist/img-oci-artifact.tar
@echo $(CTR_VERSION)\\nv1.7.7 | sort -crV || @echo $(CTR_VERSION)\\nv1.6.25 | sort -crV || (echo "containerd version must be 1.7.7+ or 1.6.25+ was $(CTR_VERSION)" && exit 1)
@echo using containerd $(CTR_VERSION)
sudo ctr -n $(CONTAINERD_NAMESPACE) image import --all-platforms $<
sudo ctr -n $(CONTAINERD_NAMESPACE) image import --all-platforms dist/img-oci-artifact.tar

docker/load/oci: dist/img-oci.tar dist/img-oci-artifact.tar
docker load -i dist/img-oci.tar
docker load -i dist/img-oci-artifact.tar

.PHONY: load/http
load/http: dist/http-img-oci.tar
sudo ctr -n $(CONTAINERD_NAMESPACE) image import --all-platforms $<

.PHONY: docker/load/http
docker/load/http: dist/http-img-oci.tar
docker load -i $<

Expand Down Expand Up @@ -276,9 +279,8 @@ test/nginx:
mkdir -p $@/out && docker save -o $@/out/img.tar docker.io/nginx:latest

.PHONY: test/k8s/cluster-%
test/k8s/cluster-%: dist/img.tar bin/kind test/k8s/_out/img-%
bin/kind create cluster --name $(KIND_CLUSTER_NAME) --image="$(shell cat test/k8s/_out/img-$*)" && \
bin/kind load image-archive --name $(KIND_CLUSTER_NAME) $(<)
test/k8s/cluster-%: bin/kind test/k8s/_out/img-%
bin/kind create cluster --name $(KIND_CLUSTER_NAME) --image="$(shell cat test/k8s/_out/img-$*)"


.PHONY: test/k8s/deploy-workload-%
Expand All @@ -290,9 +292,7 @@ test/k8s/deploy-workload-%: test/k8s/clean test/k8s/cluster-%
kubectl --context=kind-$(KIND_CLUSTER_NAME) wait deployment wasi-demo --for condition=Available=True --timeout=5s

.PHONY: test/k8s/deploy-workload-oci-%
test/k8s/deploy-workload-oci-%: test/k8s/clean test/k8s/cluster-% dist/img-oci.tar dist/img-oci-artifact.tar test/k8s/cluster-%
bin/kind load image-archive --name $(KIND_CLUSTER_NAME) dist/img-oci.tar
bin/kind load image-archive --name $(KIND_CLUSTER_NAME) dist/img-oci-artifact.tar
test/k8s/deploy-workload-oci-%: test/k8s/clean test/k8s/cluster-%
kubectl --context=kind-$(KIND_CLUSTER_NAME) apply -f test/k8s/deploy.oci.yaml
kubectl --context=kind-$(KIND_CLUSTER_NAME) wait deployment wasi-demo --for condition=Available=True --timeout=300s
# verify that we are still running after some time
Expand Down Expand Up @@ -333,7 +333,7 @@ bin/k3s/clean:

.PHONY: test/k3s-%
test/k3s-%: dist/img.tar bin/k3s dist-%
sudo bash -c -- 'while ! timeout 40 test/k3s/bootstrap.sh "$*" dist/img.tar; do $(MAKE) bin/k3s/clean bin/k3s; done'
sudo bash -c -- 'while ! timeout 40 test/k3s/bootstrap.sh "$*"; do $(MAKE) bin/k3s/clean bin/k3s; done'
sudo bin/k3s kubectl get pods --all-namespaces
sudo bin/k3s kubectl apply -f test/k8s/deploy.yaml
sudo bin/k3s kubectl get pods --all-namespaces
Expand All @@ -346,8 +346,8 @@ test/k3s-%: dist/img.tar bin/k3s dist-%
sudo bin/k3s kubectl wait deployment wasi-demo --for delete --timeout=60s

.PHONY: test/k3s-oci-%
test/k3s-oci-%: dist/img-oci.tar bin/k3s dist-%
sudo bash -c -- 'while ! timeout 40 test/k3s/bootstrap.sh "$*" dist/img-oci.tar; do $(MAKE) bin/k3s/clean bin/k3s; done'
test/k3s-oci-%: bin/k3s dist-%
sudo bash -c -- 'while ! timeout 40 test/k3s/bootstrap.sh "$*"; do $(MAKE) bin/k3s/clean bin/k3s; done'
sudo bin/k3s kubectl get pods --all-namespaces
sudo bin/k3s kubectl apply -f test/k8s/deploy.oci.yaml
sudo bin/k3s kubectl get pods --all-namespaces
Expand Down
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,10 @@ sudo make install

> Note: `make build` will only build one binary. The `make install` command copies the binary to $PATH and uses symlinks to create all the component described above.

Build the test image and load it into containerd:
Pull the test image:

```
make test-image
make load
sudo make pull-app
```

### Demo 1 using container image that contains a Wasm module.
Expand Down Expand Up @@ -185,11 +184,10 @@ To learn more about this approach checkout the [design document](https://docs.go

> **Note**: This requires containerd 1.7.7+ and 1.6.25+. If you do not have these patches for both `containerd` and `ctr` you will end up with an error message such as `mismatched image rootfs and manifest layers` at the import and run steps. Latest versions of k3s and kind have the necessary containerd versions.

Build and import the OCI image with WASM layers image:
Pull the OCI image with WASM layers image:

```
make test-image/oci
make load/oci
sudo make pull
```

Run the image with `sudo ctr run --rm --runtime=io.containerd.[ wasmedge | wasmtime | wasmer | wamr ].v1 ghcr.io/containerd/runwasi/wasi-demo-oci:latest testwasmoci`
Expand All @@ -205,8 +203,6 @@ exiting
The [CNCF tag-runtime wasm working group](https://tag-runtime.cncf.io/wgs/wasm/charter/) has a [OCI Artifact format for Wasm](https://tag-runtime.cncf.io/wgs/wasm/deliverables/wasm-oci-artifact/). This is a new Artifact type that enable the usage across projects beyond just runwasi, see the https://tag-runtime.cncf.io/wgs/wasm/deliverables/wasm-oci-artifact/#implementations

```
make test-image/oci
make load/oci
make test/k8s-oci-wasmtime
```

Expand Down
7 changes: 2 additions & 5 deletions benches/containerd-shim-benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@ make build
sudo make install
```

Then, build and load the wasi-demo-app:
Then, pull the wasi-demo-app:
```bash
make test-image
make load
make test-image/oci
make load/oci
sudo make pull
```

To run all benchmarks:
Expand Down
4 changes: 2 additions & 2 deletions crates/containerd-shim-wasmtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ cargo run --bin oci-tar-builder -- \
-o ./dist/wasi-http-img-oci.tar
```

- Import the image:
- Pull the image:

```shell
sudo ctr image import --all-platforms ./dist/wasi-http-img-oci.tar
sudo make pull-http
```

- Run the image:
Expand Down
3 changes: 1 addition & 2 deletions docs/windows-getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ To finish off installing pre-requisites, install Rust following [this](https://w
After following these steps and navigating to the runwasi directory in your terminal:
- run `make build`,
- run `make install`,
- run `make test-image`, and
- run `make load`.
- run `sudo make pull-app`.

After this, you can execute an example, like: `ctr run --rm --runtime=io.containerd.wasmtime.v1 ghcr.io/containerd/runwasi/wasi-demo-app:latest testwasm`.

Expand Down
1 change: 0 additions & 1 deletion test/k3s/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@ EOF
systemctl daemon-reload
systemctl restart k3s-runwasi
while ! bin/k3s ctr version; do sleep 1; done
bin/k3s ctr image import --all-platforms $2
while [ "$(bin/k3s kubectl get pods --all-namespaces --no-headers | wc -l)" == "0" ]; do sleep 1; done
while [ "$(bin/k3s kubectl get pods --all-namespaces --no-headers | grep -vE "Completed|Running" | wc -l)" != "0" ]; do sleep 1; done
2 changes: 0 additions & 2 deletions test/k8s/deploy.oci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ spec:
containers:
- name: demo
image: ghcr.io/containerd/runwasi/wasi-demo-oci:latest
imagePullPolicy: Never
- name: demo-artifact
image: ghcr.io/containerd/runwasi/wasi-demo-oci-artifact:latest
imagePullPolicy: Never
command: ["wasi-demo.wasm"]
- name: nginx
image: docker.io/nginx:latest
Expand Down
1 change: 0 additions & 1 deletion test/k8s/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ spec:
containers:
- name: demo
image: ghcr.io/containerd/runwasi/wasi-demo-app:latest
imagePullPolicy: Never
- name: nginx
image: docker.io/nginx:latest
ports:
Expand Down
Loading