Merge pull request #710 from GabyCT/topic/qemuvirt

kata-deploy: Add support for qemu and kernel with virtio-fs 3.0
This commit is contained in:
Jose Carlos Venegas Munoz 2019-09-18 09:45:17 -05:00 committed by GitHub
commit 827e85d259
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 117 additions and 9 deletions

View File

@ -0,0 +1,42 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
run: php-apache-kata-qemu-virtiofs
name: php-apache-kata-qemu-virtiofs
spec:
replicas: 1
selector:
matchLabels:
run: php-apache-kata-qemu-virtiofs
template:
metadata:
labels:
run: php-apache-kata-qemu-virtiofs
spec:
runtimeClassName: kata-qemu-virtiofs
containers:
- image: k8s.gcr.io/hpa-example
imagePullPolicy: Always
name: php-apache
ports:
- containerPort: 80
protocol: TCP
resources:
requests:
cpu: 200m
restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
name: php-apache-kata-qemu-virtiofs
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
run: php-apache-kata-qemu-virtiofs
sessionAffinity: None
type: ClusterIP

View File

@ -0,0 +1,14 @@
---
kind: RuntimeClass
apiVersion: node.k8s.io/v1alpha1
metadata:
name: kata-qemu-virtiofs
spec:
runtimeHandler: kata-qemu-virtiofs
---
kind: RuntimeClass
apiVersion: node.k8s.io/v1alpha1
metadata:
name: kata
spec:
runtimeHandler: kata

View File

@ -0,0 +1,12 @@
---
kind: RuntimeClass
apiVersion: node.k8s.io/v1beta1
metadata:
name: kata
handler: kata
---
kind: RuntimeClass
apiVersion: node.k8s.io/v1beta1
metadata:
name: kata-qemu-virtiofs
handler: kata-qemu-virtiofs

View File

