Skip to content

Commit

Permalink
bump spin shim version to v2
Browse files Browse the repository at this point in the history
Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
  • Loading branch information
Mossaka committed Nov 7, 2023
1 parent d27476f commit cd15936
Show file tree
Hide file tree
Showing 32 changed files with 46 additions and 30 deletions.
36 changes: 26 additions & 10 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,41 @@ jobs:
os: "ubuntu-latest",
arch: "aarch64"
}
shims: [slight, spin, wws, lunatic]
shims:
- {
name: "slight",
version: "v1",
}
- {
name: "spin",
version: "v2",
}
- {
name: "wws",
version: "v1",
}
- {
name: "lunatic",
version: "v1",
}
env:
ARCH: ${{ matrix.config.arch }}
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
with:
workspaces: |
"containerd-shim-*-v1 -> target"
"containerd-shim-* -> target"
- name: "Install dependencies"
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler libseccomp-dev
- name: build ${{ matrix.shims }}
- name: build ${{ matrix.shims.name }}
run: |
VERBOSE=1 make build SHIMS=${{ matrix.shims }}
- name: unit tests ${{ matrix.shims }}
VERBOSE=1 make build SHIMS=${{ matrix.shims.name }}
- name: unit tests ${{ matrix.shims.name }}
run: |
VERBOSE=1 make unit-tests SHIMS=${{ matrix.shims }}
VERBOSE=1 make unit-tests SHIMS=${{ matrix.shims.name }}
- name: lowercase the runner OS name
shell: bash
run: |
Expand All @@ -44,12 +60,12 @@ jobs:
- name: package release assets
run: |
mkdir _dist
cp containerd-shim-*-v1/target/${{ matrix.config.arch }}-unknown-linux-musl/release/containerd-shim-*-v1 _dist/
cp containerd-shim-*/target/${{ matrix.config.arch }}-unknown-linux-musl/release/containerd-shim-*-${{ matrix.shims.version }} _dist/
cd _dist
tar czf containerd-wasm-shims-v1-${{ matrix.shims }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.tar.gz containerd-shim-*-v1
tar czf containerd-wasm-shims-${{ matrix.shims.version }}-${{ matrix.shims.name }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.tar.gz containerd-shim-*-${{ matrix.shims.version }}
- name: upload shim artifacts
uses: actions/upload-artifact@v3
with:
name: containerd-wasm-shims-v1-${{ matrix.shims }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}
path: _dist/containerd-wasm-shims-v1-${{ matrix.shims }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.tar.gz
name: containerd-wasm-shims-${{ matrix.shims.version }}-${{ matrix.shims.name }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}
path: _dist/containerd-wasm-shims-${{ matrix.shims.version }}-${{ matrix.shims.name }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.tar.gz
retention-days: 5
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: Swatinem/rust-cache@v2
with:
workspaces: |
"containerd-shim-*-v1 -> target"
"containerd-shim-* -> target"
- name: "Install dependencies"
run: |
sudo apt-get update
Expand All @@ -37,7 +37,7 @@ jobs:
- name: Extract containerd-wasm-shims-v1-linux-${{ env.ARCH }}
run: |
mkdir -p ./bin
for f in containerd-wasm-shims-v1-*-linux-${{ env.ARCH }}/containerd-wasm-shims-v1-*-linux-${{ env.ARCH }}.tar.gz
for f in containerd-wasm-shims-*-*-linux-${{ env.ARCH }}/containerd-wasm-shims-*-*-linux-${{ env.ARCH }}.tar.gz
do tar -xzf "$f" -C ./bin
done
- name: install k3d
Expand Down
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test: unit-tests integration-tests

.PHONY: unit-tests
unit-tests: build
$(foreach shim,$(SHIMS),cross test --release --manifest-path=containerd-shim-$(shim)-v1/Cargo.toml --target $(TARGET);)
$(foreach shim,$(SHIMS),cross test --release --manifest-path=containerd-shim-$(shim)/Cargo.toml --target $(TARGET);)

.PHONY: check-bins
check-bins:
Expand Down Expand Up @@ -56,8 +56,8 @@ test/clean:

.PHONY: fmt
fmt:
$(foreach shim,$(SHIMS),cargo fmt --all --manifest-path=containerd-shim-$(shim)-v1/Cargo.toml -- --check;)
$(foreach shim,$(SHIMS),cargo clippy --all-targets --all-features --workspace --manifest-path=containerd-shim-$(shim)-v1/Cargo.toml -- -D warnings;)
$(foreach shim,$(SHIMS),cargo fmt --all --manifest-path=containerd-shim-$(shim)/Cargo.toml -- --check;)
$(foreach shim,$(SHIMS),cargo clippy --all-targets --all-features --workspace --manifest-path=containerd-shim-$(shim)/Cargo.toml -- -D warnings;)
cargo fmt --all -- --check
cargo clippy --all-targets --all-features --workspace -- --deny=warnings

Expand All @@ -73,15 +73,15 @@ install-cross:
.PHONY: $(BUILD_TARGETS)
$(BUILD_TARGETS): SHIM = $(word 2,$(subst -, ,$@))
$(BUILD_TARGETS): install-cross
cross build --release --target $(TARGET) --manifest-path=containerd-shim-$(SHIM)-v1/Cargo.toml $(VERBOSE_FLAG)
cross build --release --target $(TARGET) --manifest-path=containerd-shim-$(SHIM)/Cargo.toml $(VERBOSE_FLAG)

.PHONY: build-%
build-%:
cargo build --release --manifest-path=containerd-shim-$*-v1/Cargo.toml
cargo build --release --manifest-path=containerd-shim-$*/Cargo.toml

.PHONY: install
install: $(foreach shim,$(SHIMS),build-$(shim))
sudo $(INSTALL) containerd-shim-*/target/release/containerd-shim-*-v1 $(PREFIX)/bin
sudo $(INSTALL) containerd-shim-*/target/release/containerd-shim-* $(PREFIX)/bin

.PHONY: update-deps
update-deps:
Expand All @@ -105,9 +105,9 @@ run_%: install load

.PHONY: clean
clean: $(addprefix clean-,$(SHIMS))
$(foreach shim,$(SHIMS),test -f $(PREFIX)/bin/containerd-shim-$(shim)-v1 && sudo rm -rf $(PREFIX)/bin/containerd-shim-$(proj)-v1 || true;)
$(foreach shim,$(SHIMS),test -f $(PREFIX)/bin/containerd-shim-$(shim)-* && sudo rm -rf $(PREFIX)/bin/containerd-shim-$(proj)-* || true;)
test -d ./test && sudo rm -rf ./test || true

.PHONY: clean-%
clean-%:
cargo clean --manifest-path containerd-shim-$*-v1/Cargo.toml
cargo clean --manifest-path containerd-shim-$*/Cargo.toml
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ As mentioned above, this project uses runwasi's `containerd-shim-wasm` to build
## Quickstarts

- [Start k3d and run a sample WASM application](./deployments/k3d/README.md#how-to-run-the-example).
- [Create a Spin application on k3d](./containerd-shim-spin-v1/quickstart.md)
- [Create a Spin application on k3d](./containerd-shim-spin-v2/quickstart.md)
- [Deploy a SpiderLightning application with k3d](./containerd-shim-slight-v1/quickstart.md)
- [Deploy a Wasm Workers Server application with k3d](./containerd-shim-slight-v1/quickstart.md)

Expand All @@ -53,12 +53,12 @@ In [the deployments directory](deployments) you will find examples of deploying

To use one of these containerd shims in Kubernetes, you must do the following:

1. Install the shim binary somewhere on the path of your Kubernetes worker nodes. For example, copy `containerd-shim-spin-v1` to `/bin`.
1. Install the shim binary somewhere on the path of your Kubernetes worker nodes. For example, copy `containerd-shim-spin-v2` to `/bin`.
2. Add the following to the containerd config.toml that maps the runtime type to the shim binary from step 1.

```toml
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.spin]
runtime_type = "io.containerd.spin.v1"
runtime_type = "io.containerd.spin.v2"
```

3. Apply a runtime class that contains a handler that matches the "spin" config runtime name from step 2.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "containerd-shim-spin-v1"
name = "containerd-shim-spin-v2"
version = "0.9.2"
authors = ["DeisLabs Engineering Team"]
edition = "2021"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion deployments/k3d/config.toml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ enable_keychain = true
{{end}}

[plugins.cri.containerd.runtimes.spin]
runtime_type = "io.containerd.spin.v1"
runtime_type = "io.containerd.spin.v2"

[plugins.cri.containerd.runtimes.slight]
runtime_type = "io.containerd.slight.v1"
Expand Down
6 changes: 3 additions & 3 deletions deployments/k8s/all-in-one-demo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ scheduling:
apiVersion: node.k8s.io/v1
kind: RuntimeClass
metadata:
name: "wasmtime-spin-v1"
name: "wasmtime-spin-v2"
handler: "spin"
scheduling:
nodeSelector:
"kubernetes.azure.com/wasmtime-spin-v1": "true"
"kubernetes.azure.com/wasmtime-spin-v2": "true"
---
apiVersion: node.k8s.io/v1
kind: RuntimeClass
Expand Down Expand Up @@ -71,7 +71,7 @@ spec:
labels:
app: wasm-spin
spec:
runtimeClassName: wasmtime-spin-v1
runtimeClassName: wasmtime-spin-v2
containers:
- name: testwasm
image: ghcr.io/deislabs/containerd-wasm-shims/examples/spin-rust-hello:latest
Expand Down
2 changes: 1 addition & 1 deletion scripts/move-bins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ default_shim_path="${bin_path}containerd-shim-"

declare -A shims=(
[slight]="${default_shim_path}slight-v1"
[spin]="${default_shim_path}spin-v1"
[spin]="${default_shim_path}spin-v2"
[wws]="${default_shim_path}wws-v1"
[lunatic]="${default_shim_path}lunatic-v1"
)
Expand Down

0 comments on commit cd15936

Please sign in to comment.