Skip to content

Commit

Permalink
feat(*): use published images instead of locally built ones
Browse files Browse the repository at this point in the history
- Replaced `make load` with `sudo make pull`
- Updated documents to pull images from `ghcr.io` instead of building them locally

Signed-off-by: Jiaxiao (mossaka) Zhou <duibao55328@gmail.com>
  • Loading branch information
Mossaka committed Jan 28, 2025
1 parent 5088658 commit 570a9fe
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/action-test-smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,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
6 changes: 3 additions & 3 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- 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
make OPT_PROFILE=release build install pull
- name: Run Benchmarks
shell: bash
run: |
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:
- 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
make OPT_PROFILE=release build install pull
- name: Run Benchmarks
shell: bash
run: |
Expand Down Expand Up @@ -113,7 +113,7 @@ jobs:
- name: Build and load shims and wasi-demo-app
shell: bash
run: |
make OPT_PROFILE=release build install test-image/http load/http
make OPT_PROFILE=release build install pull
- name: Start wasmtime shim
shell: bash
run: |
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

0 comments on commit 570a9fe

Please sign in to comment.