Skip to content

Commit

Permalink
Merge pull request #9 from knawd/runtime-ci
Browse files Browse the repository at this point in the history
Runtime ci
  • Loading branch information
No9 authored Feb 12, 2023
2 parents 6d5db7b + 1849d24 commit 08b3061
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 75 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/lint-test-charts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,7 @@ jobs:
if: steps.list-changed.outputs.changed == 'true'

- name: Run chart-testing (install)
run: ct install --config ct.yaml --helm-extra-set-args "--set target=ubuntu_18_04"
run: ct install --config ct.yaml --helm-extra-set-args "--set target=ubuntu_18_04"

- name: Run chart-testing (install wasmtime)
run: ct install --config ct.yaml --helm-extra-set-args "--set target=ubuntu_18_04 --set ociType=crun-wasmtime"
67 changes: 15 additions & 52 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
FROM ubuntu:18.04 as ubuntu18builder
FROM quay.io/knawd/libnode:ubuntu18 as ubuntu18builder

ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Etc/UTC
ENV WASMTIME_VERSION=v5.0.0
RUN apt-get update
RUN apt-get install -y curl make git gcc build-essential pkgconf libtool libsystemd-dev libprotobuf-c-dev libcap-dev libseccomp-dev libyajl-dev go-md2man libtool autoconf python3 automake xz-utils
RUN curl https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- -e all -p /usr/local --version=0.11.2
RUN git clone --depth 1 --recursive https://github.com/containers/crun.git
WORKDIR /
RUN git clone --depth 1 -b 1.8 --recursive https://github.com/containers/crun.git
WORKDIR /crun

RUN ./autogen.sh
RUN ./configure --with-wasmedge --enable-embedded-yajl
RUN make
Expand All @@ -22,11 +20,6 @@ RUN make
RUN ./crun --version
RUN mv crun crun-wasmtime

WORKDIR /wasm_nodejs
RUN git clone --depth 1 -b napi-libnode https://github.com/mmomtchev/node.git
WORKDIR /wasm_nodejs/node
RUN ./configure --shared
RUN make
WORKDIR /wasm_nodejs
RUN git clone --depth 1 -b node-wasm-experiment https://github.com/mhdawson/crun.git
WORKDIR /wasm_nodejs/crun
Expand All @@ -41,15 +34,11 @@ RUN make
RUN ./crun --version
RUN mv crun crun-wasm-nodejs

FROM ubuntu:20.04 as ubuntu20builder

ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Etc/UTC
FROM quay.io/knawd/libnode:ubuntu20 as ubuntu20builder
ENV WASMTIME_VERSION=v5.0.0
RUN apt update --fix-missing
RUN apt-get install -y curl make git gcc build-essential pkgconf libtool libsystemd-dev libprotobuf-c-dev libcap-dev libseccomp-dev libyajl-dev go-md2man libtool autoconf python3 automake xz-utils
RUN curl https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- -e all -p /usr/local --version=0.11.2
RUN git clone --depth 1 --recursive https://github.com/containers/crun.git
WORKDIR /
RUN git clone --depth 1 -b 1.8 --recursive https://github.com/containers/crun.git
WORKDIR /crun
RUN ./autogen.sh
RUN ./configure --with-wasmedge --enable-embedded-yajl
Expand All @@ -65,11 +54,6 @@ RUN make
RUN ./crun --version
RUN mv crun crun-wasmtime

WORKDIR /wasm_nodejs
RUN git clone --depth 1 -b napi-libnode https://github.com/mmomtchev/node.git
WORKDIR /wasm_nodejs/node
RUN ./configure --shared
RUN make
WORKDIR /wasm_nodejs
RUN git clone --depth 1 -b node-wasm-experiment https://github.com/mhdawson/crun.git
WORKDIR /wasm_nodejs/crun
Expand All @@ -84,25 +68,15 @@ RUN make
RUN ./crun --version
RUN mv crun crun-wasm-nodejs

FROM docker.io/rockylinux/rockylinux:8 as rhel8builder
FROM quay.io/knawd/libnode:rocky8 as rhel8builder
ENV WASMTIME_VERSION=v5.0.0
RUN dnf update -y
RUN dnf install -y dnf-plugins-core
RUN dnf config-manager --set-enabled plus
RUN dnf config-manager --set-enabled devel
RUN dnf config-manager --set-enabled powertools
RUN dnf clean all
RUN dnf update -y
RUN dnf repolist --all
RUN dnf -y install epel-release

