diff --git a/clr-k8s-examples/8-kata/fire-runtimeClass.yaml b/clr-k8s-examples/8-kata/fire-runtimeClass.yaml new file mode 100644 index 0000000..687f9a5 --- /dev/null +++ b/clr-k8s-examples/8-kata/fire-runtimeClass.yaml @@ -0,0 +1,6 @@ +kind: RuntimeClass +apiVersion: node.k8s.io/v1alpha1 +metadata: + name: fire +spec: + runtimeHandler: fire diff --git a/clr-k8s-examples/setup_firecracker.sh b/clr-k8s-examples/setup_firecracker.sh new file mode 100755 index 0000000..ae18fb9 --- /dev/null +++ b/clr-k8s-examples/setup_firecracker.sh @@ -0,0 +1,86 @@ +#!/bin/bash + +mkdir -p /etc/kata-containers + +# Setup a configuration to be used by firecracker +cat <> /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 diff --git a/clr-k8s-examples/setup_system.sh b/clr-k8s-examples/setup_system.sh index 3104225..134f759 100755 --- a/clr-k8s-examples/setup_system.sh +++ b/clr-k8s-examples/setup_system.sh @@ -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 diff --git a/clr-k8s-examples/tests/test-deploy-fire.yaml b/clr-k8s-examples/tests/test-deploy-fire.yaml new file mode 100644 index 0000000..a0cb338 --- /dev/null +++ b/clr-k8s-examples/tests/test-deploy-fire.yaml @@ -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