-
Notifications
You must be signed in to change notification settings - Fork 354
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
Add easy way to test with K8s #1884
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
|
||
sudo apt-get -y update | ||
sudo apt-get install -y pkg-config libsystemd-dev libdbus-glib-1-dev libelf-dev libseccomp-dev | ||
apt-get -y update | ||
apt-get install -y pkg-config libsystemd-dev libdbus-glib-1-dev libelf-dev libseccomp-dev |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ jobs: | |
uses: actions/checkout@v3 | ||
|
||
- name: Install requirements | ||
run: ./.github/scripts/dependency.sh | ||
run: sudo ./.github/scripts/dependency.sh | ||
|
||
- name: Setup Rust toolchain and cache | ||
uses: actions-rust-lang/[email protected] | ||
|
@@ -41,7 +41,7 @@ jobs: | |
ref: main | ||
|
||
- name: Install requirements | ||
run: ./.github/scripts/dependency.sh | ||
run: sudo ./.github/scripts/dependency.sh | ||
|
||
- name: Setup Rust toolchain and cache | ||
uses: actions-rust-lang/[email protected] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: 🧪 Containerd integration test | ||
name: 🧪 e2e test | ||
|
||
on: | ||
push: | ||
|
@@ -17,7 +17,7 @@ jobs: | |
- name: Setup Rust toolchain and cache | ||
uses: actions-rust-lang/[email protected] | ||
- name: Install requirements | ||
run: ./.github/scripts/dependency.sh | ||
run: sudo ./.github/scripts/dependency.sh | ||
- name: Build youki | ||
run: make youki-release | ||
- name: Upload youki binary | ||
|
@@ -57,3 +57,21 @@ jobs: | |
runc --version | ||
- name: Integration Test | ||
run: sudo make TEST_RUNTIME=io.containerd.runc.v2 TESTFLAGS="-timeout 40m" integration | ||
# | ||
# k8s-tests: | ||
# runs-on: ubuntu-22.04 | ||
# needs: [youki-build] | ||
# timeout-minutes: 40 | ||
# steps: | ||
# - uses: actions/checkout@v3 | ||
# - name: Download youki binary | ||
# uses: actions/download-artifact@v3 | ||
# with: | ||
# name: youki | ||
# - name: Add the permission to run | ||
# run: chmod +x ./youki | ||
# - name: test/k8s/deploy | ||
# run: make test/k8s/deploy | ||
# # - name: Debug | ||
# # if: ${{ always() }} | ||
# # uses: mxschmitt/action-tmate@v3 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ jobs: | |
- name: Setup Rust toolchain and cache | ||
uses: actions-rust-lang/[email protected] | ||
- name: Install requirements | ||
run: ./.github/scripts/dependency.sh | ||
run: sudo ./.github/scripts/dependency.sh | ||
- name: Install runc 1.1.0 | ||
run: | | ||
wget -q https://github.com/opencontainers/runc/releases/download/v1.1.0/runc.amd64 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,7 @@ jobs: | |
uses: actions-rust-lang/[email protected] | ||
- run: rustup component add rustfmt clippy | ||
- name: Install requirements | ||
run: ./.github/scripts/dependency.sh | ||
run: sudo ./.github/scripts/dependency.sh | ||
- run: sudo apt-get install -y pkg-config libsystemd-dev libdbus-glib-1-dev libelf-dev libseccomp-dev | ||
- name: Check formatting | ||
run: cargo fmt --all -- --check | ||
|
@@ -84,7 +84,7 @@ jobs: | |
with: | ||
tool: [email protected] | ||
- name: Install requirements | ||
run: ./.github/scripts/dependency.sh | ||
run: sudo ./.github/scripts/dependency.sh | ||
- name: Run Test Coverage for youki | ||
run: | | ||
cargo llvm-cov clean --workspace | ||
|
@@ -105,7 +105,7 @@ jobs: | |
- name: Setup Rust toolchain and cache | ||
uses: actions-rust-lang/[email protected] | ||
- name: Install requirements | ||
run: ./.github/scripts/dependency.sh | ||
run: sudo ./.github/scripts/dependency.sh | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: "1.17.6" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ jobs: | |
with: | ||
submodules: recursive | ||
- name: Install requirements | ||
run: ./.github/scripts/dependency.sh | ||
run: sudo ./.github/scripts/dependency.sh | ||
- name: Setup Rust toolchain and cache | ||
uses: actions-rust-lang/[email protected] | ||
- name: Build | ||
|
@@ -30,7 +30,7 @@ jobs: | |
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Install requirements | ||
run: ./.github/scripts/dependency.sh | ||
run: sudo ./.github/scripts/dependency.sh | ||
- name: Setup Rust toolchain and cache | ||
uses: actions-rust-lang/[email protected] | ||
- name: Release build | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,6 @@ tags.temp | |
*~ | ||
|
||
/bundle.tar.gz | ||
/test.log | ||
/test.log | ||
|
||
/tests/k8s/_out/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -204,7 +204,7 @@ pub fn container_init_process( | |
// before pivot_root is called. This runs in the container namespaces. | ||
if let Some(hooks) = hooks { | ||
hooks::run_hooks(hooks.create_container().as_ref(), container) | ||
.context("Failed to run create container hooks")?; | ||
.context("failed to run create container hooks")?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need this since these will be replaced with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prioritize the merge for subsequent work 🙇 |
||
} | ||
|
||
let bind_service = namespaces.get(LinuxNamespaceType::User).is_some(); | ||
|
@@ -216,7 +216,7 @@ pub fn container_init_process( | |
bind_service, | ||
namespaces.get(LinuxNamespaceType::Cgroup).is_some(), | ||
) | ||
.with_context(|| "Failed to prepare rootfs")?; | ||
.with_context(|| "failed to prepare rootfs")?; | ||
|
||
// Entering into the rootfs jail. If mount namespace is specified, then | ||
// we use pivot_root, but if we are on the host mount namespace, we will | ||
|
@@ -376,9 +376,9 @@ pub fn container_init_process( | |
warn!("seccomp not available, unable to enforce no_new_privileges!") | ||
} | ||
|
||
capabilities::reset_effective(syscall).context("Failed to reset effective capabilities")?; | ||
capabilities::reset_effective(syscall).context("failed to reset effective capabilities")?; | ||
if let Some(caps) = proc.capabilities() { | ||
capabilities::drop_privileges(caps, syscall).context("Failed to drop capabilities")?; | ||
capabilities::drop_privileges(caps, syscall).context("failed to drop capabilities")?; | ||
} | ||
|
||
// Change directory to process.cwd if process.cwd is not empty | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# syntax=docker/dockerfile:1.4 | ||
|
||
ARG KIND_NODE_VERSION=v1.23.13 | ||
|
||
FROM kindest/node:${KIND_NODE_VERSION} AS kind-base | ||
|
||
FROM kind-base AS shim-build | ||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > /tmp/rustup.sh && sh /tmp/rustup.sh -y --profile=minimal | ||
ENV PATH="/root/.cargo/bin:${PATH}" | ||
WORKDIR /shim | ||
COPY ./youki /shim/youki | ||
|
||
FROM scratch AS shim | ||
COPY --from=shim-build /shim/youki / | ||
|
||
FROM kind-base AS kind-fetch | ||
ARG TARGETARCH | ||
ARG KIND_VERSION=v0.17.0 | ||
RUN curl -sSLf https://kind.sigs.k8s.io/dl/${KIND_VERSION}/kind-linux-${TARGETARCH} > /root/kind && chmod +x /root/kind | ||
|
||
FROM scratch AS kind-bin | ||
COPY --from=kind-fetch /root/kind /kind | ||
|
||
FROM kind-base | ||
RUN <<EOF | ||
set -e | ||
echo '[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.youki]' >> /etc/containerd/config.toml | ||
echo ' runtime_type = "io.containerd.runc.v2"' >> /etc/containerd/config.toml | ||
echo ' [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.youki.options]' >> /etc/containerd/config.toml | ||
echo ' BinaryName = "/usr/local/bin/youki"' >> /etc/containerd/config.toml | ||
sed -i 's,SystemdCgroup = true,,' /etc/containerd/config.toml | ||
EOF | ||
COPY .github/scripts/dependency.sh .github/scripts/dependency.sh | ||
RUN apt-get update && .github/scripts/dependency.sh | ||
COPY --link --from=shim /* /usr/local/bin/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
apiVersion: node.k8s.io/v1 | ||
kind: RuntimeClass | ||
metadata: | ||
name: youki | ||
handler: youki | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: nginx-deployment | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: nginx | ||
replicas: 2 | ||
template: | ||
metadata: | ||
labels: | ||
app: nginx | ||
spec: | ||
runtimeClassName: youki | ||
containers: | ||
- name: nginx | ||
image: nginx:1.16.1 | ||
ports: | ||
- containerPort: 80 | ||
automountServiceAccountToken: false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Deleting this line, unfortunately, youki gives an error 😭 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you have an idea why? We should track this as an issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, I recommend separate the install step from the actual test step. We can create a
prepare
target that sets up the k3s environment for the test, thenmake test
should only check the dependency and run the test. In this way, the test can run multiple times without repeating the install step.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@YJDoc2 Since I can't take any more time today, but I don't want to interrupt your work, can I ask you to fix it with just PR?