A code execution sandbox running natively on Kubernetes. Written in Kotlin.
The project leverages the power of Kubernetes orchestration and the security capabilities
of Kata containers to create a robust and secure(one day) environment for executing untrusted code.
The project uses Kata containers as a runtime environment, which provide lightweight, secure and isolated containerized virtual machines that offer an additional layer of protection compared to traditional container runtimes.
To build service images, use defined Github Actions.
We'll be using kata-containers stable-3.1.
- Setup clean ubuntu-server or some other base OS
sudo apt-get update && sudo apt-get upgrade && sudo apt-get install gitgit clone https://github.com/kata-containers/kata-containers.gitgit checkout stable-3.1curl -sfL https://get.k3s.io | sh -- Wait till k3s is up and running (check with
kubectl get nodes) cd /kata-containers/tools/packaging/kata-deploykubectl apply -f kata-rbac/base/kata-rbac.yamlkubectl apply -k kata-deploy/overlays/k3s- Wait till kata-containers is up and running (check with
kubectl -n kube-system wait --timeout=10m --for=condition=Ready -l name=kata-deploy pod) - Add kata-containers runtime-classes:
kubectl apply -f https://raw.githubusercontent.com/kata-containers/kata-containers/main/tools/packaging/kata-deploy/runtimeclasses/kata-runtimeClasses.yaml - Run an example kata-containers deployment:
kubectl apply -f https://raw.githubusercontent.com/kata-containers/kata-containers/main/tools/packaging/kata-deploy/examples/test-deploy-kata-dragonball.yaml - Check if the example deployment works correctly:
kubectl describe deployment php-apache-kata-dragonball
Source:
- https://docs.k3s.io/quick-start
- https://github.com/kata-containers/kata-containers/blob/stable-3.1/tools/packaging/kata-deploy/README.md
- Run
terraform applyon a machine which keeps the state of the cluster.
kubectl port-forward svc/prometheus-grafana -n monitoring 3000:80
kubectl port-forward svc/argocd-server -n argocd 8080:443kubectl port-forward svc/postgresdb -n postgres 5432:5432Then log into database using any database client and secrets available on the cluster (namespace postgres).
In order to run my version of Kubexecutor on dev cluster:
- Create a feature branch with desired changes.
- Modify image tag version in
k8s/overlays/dev/kustomization.yaml - Run Build & push Github Actions workflow of the modified service.
- Connect to ArgoCD, enter kubexecutor app -> app details -> edit.
- Change Target Revision to name of Your feature branch, i.e.
feature/test-deploy-from-branch. - Sync the state of the application in ArgoCD.
After testing the changes:
- Create a pull request with the changes and merge it.
- Change Target Revision in ArgoCD to
HEAD.