@ -40,6 +40,10 @@ function configure_docker() {
"path": "/opt/kata/bin/kata-runtime",
"runtimeArgs": [ "--kata-config", "/opt/kata/share/defaults/kata-containers/configuration-qemu.toml" ]
},
"kata-qemu-virtiofs": {
"path": "/opt/kata/bin/kata-runtime",
"runtimeArgs": [ "--kata-config", "/opt/kata/share/defaults/kata-containers/configuration-qemu-virtiofs.toml" ]
},
"kata-nemu": {
"path": "/opt/kata/bin/kata-runtime",
"runtimeArgs": [ "--kata-config", "/opt/kata/share/defaults/kata-containers/configuration-nemu.toml" ]

View File

@ -65,9 +65,11 @@ function configure_crio() {
cp -n "$crio_conf_file" "$crio_conf_file_backup"
local kata_qemu_path="/opt/kata/bin/kata-qemu"
local kata_qemu_virtiofs_path="/opt/kata/bin/kata-qemu-virtiofs"
local kata_nemu_path="/opt/kata/bin/kata-nemu"
local kata_fc_path="/opt/kata/bin/kata-fc"
local kata_qemu_conf="crio.runtime.runtimes.kata-qemu"
local kata_qemu_virtiofs_conf="crio.runtime.runtimes.kata-qemu-virtiofs"
local kata_nemu_conf="crio.runtime.runtimes.kata-nemu"
local kata_fc_conf="crio.runtime.runtimes.kata-fc"
@ -84,6 +86,20 @@ function configure_crio() {
EOT
fi
# add kata-qemu-virtiofs config
if grep -q "^\[$kata_qemu_virtiofs_conf\]" $crio_conf_file; then
echo "Configuration exists $kata_qemu_virtiofs_conf, overwriting"
sed -i "/^\[$kata_qemu_virtiofs_conf\]/,+1s#runtime_path.*#runtime_path = \"${kata_qemu_path}\"#" $crio_conf_file
else
cat <<EOT | tee -a "$crio_conf_file"
# Path to the Kata Containers runtime binary that uses the QEMU hypervisor.
[$kata_qemu_conf]
runtime_path = "${kata_qemu_virtiofs_path}"
EOT
fi
# add kata-nemu config
if grep -q "^\[$kata_nemu_conf\]" $crio_conf_file; then
echo "Configuration exists $kata_nemu_conf, overwriting"

View File

@ -78,10 +78,12 @@ Commands:
Options:
-c <path>: Path to config file to build a the kernel
-c <path>: Path to config file to build a the kernel.
-e : Enable experimental kernel.
-h : Display this help.
-k <path>: Path to kernel to build
-k <path>: Path to kernel to build.
-p <path>: Path to a directory with patches to apply to kernel.
-t : Hypervisor_target.
-v : Kernel version to use if kernel path not provided.
EOT
}
@ -414,10 +416,14 @@ main() {
# If not kernel version take it from versions.yaml
if [ -z "$kernel_version" ]; then
if [[ ${experimental_kernel} == "true" ]]; then
kernel_version=$(get_from_kata_deps "assets.kernel-experimental.tag")
else
kernel_version=$(get_from_kata_deps "assets.kernel.version")
#Remove extra 'v'
kernel_version="${kernel_version#v}"
fi
fi
if [ -z "${kernel_path}" ]; then
config_version=$(get_config_version)

View File

@ -103,6 +103,17 @@ install_kernel() {
)
}
#Install experimental kernel asset
install_experimental_kernel() {
pushd ${GOPATH}/src/github.com/${project}/packaging
info "build experimental kernel"
./kernel/build-kernel.sh -e setup
./kernel/build-kernel.sh -e build
info "install experimental kernel"
DESTDIR="${destdir}" PREFIX="${prefix}" ./kernel/build-kernel.sh -e install
popd
}
# Install static nemu asset
install_nemu() {
info "build static nemu"
@ -122,8 +133,8 @@ install_qemu() {
# Install static qemu-virtiofsd asset
install_qemu_virtiofsd() {
info "build static qemu-virtiofs"
"${script_dir}/../static-build/qemu-virtiofsd/build-static-qemu.sh"
info "Install static qemu-virtiofsd"
"${script_dir}/../static-build/qemu-virtiofs/build-static-qemu-virtiofs.sh"
info "Install static qemu-virtiofs"
tar xf kata-qemu-static.tar.gz -C "${destdir}"
}
@ -216,6 +227,7 @@ main() {
install_image
install_kata_components
install_kernel
install_experimental_kernel
install_qemu
install_qemu_virtiofsd
install_nemu

View File

@ -44,5 +44,6 @@ RUN PREFIX="${PREFIX}" /root/configure-hypervisor.sh -s kata-qemu | sed -e 's|--
RUN make -j$(nproc)
RUN make -j$(nproc) virtiofsd
RUN make install DESTDIR=/tmp/qemu-virtiofs-static
RUN mv /tmp/qemu-virtiofs-static/"${PREFIX}"/bin/qemu-system-x86_64 /tmp/qemu-virtiofs-static/"${PREFIX}"/bin/qemu-virtiofs-system-x86_64
RUN chmod +x virtiofsd && mv virtiofsd /tmp/qemu-virtiofs-static/opt/kata/bin/
RUN cd /tmp/qemu-virtiofs-static && tar -czvf kata-qemu-static.tar.gz *

View File

@ -11,11 +11,12 @@ set -o pipefail
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${script_dir}/../../scripts/lib.sh"
source "${script_dir}/../qemu.blacklist"
packaging_dir="${script_dir}/../.."
qemu_virtiofs_repo="https://gitlab.com/virtio-fs/qemu.git"
qemu_virtiofs_repo=$(get_from_kata_deps "assets.hypervisor.qemu-experimental.url")
# This tag will be supported on the runtime versions.yaml
qemu_virtiofs_tag="virtio-fs-v0.3"
qemu_virtiofs_tag=$(get_from_kata_deps "assets.hypervisor.qemu-experimental.tag")
qemu_tar="kata-qemu-static.tar.gz"
qemu_tmp_tar="kata-qemu-static-tmp.tar.gz"