Skip to content

Commit

Permalink
Merge pull request #3 from knawd/wasmtime
Browse files Browse the repository at this point in the history
feature: wasmtime support and chart lint
  • Loading branch information
No9 authored Feb 1, 2023
2 parents 96bea4d + 01c6c6b commit 07dcb2a
Show file tree
Hide file tree
Showing 11 changed files with 158 additions and 20 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/lint-test-charts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Lint and Test Charts

on: pull_request

jobs:
lint-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: v3.11.0

# Python is required because `ct lint` runs Yamale (https://github.com/23andMe/Yamale) and
# yamllint (https://github.com/adrienverge/yamllint) which require Python
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7

- name: Set up chart-testing
uses: helm/[email protected]

- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --config ct.yaml)
if [[ -n "$changed" ]]; then
echo "::set-output name=changed::true"
fi
- name: Run chart-testing (lint)
run: ct lint --config ct.yaml

- name: Create kind cluster
uses: helm/[email protected]
if: steps.list-changed.outputs.changed == 'true'

- name: Run chart-testing (install)
run: ct install --config ct.yaml
50 changes: 50 additions & 0 deletions .github/workflows/release-chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Release Charts

on:
push:
branches:
- main

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Install Helm
uses: azure/setup-helm@v3
with:
version: v3.11.0

# Optional step if GPG signing is used
- name: Prepare GPG key
run: |
gpg_dir=.cr-gpg
mkdir "$gpg_dir"
keyring="$gpg_dir/secring.gpg"
base64 -d <<< "$GPG_KEYRING_BASE64" > "$keyring"
passphrase_file="$gpg_dir/passphrase"
echo "$GPG_PASSPHRASE" > "$passphrase_file"
echo "CR_PASSPHRASE_FILE=$passphrase_file" >> "$GITHUB_ENV"
echo "CR_KEYRING=$keyring" >> "$GITHUB_ENV"
env:
GPG_KEYRING_BASE64: "${{ secrets.GPG_KEYRING_BASE64 }}"
GPG_PASSPHRASE: "${{ secrets.GPG_PASSPHRASE }}"

- name: Add dependency chart repos
run: |
helm repo add bitnami https://charts.bitnami.com/bitnami
- name: Run chart-releaser
uses: helm/[email protected]
with:
charts_dir: charts
config: cr.yaml
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
39 changes: 32 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM ubuntu:18.04 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
Expand All @@ -12,12 +12,21 @@ RUN ./autogen.sh
RUN ./configure --with-wasmedge --enable-embedded-yajl
RUN make
RUN ./crun --version
RUN mv crun crun-wasmedge

