Kata-Containers: Fix kata-containers runtime (#8068)

* Kata-containes: Fix for ubuntu and centos sometimes kata containers fail to start because of access errors to /dev/vhost-vsock and /dev/vhost-net

* Kata-containers: use similar testing strategy as gvisor

* Kata-Containers: adjust values for 2.2.0 defaults

Make CI tests actually pass

* Kata-Containers: bump to 2.2.2 to fix sandbox_cgroup_only issue
This commit is contained in:
Cristian Calin
2021-11-09 20:01:48 +02:00
committed by GitHub
parent 039205560a
commit b7ae4a2cfd
10 changed files with 287 additions and 18 deletions

View File

@@ -4,6 +4,7 @@
become: true
vars:
kata_containers_enabled: true
container_manager: containerd
roles:
- role: kubespray-defaults
- role: container-engine/containerd

View File

@@ -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"
}
]
}
}

View File

@@ -0,0 +1,10 @@
{
"metadata": {
"name": "kata1"
},
"image": {
"image": "docker.io/library/hello-world:latest"
},
"log_path": "kata1.0.log",
"linux": {}
}

View File

@@ -0,0 +1,10 @@
{
"metadata": {
"name": "kata1",
"namespace": "default",
"attempt": 1,
"uid": "hdishd83djaidwnduwk28bcsb"
},
"linux": {},
"log_directory": "/tmp"
}

View File

@@ -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

View File

@@ -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