Skip to content
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

Kata-Containers: Fix kata-containers runtime #8068

Merged
merged 4 commits into from
Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
become: true
vars:
kata_containers_enabled: true
container_manager: containerd
roles:
- role: kubespray-defaults
- role: container-engine/containerd
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"cniVersion": "0.2.0",
"name": "mynet",
"type": "bridge",
"bridge": "cni0",
"isGateway": true,
"ipMasq": true,
"ipam": {
"type": "host-local",
"subnet": "172.19.0.0/24",
"routes": [
{
"dst": "0.0.0.0/0"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"metadata": {
"name": "kata1"
},
"image": {
"image": "docker.io/library/hello-world:latest"
},
"log_path": "kata1.0.log",
"linux": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"metadata": {
"name": "kata1",
"namespace": "default",
"attempt": 1,
"uid": "hdishd83djaidwnduwk28bcsb"
},
"linux": {},
"log_directory": "/tmp"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,48 @@
---
- name: Prepare
hosts: all
gather_facts: False
become: true
roles:
- role: kubespray-defaults
- role: bootstrap-os
- role: adduser
user: "{{ addusers.kube }}"
tasks:
- include_tasks: "../../../../download/tasks/download_file.yml"
vars:
download: "{{ download_defaults | combine(downloads.cni) }}"

- name: Prepare container runtime
hosts: all
become: true
vars:
container_manager: containerd
kube_network_plugin: cni
roles:
- role: kubespray-defaults
- role: network_plugin/cni
- role: container-engine/crictl
tasks:
- name: Copy test container files
copy:
src: "{{ item }}"
dest: "/tmp/{{ item }}"
owner: root
mode: 0644
with_items:
- container.json
- sandbox.json
- name: Create /etc/cni/net.d directory
file:
path: /etc/cni/net.d
state: directory
owner: kube
mode: 0755
- name: Setup CNI
copy:
src: "{{ item }}"
dest: "/etc/cni/net.d/{{ item }}"
owner: root
mode: 0644
with_items:
- 10-mynet.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,24 @@ def test_run(host):
assert "kata-runtime" in cmd.stdout


def test_run_pod(host):
image = "docker.io/library/hello-world:latest"
runtime = "io.containerd.kata-qemu.v2"

pull_command = "ctr image pull {}".format(image)
def test_run_check(host):
kataruntime = "/opt/kata/bin/kata-runtime"
with host.sudo():
cmd = host.command(pull_command)
cmd = host.command(kataruntime + " check")
assert cmd.rc == 0
assert "System is capable of running" in cmd.stdout

run_command = "ctr run --runtime {} {} kata1".format(runtime, image)

def test_run_pod(host):
runtime = "kata-qemu"

run_command = "/usr/local/bin/crictl run --with-pull --runtime {} /tmp/container.json /tmp/sandbox.json".format(runtime)
with host.sudo():
cmd = host.command(run_command)
assert cmd.rc == 0
assert "Hello from Docker!" in cmd.stdout

with host.sudo():
log_f = host.file("/tmp/kata1.0.log")

assert log_f.exists
assert b"Hello from Docker!" in log_f.content
16 changes: 16 additions & 0 deletions roles/container-engine/kata-containers/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,19 @@
mode: 0755
with_items:
- qemu

- name: kata-containers | Load vhost kernel modules
modprobe:
state: present
name: "{{ item }}"
with_items:
- vhost_vsock
- vhost_net

- name: kata-containers | Persist vhost kernel modules
copy:
dest: /etc/modules-load.d/kubespray-kata-containers.conf
mode: 0644
content: |
vhost_vsock
vhost_net
Loading