2018-12-07 23:27:22 +00:00
## gVisor Addon
2019-03-29 11:16:02 +00:00
[gVisor ](https://gvisor.dev/ ), a sandboxed container runtime, allows users to securely run pods with untrusted workloads within Minikube.
2018-12-07 23:27:22 +00:00
### Starting Minikube
gVisor depends on the containerd runtime to run in Minikube.
When starting minikube, specify the following flags, along with any additional desired flags:
```shell
$ minikube start --container-runtime=containerd \
2019-02-05 19:04:03 +00:00
--docker-opt containerd=/var/run/containerd/containerd.sock
2018-12-07 23:27:22 +00:00
```
### Enabling gVisor
To enable this addon, simply run:
```
$ minikube addons enable gvisor
```
2019-03-29 11:16:02 +00:00
Within one minute, the addon manager should pick up the change and you should
see the `gvisor` pod and `gvisor` [Runtime Class ](https://kubernetes.io/docs/concepts/containers/runtime-class/ ):
2018-12-07 23:27:22 +00:00
```
2019-03-29 11:16:02 +00:00
$ kubectl get pod,runtimeclass gvisor -n kube-system
NAME READY STATUS RESTARTS AGE
pod/gvisor 1/1 Running 0 2m52s
NAME CREATED AT
runtimeclass.node.k8s.io/gvisor 2019-06-15T04:35:09Z
2018-12-07 23:27:22 +00:00
```
2019-03-29 11:16:02 +00:00
Once the pod has status `Running` , gVisor is enabled in Minikube.
2018-12-07 23:27:22 +00:00
### Running pods in gVisor
2019-03-29 11:16:02 +00:00
To run a pod in gVisor, add the `gvisor` runtime class to the Pod spec in your
Kubernetes yaml:
2018-12-07 23:27:22 +00:00
```
2019-03-29 11:16:02 +00:00
runtimeClassName: gvisor
2018-12-07 23:27:22 +00:00
```
An example Pod is shown below:
```yaml
apiVersion: v1
kind: Pod
metadata:
name: nginx-untrusted
spec:
2019-03-29 11:16:02 +00:00
runtimeClassName: gvisor
2018-12-07 23:27:22 +00:00
containers:
- name: nginx
image: nginx
```
### Disabling gVisor
2019-03-29 11:16:02 +00:00
2018-12-07 23:27:22 +00:00
To disable gVisor, run:
```
$ minikube addons disable gvisor
```
Within one minute, the addon manager should pick up the change.
Once the `gvisor` pod has status `Terminating` , or has been deleted, the gvisor addon should be disabled.
```
$ kubectl get pod gvisor -n kube-system
NAME READY STATUS RESTARTS AGE
gvisor 1/1 Terminating 0 5m
```
2019-03-29 11:16:02 +00:00
_Note: Once gVisor is disabled, any pod with the `gvisor` Runtime Class or `io.kubernetes.cri.untrusted-workload` annotation will fail with a FailedCreatePodSandBox error._