mirror of
https://github.com/clearlinux/cloud-native-setup.git
synced 2026-08-19 13:36:43 +00:00
Initial support for firecracker configuration on Clearlinux
Initial support for firecracker configuration on Clearlinux. This is a little bit complicated due to CRIO requiring a disk or partition to use devicemapper. Signed-off-by: Manohar Castelino <manohar.r.castelino@intel.com>
This commit is contained in:
committed by
Manohar Castelino
parent
113e3b4daf
commit
7dfce0dd00
@@ -0,0 +1,6 @@
|
||||
kind: RuntimeClass
|
||||
apiVersion: node.k8s.io/v1alpha1
|
||||
metadata:
|
||||
name: fire
|
||||
spec:
|
||||
runtimeHandler: fire
|
||||
Executable
+86
@@ -0,0 +1,86 @@
|
||||
#!/bin/bash
|
||||
|
||||
mkdir -p /etc/kata-containers
|
||||
|
||||
# Setup a configuration to be used by firecracker
|
||||
cat <<EOT | tee /etc/kata-containers/configuration_firecracker.toml
|
||||
[hypervisor.firecracker]
|
||||
path = "/usr/bin/firecracker"
|
||||
kernel = "/usr//share/kata-containers/vmlinux.container"
|
||||
image = "/usr//share/kata-containers/kata-containers.img"
|
||||
kernel_params = ""
|
||||
default_vcpus = 1
|
||||
default_memory = 4096
|
||||
default_maxvcpus = 0
|
||||
default_bridges = 1
|
||||
block_device_driver = "virtio-mmio"
|
||||
disable_block_device_use = false
|
||||
enable_debug = true
|
||||
use_vsock = true
|
||||
|
||||
[shim.kata]
|
||||
path = "/usr//libexec/kata-containers/kata-shim"
|
||||
|
||||
[agent.kata]
|
||||
|
||||
[runtime]
|
||||
internetworking_model="tcfilter"
|
||||
EOT
|
||||
|
||||
# Firecracker can only work with devicemapper
|
||||
# Setup a sparse disk to be used for devicemapper
|
||||
rm -f /var/lib/crio/devicemapper/disk.img
|
||||
mkdir -p /var/lib/crio/devicemapper
|
||||
truncate /var/lib/crio/devicemapper/disk.img --size 10G
|
||||
|
||||
# Ensure that this disk is loop mounted at each boot
|
||||
mkdir -p /etc/systemd/system
|
||||
|
||||
cat <<EOT | tee /etc/systemd/system/devicemapper.service
|
||||
[Unit]
|
||||
Description=Setup CRIO devicemapper
|
||||
DefaultDependencies=no
|
||||
After=systemd-udev-settle.service
|
||||
Before=lvm2-activation-early.service
|
||||
Wants=systemd-udev-settle.service
|
||||
|
||||
[Service]
|
||||
ExecStart=-/sbin/losetup /dev/loop8 /var/lib/crio/devicemapper/disk.img
|
||||
RemainAfterExit=true
|
||||
Type=oneshot
|
||||
|
||||
[Install]
|
||||
WantedBy=local-fs.target
|
||||
EOT
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl start devicemapper
|
||||
|
||||
# For now till we address https://github.com/kubernetes-sigs/cri-o/issues/1991
|
||||
# use a shell script to expose firecracker through kata
|
||||
cat <<EOT | tee /usr/bin/kata-runtime-fire
|
||||
#!/bin/bash
|
||||
|
||||
/usr/bin/kata-runtime --kata-config /etc/kata-containers/configuration_firecracker.toml "\$@"
|
||||
EOT
|
||||
|
||||
chmod +x /usr/bin/kata-runtime-fire
|
||||
|
||||
# Add firecracker as a second runtime
|
||||
# Also setup crio to use devicemapper
|
||||
|
||||
mkdir -p /etc/crio/
|
||||
cp /usr/share/defaults/crio/crio.conf /etc/crio/crio.conf
|
||||
|
||||
echo -e "\n[crio.runtime.runtimes.kata]\nruntime_path = \"/usr/bin/kata-runtime\"" >> /etc/crio/crio.conf
|
||||
echo -e "\n[crio.runtime.runtimes.fire]\nruntime_path = \"/usr/bin/kata-runtime-fire\"" >> /etc/crio/crio.conf
|
||||
|
||||
sed -i 's|\(\[crio\.runtime\]\)|\1\nmanage_network_ns_lifecycle = true|' /etc/crio/crio.conf
|
||||
|
||||
sed -i 's/storage_driver = \"overlay\"/storage_driver = \"devicemapper\"\
|
||||
storage_option = [\
|
||||
\"dm.basesize=8G\",\
|
||||
\"dm.directlvm_device=\/dev\/loop8\",\
|
||||
\"dm.directlvm_device_force=true\",\
|
||||
\"dm.fs=ext4\"\
|
||||
]/g' /etc/crio/crio.conf
|
||||
@@ -3,6 +3,9 @@
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
|
||||
CUR_DIR=$(pwd)
|
||||
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
|
||||
|
||||
ADD_NO_PROXY="10.244.0.0/16,10.96.0.0/12"
|
||||
ADD_NO_PROXY+=",$(hostname -I | sed 's/[[:space:]]/,/g')"
|
||||
|
||||
@@ -78,6 +81,8 @@ EOF
|
||||
fi
|
||||
set -o nounset
|
||||
|
||||
sudo $SCRIPT_DIR/setup_firecracker.sh
|
||||
|
||||
# We have potentially modified their env files, we need to restart the services.
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl restart crio || true
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
run: php-apache-fire
|
||||
name: php-apache-fire
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
run: php-apache-fire
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
run: php-apache-fire
|
||||
spec:
|
||||
runtimeClassName: fire
|
||||
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-fire
|
||||
spec:
|
||||
ports:
|
||||
- port: 80
|
||||
protocol: TCP
|
||||
targetPort: 80
|
||||
selector:
|
||||
run: php-apache-fire
|
||||
sessionAffinity: None
|
||||
type: ClusterIP
|
||||
Reference in New Issue
Block a user