RUN curl -L https://github.com/bytecodealliance/wasmtime/releases/download/${WASMTIME_VERSION}/wasmtime-${WASMTIME_VERSION}-$(uname -m)-linux-c-api.tar.xz | tar xJf - -C /
RUN cp -R /wasmtime-${WASMTIME_VERSION}-$(uname -m)-linux-c-api/* /usr/local/
WORKDIR /crun
RUN ./configure --with-wasmtime --enable-embedded-yajl
RUN make
RUN ./crun --version
RUN mv crun crun-wasmtime

FROM ubuntu:20.04 as ubuntu20builder

ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Etc/UTC

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
Expand All @@ -27,8 +36,18 @@ RUN ./autogen.sh
RUN ./configure --with-wasmedge --enable-embedded-yajl
RUN make
RUN ./crun --version
RUN mv crun crun-wasmedge

RUN curl -L https://github.com/bytecodealliance/wasmtime/releases/download/${WASMTIME_VERSION}/wasmtime-${WASMTIME_VERSION}-$(uname -m)-linux-c-api.tar.xz | tar xJf - -C /
RUN cp -R /wasmtime-${WASMTIME_VERSION}-$(uname -m)-linux-c-api/* /usr/local/
WORKDIR /crun
RUN ./configure --with-wasmtime --enable-embedded-yajl
RUN make
RUN ./crun --version
RUN mv crun crun-wasmtime

FROM docker.io/rockylinux/rockylinux:8 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
Expand All @@ -50,7 +69,14 @@ RUN ./autogen.sh
RUN ./configure --with-wasmedge --enable-embedded-yajl
RUN make
RUN ./crun --version

RUN mv crun crun-wasmedge
RUN curl -L https://github.com/bytecodealliance/wasmtime/releases/download/${WASMTIME_VERSION}/wasmtime-${WASMTIME_VERSION}-$(uname -m)-linux-c-api.tar.xz | tar xJf - -C /
RUN cp -R /wasmtime-${WASMTIME_VERSION}-$(uname -m)-linux-c-api/* /usr/local/
WORKDIR /crun
RUN ./configure --with-wasmtime --enable-embedded-yajl
RUN make
RUN ./crun --version
RUN mv crun crun-wasmtime

RUN yum install -y gcc openssl-devel && \
rm -rf /var/cache/dnf && \
Expand All @@ -70,14 +96,13 @@ FROM registry.access.redhat.com/ubi8:8.7-1054

WORKDIR "/vendor/rhel8"


COPY --from=rhel8builder /usr/local/lib/libwasmedge.so.0 /crun/crun ./
COPY --from=rhel8builder /usr/local/lib/libwasmedge.so.0 /crun/crun-wasmedge /crun/crun-wasmtime ./

WORKDIR "/vendor/ubuntu_20_04"
COPY --from=ubuntu20builder /usr/local/lib/libwasmedge.so.0 /crun/crun ./
COPY --from=ubuntu20builder /usr/local/lib/libwasmedge.so.0 /crun/crun-wasmedge /crun/crun-wasmtime ./

WORKDIR "/vendor/ubuntu_18_04"
COPY --from=ubuntu18builder /usr/local/lib/libwasmedge.so.0 /crun/crun ./
COPY --from=ubuntu18builder /usr/local/lib/libwasmedge.so.0 /crun/crun-wasmedge /crun/crun-wasmtime ./

WORKDIR "/app"
COPY --from=rhel8builder /app-build/target/release/manager ./
Expand Down
6 changes: 3 additions & 3 deletions charts/knawd-deployer/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: knawd-deployer
description: A helm chart to deploy a WASI enabled crun.
type: application

keywords:
- wasi
- wasm
Expand All @@ -11,9 +11,9 @@ sources:

type: application

version: v1.0.0-beta
version: v1.0.0-gamma

appVersion: "v1.0.0-beta"
appVersion: "v1.0.0-gamma"

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

Expand Down
4 changes: 2 additions & 2 deletions charts/knawd-deployer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ daemonset:

configLocation: The location of the OCI configuration on the node (default: "/etc/containerd")

ociName: The name of the OCI Runtime file. Currently not in use (default: "crun")
ociType: The type of the OCI Runtime to deploy. Currently "crun-wasmedge" and "crun-wasmtime" are supported (default: "crun-wasmedge")

nodeRoot: The location in the deployer where the node file system is mounted (default: "/mnt/node-root")
nodeRoot: The location in the deployer where the node file system is mounted (default: "/mnt/node-root")

isMicroK8s: Is this a microK8s installation (default: false)

Expand Down
4 changes: 2 additions & 2 deletions charts/knawd-deployer/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ spec:
value: {{ .Values.daemonset.logLevel | quote }}
- name: OCI_LOCATION
value: {{ .Values.daemonset.ociLocation | quote }}
- name: OCI_NAME
value: {{ .Values.daemonset.ociName | quote }}
- name: OCI_TYPE
value: {{ .Values.daemonset.ociType | quote }}
- name: NODE_ROOT
value: {{ .Values.daemonset.nodeRoot | quote }}
- name: IS_MICROK8S
Expand Down
5 changes: 2 additions & 3 deletions charts/knawd-deployer/values.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

image:
registry: quay.io
repository: knawd/deployer
tag: v1.0.0-beta
tag: v1.0.0-gamma
pullPolicy: Always

daemonset:
Expand All @@ -13,7 +12,7 @@ daemonset:
logLevel: "info"
ociLocation: "/usr/local/sbin"
configLocation: "/etc/containerd"
ociName: "crun"
ociType: "crun-wasmedge"
nodeRoot: "/mnt/node-root"
isMicroK8s: false
autoRestart: true
Expand Down
5 changes: 5 additions & 0 deletions cr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Set to true for GPG signing
sign: true
# UID of the GPG key to use
key: Anton Whalley
release-name-template: "{{ .Version }}"
6 changes: 6 additions & 0 deletions ct.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
remote: origin
target-branch: main
chart-dirs:
- charts
helm-extra-args: "--timeout 600s"
check-version-increment: false
6 changes: 4 additions & 2 deletions manager/src/bin/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ async fn main() -> Result<(), std::io::Error> {
let oci_location = format!(
"{}{}",
node_root,
env::var("OCI_LOCATION").expect("OCI_LOCATION")
env::var("OCI_LOCATION").expect("OCI_LOCATION env should be set")
);

let oci_type = env::var("OCI_TYPE").expect("OCI_TYPE env should be set");

no_path_exit(&node_root);
no_path_exit(&lib_location);
no_path_exit(&config_location);
Expand Down Expand Up @@ -122,7 +124,7 @@ async fn main() -> Result<(), std::io::Error> {
return Ok(());
}

manager::copy_to(VENDOR_BASE, oci_location.as_str(), &vendor, "crun")?;
manager::copy_to(VENDOR_BASE, oci_location.as_str(), &vendor, &oci_type)?;
match vendor.as_str() {
"rhel8" => {
for file_name in &LIB_FILES {
Expand Down
9 changes: 8 additions & 1 deletion manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ pub fn copy_to(
file_name: &str,
) -> Result<(), std::io::Error> {
let location = format!("/{vendor_base}/{vendor}/{file_name}");
let destination = format!("/{destination_base}/{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"),
_ => format!("/{destination_base}/{file_name}"),
};

info!("Copying from {} to {}", location, destination);
fs::copy(location, destination)?;
Ok(())
Expand Down

0 comments on commit 07dcb2a

Please sign in to comment.