RUN dnf install -y git python3 which redhat-lsb-core
RUN curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- -e all -p /usr/local --version=0.11.2
RUN dnf install -y systemd-devel yajl-devel libseccomp-devel pkg-config libgcrypt-devel \
glibc-static python3-libmount libtool libcap-devel
WORKDIR "/"
RUN git clone --depth 1 --recursive https://github.com/containers/crun.git
WORKDIR /
RUN git clone --depth 1 -b 1.8 --recursive https://github.com/containers/crun.git
WORKDIR /crun

RUN ./autogen.sh
RUN ./configure --with-wasmedge --enable-embedded-yajl
RUN make
Expand All @@ -119,11 +93,6 @@ RUN mv crun crun-wasmtime

### wasm_nodejs doesn't use the default crun so we are creating subfolders
WORKDIR /wasm_nodejs
RUN git clone --depth 1 -b napi-libnode https://github.com/mmomtchev/node.git
WORKDIR /wasm_nodejs/node
RUN ./configure --shared
RUN make
WORKDIR /wasm_nodejs
RUN git clone --depth 1 -b node-wasm-experiment https://github.com/mhdawson/crun.git
WORKDIR /wasm_nodejs/crun
RUN cp /wasm_nodejs/node/out/Release/libnode.so.* /lib64/libnode.so
Expand All @@ -137,31 +106,25 @@ RUN make
RUN ./crun --version
RUN mv crun crun-wasm-nodejs

RUN yum install -y gcc openssl-devel && \
rm -rf /var/cache/dnf && \
curl https://sh.rustup.rs -sSf | sh -s -- -y

COPY manager /app-build/

WORKDIR "/app-build"

ENV PATH=/root/.cargo/bin:${PATH}

RUN cargo build --release

RUN cargo test --release

FROM registry.access.redhat.com/ubi8:8.7-1054
FROM registry.access.redhat.com/ubi8:8.7-1054.1675788412

WORKDIR "/vendor/rhel8"

COPY --from=rhel8builder /usr/local/lib/libwasmedge.so.0 /lib64/libnode.so /crun/crun-wasmedge /crun/crun-wasmtime /wasm_nodejs/crun/crun-wasm-nodejs ./
COPY --from=rhel8builder /usr/local/lib/libwasmedge.so.0 /lib64/libnode.so /usr/local/lib/libwasmtime.so /crun/crun-wasmedge /crun/crun-wasmtime /wasm_nodejs/crun/crun-wasm-nodejs ./

WORKDIR "/vendor/ubuntu_20_04"
COPY --from=ubuntu20builder /usr/local/lib/libwasmedge.so.0 /lib64/libnode.so /crun/crun-wasmedge /crun/crun-wasmtime /wasm_nodejs/crun/crun-wasm-nodejs ./
COPY --from=ubuntu20builder /usr/local/lib/libwasmedge.so.0 /lib64/libnode.so /usr/local/lib/libwasmtime.so /crun/crun-wasmedge /crun/crun-wasmtime /wasm_nodejs/crun/crun-wasm-nodejs ./

WORKDIR "/vendor/ubuntu_18_04"
COPY --from=ubuntu18builder /usr/local/lib/libwasmedge.so.0 /lib64/libnode.so /crun/crun-wasmedge /crun/crun-wasmtime /wasm_nodejs/crun/crun-wasm-nodejs ./
COPY --from=ubuntu18builder /usr/local/lib/libwasmedge.so.0 /lib64/libnode.so /usr/local/lib/libwasmtime.so /crun/crun-wasmedge /crun/crun-wasmtime /wasm_nodejs/crun/crun-wasm-nodejs ./

WORKDIR "/app"
COPY --from=rhel8builder /app-build/target/release/manager ./
Expand Down
4 changes: 4 additions & 0 deletions FAQ.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Frequently Asked Questions

* What do I do if I want to change the WASM runtime on a server.
All current WASM workloads will have to be drained from the server as the crun update will not work due to it being locked on the server.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ The deployment is performed copying files to 3 locations on each node:

## Supported Versions

