Skip to content

Commit

Permalink
kata-deploy: support kata-deploy for runtime-rs
Browse files Browse the repository at this point in the history
support kata-deploy for runtime-rs

Fixes:#5000
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
  • Loading branch information
Tim-0731-Hzt committed Sep 22, 2022
1 parent a394761 commit c6b3dcb
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 3 deletions.
15 changes: 14 additions & 1 deletion tools/packaging/kata-deploy/README.md
Expand Up @@ -81,6 +81,14 @@ which will ensure the workload is only scheduled on a node that has Kata Contain
```bash
$ kubectl apply -f https://raw.githubusercontent.com/kata-containers/kata-containers/main/tools/packaging/kata-deploy/runtimeclasses/kata-runtimeClasses.yaml
```
The following YAML snippet shows how to specify a workload should use Kata with `Dragonball`:

```yaml
spec:
template:
spec:
runtimeClassName: kata-dragonball
```

The following YAML snippet shows how to specify a workload should use Kata with Cloud Hypervisor:

Expand Down Expand Up @@ -108,6 +116,11 @@ spec:
spec:
runtimeClassName: kata-qemu
```
To run an example with `kata-dragonball`:

```bash
$ kubectl apply -f https://raw.githubusercontent.com/kata-containers/kata-containers/main/tools/packaging/kata-deploy/examples/test-deploy-kata-dragonball.yaml
```

To run an example with `kata-clh`:

Expand Down Expand Up @@ -192,7 +205,7 @@ from the [Kata Containers release page](https://github.com/kata-containers/kata-

Host artifacts:
* `cloud-hypervisor`, `firecracker`, `qemu`, and supporting binaries
* `containerd-shim-kata-v2`
* `containerd-shim-kata-v2` (go runtime and rust runtime)
* `kata-collect-data.sh`
* `kata-runtime`

Expand Down
2 changes: 1 addition & 1 deletion tools/packaging/kata-deploy/action/test-kata.sh
Expand Up @@ -66,7 +66,7 @@ function run_test() {
cmd="kubectl get pods | grep $busybox_pod | grep Completed"
wait_time=120

configurations=("nginx-deployment-qemu" "nginx-deployment-clh")
configurations=("nginx-deployment-qemu" "nginx-deployment-clh" "nginx-deployment-dragonball")
for deployment in "${configurations[@]}"; do
# start the kata pod:
kubectl apply -f "$YAMLPATH/examples/${deployment}.yaml"
Expand Down
@@ -0,0 +1,20 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment-dragonball
spec:
selector:
matchLabels:
app: nginx
replicas: 2
template:
metadata:
labels:
app: nginx
spec:
runtimeClassName: kata-dragonball
containers:
- name: nginx
image: nginx:1.14
ports:
- containerPort: 80
@@ -0,0 +1,42 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
run: php-apache-kata-dragonball
name: php-apache-kata-dragonball
spec:
replicas: 1
selector:
matchLabels:
run: php-apache-kata-dragonball
template:
metadata:
labels:
run: php-apache-kata-dragonball
spec:
runtimeClassName: kata-dragonball
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-dragonball
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
run: php-apache-kata-dragonball
sessionAffinity: None
type: ClusterIP
Expand Up @@ -37,3 +37,16 @@ overhead:
scheduling:
nodeSelector:
katacontainers.io/kata-runtime: "true"
---
kind: RuntimeClass
apiVersion: node.k8s.io/v1
metadata:
name: kata-dragonball
handler: kata-dragonball
overhead:
podFixed:
memory: "130Mi"
cpu: "250m"
scheduling:
nodeSelector:
katacontainers.io/kata-runtime: "true"
8 changes: 7 additions & 1 deletion tools/packaging/kata-deploy/scripts/kata-deploy.sh
Expand Up @@ -17,6 +17,7 @@ shims=(
"fc"
"qemu"
"clh"
"dragonball"
)

default_shim="qemu"
Expand Down Expand Up @@ -57,6 +58,7 @@ function install_artifacts() {
echo "copying kata artifacts onto host"
cp -a /opt/kata-artifacts/opt/kata/* /opt/kata/
chmod +x /opt/kata/bin/*
chmod +x /opt/kata/runtime-rs/bin/*
}

function configure_cri_runtime() {
Expand Down Expand Up @@ -98,7 +100,11 @@ function configure_different_shims_base() {
fi
fi

ln -sf /opt/kata/bin/containerd-shim-kata-v2 "${shim_file}"
if [[ "${shim}" == "dragonball" ]]; then
ln -sf /opt/kata/runtime-rs/bin/containerd-shim-kata-v2 "${shim_file}"
else
ln -sf /opt/kata/bin/containerd-shim-kata-v2 "${shim_file}"
fi
chmod +x "$shim_file"

if [ "${shim}" == "${default_shim}" ]; then
Expand Down

0 comments on commit c6b3dcb

Please sign in to comment.