mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-28 16:27:50 +00:00
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:
commit
827e85d259
42
kata-deploy/examples/test-deploy-kata-qemu-virtiofs.yaml
Normal file
42
kata-deploy/examples/test-deploy-kata-qemu-virtiofs.yaml
Normal 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
|
14
kata-deploy/k8s-1.13/kata-qemu-virtiofs-runtimeClass.yaml
Normal file
14
kata-deploy/k8s-1.13/kata-qemu-virtiofs-runtimeClass.yaml
Normal 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
|
12
kata-deploy/k8s-1.14/kata-qemu-virtiofs-runtimeClass.yaml
Normal file
12
kata-deploy/k8s-1.14/kata-qemu-virtiofs-runtimeClass.yaml
Normal 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
|
@ -40,6 +40,10 @@ function configure_docker() {
|
|||||||
"path": "/opt/kata/bin/kata-runtime",
|
"path": "/opt/kata/bin/kata-runtime",
|
||||||
"runtimeArgs": [ "--kata-config", "/opt/kata/share/defaults/kata-containers/configuration-qemu.toml" ]
|
"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": {
|
"kata-nemu": {
|
||||||
"path": "/opt/kata/bin/kata-runtime",
|
"path": "/opt/kata/bin/kata-runtime",
|
||||||
"runtimeArgs": [ "--kata-config", "/opt/kata/share/defaults/kata-containers/configuration-nemu.toml" ]
|
"runtimeArgs": [ "--kata-config", "/opt/kata/share/defaults/kata-containers/configuration-nemu.toml" ]
|
||||||
|
@ -65,9 +65,11 @@ function configure_crio() {
|
|||||||
cp -n "$crio_conf_file" "$crio_conf_file_backup"
|
cp -n "$crio_conf_file" "$crio_conf_file_backup"
|
||||||
|
|
||||||
local kata_qemu_path="/opt/kata/bin/kata-qemu"
|
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_nemu_path="/opt/kata/bin/kata-nemu"
|
||||||
local kata_fc_path="/opt/kata/bin/kata-fc"
|
local kata_fc_path="/opt/kata/bin/kata-fc"
|
||||||
local kata_qemu_conf="crio.runtime.runtimes.kata-qemu"
|
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_nemu_conf="crio.runtime.runtimes.kata-nemu"
|
||||||
local kata_fc_conf="crio.runtime.runtimes.kata-fc"
|
local kata_fc_conf="crio.runtime.runtimes.kata-fc"
|
||||||
|
|
||||||
@ -84,6 +86,20 @@ function configure_crio() {
|
|||||||
EOT
|
EOT
|
||||||
fi
|
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
|
# add kata-nemu config
|
||||||
if grep -q "^\[$kata_nemu_conf\]" $crio_conf_file; then
|
if grep -q "^\[$kata_nemu_conf\]" $crio_conf_file; then
|
||||||
echo "Configuration exists $kata_nemu_conf, overwriting"
|
echo "Configuration exists $kata_nemu_conf, overwriting"
|
||||||
|
@ -78,10 +78,12 @@ Commands:
|
|||||||
|
|
||||||
Options:
|
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.
|
-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.
|
-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.
|
-v : Kernel version to use if kernel path not provided.
|
||||||
EOT
|
EOT
|
||||||
}
|
}
|
||||||
@ -414,10 +416,14 @@ main() {
|
|||||||
|
|
||||||
# If not kernel version take it from versions.yaml
|
# If not kernel version take it from versions.yaml
|
||||||
if [ -z "$kernel_version" ]; then
|
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")
|
kernel_version=$(get_from_kata_deps "assets.kernel.version")
|
||||||
#Remove extra 'v'
|
#Remove extra 'v'
|
||||||
kernel_version="${kernel_version#v}"
|
kernel_version="${kernel_version#v}"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "${kernel_path}" ]; then
|
if [ -z "${kernel_path}" ]; then
|
||||||
config_version=$(get_config_version)
|
config_version=$(get_config_version)
|
||||||
|
@ -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 static nemu asset
|
||||||
install_nemu() {
|
install_nemu() {
|
||||||
info "build static nemu"
|
info "build static nemu"
|
||||||
@ -122,8 +133,8 @@ install_qemu() {
|
|||||||
# Install static qemu-virtiofsd asset
|
# Install static qemu-virtiofsd asset
|
||||||
install_qemu_virtiofsd() {
|
install_qemu_virtiofsd() {
|
||||||
info "build static qemu-virtiofs"
|
info "build static qemu-virtiofs"
|
||||||
"${script_dir}/../static-build/qemu-virtiofsd/build-static-qemu.sh"
|
"${script_dir}/../static-build/qemu-virtiofs/build-static-qemu-virtiofs.sh"
|
||||||
info "Install static qemu-virtiofsd"
|
info "Install static qemu-virtiofs"
|
||||||
tar xf kata-qemu-static.tar.gz -C "${destdir}"
|
tar xf kata-qemu-static.tar.gz -C "${destdir}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,6 +227,7 @@ main() {
|
|||||||
install_image
|
install_image
|
||||||
install_kata_components
|
install_kata_components
|
||||||
install_kernel
|
install_kernel
|
||||||
|
install_experimental_kernel
|
||||||
install_qemu
|
install_qemu
|
||||||
install_qemu_virtiofsd
|
install_qemu_virtiofsd
|
||||||
install_nemu
|
install_nemu
|
||||||
|
@ -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)
|
||||||
RUN make -j$(nproc) virtiofsd
|
RUN make -j$(nproc) virtiofsd
|
||||||
RUN make install DESTDIR=/tmp/qemu-virtiofs-static
|
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 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 *
|
RUN cd /tmp/qemu-virtiofs-static && tar -czvf kata-qemu-static.tar.gz *
|
||||||
|
@ -11,11 +11,12 @@ set -o pipefail
|
|||||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
source "${script_dir}/../../scripts/lib.sh"
|
source "${script_dir}/../../scripts/lib.sh"
|
||||||
|
source "${script_dir}/../qemu.blacklist"
|
||||||
|
|
||||||
packaging_dir="${script_dir}/../.."
|
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
|
# 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_tar="kata-qemu-static.tar.gz"
|
||||||
qemu_tmp_tar="kata-qemu-static-tmp.tar.gz"
|
qemu_tmp_tar="kata-qemu-static-tmp.tar.gz"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user