|Release|WASMEdge|WASMtime|crun|Ubuntu|OpenShift|
|---|---|---|---|---|---|
|v1.0.0-theta|0.11.2|5.0.0|[main](https://github.com/containers/crun/commit/26fe1383a05279935e67ee31e7ff10c43e7d87ea)|18.04, 20.04|4.10, 4.11|
|v1.0.0-gamma|0.11.2|5.0.0|[main](https://github.com/containers/crun/commit/26fe1383a05279935e67ee31e7ff10c43e7d87ea)|18.04, 20.04|4.10, 4.11|
|v1.0.0-beta|0.11.2|N/A|[main](https://github.com/containers/crun/commit/26fe1383a05279935e67ee31e7ff10c43e7d87ea)|18.04, 20.04|4.10, 4.11|
|v1.0.0-alpha|0.11.2|N/A|[main](https://github.com/containers/crun/commit/26fe1383a05279935e67ee31e7ff10c43e7d87ea)|18.04, 20.04|4.10, 4.11|
|Release|WASMEdge|WASMtime|node-wasm|crun|Ubuntu|OpenShift|
|---|---|---|---|---|---|---|
|v1.0.0-iota|0.11.2|5.0.0|[experiment](https://github.com/mhdawson/crun/commit/23f346e3bc15ec7e6188b405df895aef5a5cbcdd)|[1.8](https://github.com/containers/crun/releases/tag/1.8)|18.04, 20.04|4.10, 4.11|
|v1.0.0-theta|0.11.2|5.0.0|N/A|[main](https://github.com/containers/crun/commit/26fe1383a05279935e67ee31e7ff10c43e7d87ea)|18.04, 20.04|4.10, 4.11|
|v1.0.0-gamma|0.11.2|5.0.0|N/A|[main](https://github.com/containers/crun/commit/26fe1383a05279935e67ee31e7ff10c43e7d87ea)|18.04, 20.04|4.10, 4.11|
|v1.0.0-beta|0.11.2|N/A|N/A|[main](https://github.com/containers/crun/commit/26fe1383a05279935e67ee31e7ff10c43e7d87ea)|18.04, 20.04|4.10, 4.11|
|v1.0.0-alpha|0.11.2|N/A|N/A|[main](https://github.com/containers/crun/commit/26fe1383a05279935e67ee31e7ff10c43e7d87ea)|18.04, 20.04|4.10, 4.11|


N.B. Red Hat Core OS based instances have still to be tested and we expect some issues modifying the crio config and copying the WASM libs to the host.
Expand Down
10 changes: 5 additions & 5 deletions charts/knawd-deployer/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ sources:

type: application

version: v1.0.0-theta
version: v1.0.0-mu

appVersion: "v1.0.0-theta"
appVersion: "v1.0.0-mu"

# icon: https://raw.githubusercontent.com/No9/core-dump-handler/master/assets/handle-with-care-svgrepo-com.svg

Expand All @@ -25,13 +25,13 @@ maintainers:
annotations:
artifacthub.io/changes: |
- kind: added
description: Streamline the chart options
description: Streamline builds and support for wasm nodejs
links:
- name: GitHub PR
url: https://github.com/knawd/deployer/pull/7
url: https://github.com/knawd/deployer/pull/8
artifacthub.io/images: |
- name: knawd-deployer
image: quay.io/knawd/deployer:v1.0.0-beta
image: quay.io/knawd/deployer:v1.0.0-mu
artifacthub.io/license: MIT
artifacthub.io/signKey: |
fingerprint: BED079E67FD431E45301B1C9949E671B46AC8A34
Expand Down
2 changes: 1 addition & 1 deletion charts/knawd-deployer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ These are the values particular to the deployer service.
**tag**: The tag in the repository where the image is located used to specifiy a custom image (default: latest)
**autoRestart**: Should the deployer automatically restart the CRI service? Required for the config to be applied (default: true)
**logLevel**: The log level. Supported options `info`, `error`, `warn`, `debug` (default: "info")
**ociType**: The type of the OCI Runtime to deploy. Currently `crun-wasmedge` and `crun-wasmtime` are supported (default: "crun-wasmedge")
**ociType**: The type of the OCI Runtime to deploy. Currently `crun-wasmedge`, `crun-wasmtime` and `crun-wasm-nodejs` are supported (default: "crun-wasmedge")
**patchKnative**: Runs the patch to enable setting the runtime in a knative service definition.
2 changes: 0 additions & 2 deletions charts/knawd-deployer/templates/rbac.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{{- if eq .Values.target "rhel8" }}
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
Expand Down Expand Up @@ -73,5 +72,4 @@ roleRef:
kind: ClusterRole
name: knawd-cluster-role
apiGroup: rbac.authorization.k8s.io
{{- end }}
{{- end }}
5 changes: 4 additions & 1 deletion charts/knawd-deployer/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"enum": [
"v1.0.0-gamma",
"v1.0.0-theta",
"v1.0.0-iota",
"v1.0.0-mu",
"latest"
],
"default": "latest"
Expand All @@ -42,7 +44,8 @@
"type": "string",
"enum": [
"crun-wasmedge",
"crun-wasmtime"
"crun-wasmtime",
"crun-wasm-nodejs"
]
},
"default": "crun-wasmedge"
Expand Down
2 changes: 1 addition & 1 deletion charts/knawd-deployer/values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
target: rhel8
tag: v1.0.0-theta
tag: v1.0.0-mu
autoRestart: true
logLevel: "info"
ociType: "crun-wasmedge"
Expand Down
15 changes: 11 additions & 4 deletions manager/src/bin/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ static VENDOR_BASE: &str = "vendor";
#[allow(clippy::while_immutable_condition)]
#[tokio::main]
async fn main() -> Result<(), std::io::Error> {
let mut lib_files = vec!["libwasmedge.so.0"];
let mut lib_files = vec![];

// An output test so the build can be validated
if env::args().count() >= 2 && env::args().nth(1) != Some("remove".to_string()) {
Expand Down Expand Up @@ -46,8 +46,14 @@ async fn main() -> Result<(), std::io::Error> {
no_path_exit(&config_location);
no_path_exit(&oci_location);

if oci_type == *"crun-wasmedge" {
lib_files.push("libwasmedge.so.0");
}
if oci_type == *"crun-wasmtime" {
lib_files.push("libwasmtime.so");
}

if oci_type == *"crun-wasm-nodejs" {
//let mut libnode = "libnode.so";
lib_files.push("libnode.so");
}
let auto_restart = env::var("AUTO_RESTART")
Expand Down Expand Up @@ -131,13 +137,14 @@ async fn main() -> Result<(), std::io::Error> {

manager::copy_to(VENDOR_BASE, oci_location.as_str(), &vendor, &oci_type)?;
let full_oci_location = format!("{oci_location}/crun");
let host_oci_location = full_oci_location.replace(&node_root, "");
match vendor.as_str() {
"rhel8" => {
for file_name in &lib_files {
manager::copy_to(VENDOR_BASE, lib_location.as_str(), &vendor, file_name)?;
}
let crio_file = format!("{config_location}/crio.conf");
manager::update_crio_config(crio_file.as_str(), full_oci_location.as_str())?;
manager::update_crio_config(crio_file.as_str(), host_oci_location.as_str())?;
if auto_restart {
manager::restart_oci_runtime(node_root, is_micro_k8s, "crio".to_string())?;
}
Expand All @@ -147,7 +154,7 @@ async fn main() -> Result<(), std::io::Error> {
manager::copy_to(VENDOR_BASE, lib_location.as_str(), &vendor, file_name)?
}
let toml_file = format!("{config_location}/config.toml");
manager::update_containerd_config(toml_file.as_str(), full_oci_location.as_str())?;
manager::update_containerd_config(toml_file.as_str(), host_oci_location.as_str())?;
if auto_restart {
manager::restart_oci_runtime(node_root, is_micro_k8s, "containerd".to_string())?;
}
Expand Down
6 changes: 4 additions & 2 deletions manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ pub fn copy_to(
vendor: &str,
file_name: &str,
) -> Result<(), std::io::Error> {
let location = format!("{vendor_base}/{vendor}/{file_name}");
let location = format!("/{vendor_base}/{vendor}/{file_name}");

// Really software development is just about how neatly you can throw things away.
// Here we are selecting which type of crun to deploy
let destination: String = match file_name {
"crun-wasmedge" | "crun-wasmtime" => format!("{destination_base}/crun"),
"crun-wasmedge" | "crun-wasmtime" | "crun-wasm-nodejs" => {
format!("{destination_base}/crun")
}
_ => format!("{destination_base}/{file_name}"),
};

Expand Down

0 comments on commit 08b3061

Please sign in to comment.